本机:ubuntu 11.10
虚拟机: windows xp
首先在linux下创建共享的文件夹:
VBoxManage sharedfolder add "xp" -name "vshare" -hostpath "\home\hm\vshare"
报错如下:VBoxManage: error: The machine 'xp' is already locked for a session (or being unlocked)
VBoxManage: error: Details: code VBOX_E_INVALID_OBJECT_STATE (0x80bb0007), component Machine, interface IMachine, callee nsISupports
VBoxManage: error: Context: "LockMachine(a->session, LockType_Write)" at line 971 of file VBoxManageMisc.cpp
原因是vm没有关闭。
关闭后再运行命令,还报错:VBoxManage: error: Shared folder path '\home\hm\vshare' is not absolute
VBoxManage: error: Details: code NS_ERROR_INVALID_ARG (0x80070057), component SharedFolder, interface ISharedFolder, callee nsISupports
VBoxManage: error: Context: "CreateSharedFolder(Bstr(name).raw(), Bstr(hostpath).raw(), fWritable, fAutoMount)" at line 978 of file VBoxManageMisc.cpp
最后干脆直接通过VBOX的settings设置的共享目录,设置好后,重启vm;
在命令行中输入:
net use Z: \\vboxsvr\共享的文件夹名称
(注意“Z:”后面有个空格)
即可。