VirtualBox VBoxManage可以动态添加/删除共享文件夹吗? [英] Can VirtualBox VBoxManage add/remove shared folders on the fly?

查看:275
本文介绍了VirtualBox VBoxManage可以动态添加/删除共享文件夹吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试向我的VirtualBox添加/删除共享文件夹时,出现此错误:

When I am trying to add/remove shared folder to my VirtualBox I am getting this error:

~$ VBoxManage sharedfolder add dev --name srv --hostpath  "/my/local/path"

VBoxManage: error: The machine 'dev' is already locked for a session (or being unlocked)
VBoxManage: error: Details: code VBOX_E_INVALID_OBJECT_STATE (0x80bb0007), component MachineWrap, interface IMachine, callee nsISupports
VBoxManage: error: Context: "LockMachine(a->session, LockType_Write)" at line 1012 of file VBoxManageMisc.cpp

当我停止机器,操作共享然后重新启动机器时,它可以工作。它也可以在VirtualBox UI中运行,但我想编写这些操作的脚本。

It works when I stop the machine, manipulate shares and then start the machine again. It also works from the VirtualBox UI but I would like to script these operations.

在Mac OS Yosemite上运行VirtualBox 5.0.12。该框配备了 docker-machine

Running VirtualBox 5.0.12 on Mac OS Yosemite. The box was provisioned with docker-machine.

推荐答案

虚拟盒子论坛中的 socratis ,方法是使用-transient 标志:

As noted by 'socratis' at Virtual Box Forum, the way to do this is by using the --transient flag:

     ~$ VBoxManage sharedfolder add dev --name srv --hostpath  "/my/local/path" --transient

使用-transient 时,映射将不会在VM重新启动时持续存在。

When using --transient, the mapping will not persist over the VM restart.

VirtualBox文档也提到了这一点:


有两种类型的股票:

There are two types of shares:

VM共享,仅对已为其定义的VM可用;
瞬态VM共享,可以在运行时添加和删除,并且在VM停止后不会持久;为此,请在上述命令行中添加--transient选项。

VM shares which are only available to the VM for which they have been defined; transient VM shares, which can be added and removed at runtime and do not persist after a VM has stopped; for these, add the --transient option to the above command line.

这篇关于VirtualBox VBoxManage可以动态添加/删除共享文件夹吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆