2015-12-28 86 views
1

當我試圖添加/刪除共享文件夾到我的VirtualBox的我收到此錯誤:VirtualBox VBoxManage可以即時添加/刪除共享文件夾嗎?

~$ 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用戶界面,但我想編寫這些操作腳本。

在Mac OS Yosemite上運行VirtualBox 5.0.12。該盒子配備了docker-machine

回答

3

截至Virtual Box Forum注意到「socratis」,要做到這一點的方法是使用--transient標誌:

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

當使用--transient,映射不會在虛擬機重新啓動持續。

VirtualBox documentation提到了這一點,以及:

There are two types of shares:

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.

+0

是的,但我想的共享文件夾是永久性的,而不是短暫的。您可以使用VirtualBox GUI(在虛擬機運行時添加永久共享文件夾)執行此操作,因此它也應該可以通過命令行完成。 – wisbucky

+0

要使它們永久保存,您需要停止該框,進行更改,然後啓動該框。我不知道其他方式。事實上,直接使用VirtualBox太麻煩了,我已經轉向了Vagrant –

相關問題