gpt4 book ai didi

virtualbox - VirtualBox VBoxManage 可以即时添加/删除共享文件夹吗?

转载 作者:行者123 更新时间:2023-12-01 22:26:00 24 4
gpt4 key购买 nike

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

~$ 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,但我想编写这些操作的脚本。

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

最佳答案

正如“socratis”在 Virtual Box Forum 中指出的那样,方法是使用 --transient 标志:

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

当使用 --transient 时,映射不会在 VM 重启后持续存在。

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.

关于virtualbox - VirtualBox VBoxManage 可以即时添加/删除共享文件夹吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34489942/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com