在VirtualBox的主机(即SUSE11.1)的终端中执行下列命令:
VBoxManage sharedfolder add "VM name" -name "sharename" -hostpath "/test"
上述命令中的 VM name 是指VBOX所建立的虚拟机名称,如我的是 winxp;sharename 为共享的文件夹名称,可任意设置,如kpjack;/test 为主机(即SUSE11.1)上将要共享给虚拟XP的文件夹,我把/home/kpjack设为与虚拟XP的共享。
因此就要输入以下这条命令:
#VBoxManage sharedfolder add "winxp" -name "kpjack" -hostpath "/home/kpjack"
在VBOX中启动虚拟机(本例为winxp)登录XP后,点击“开始”菜单中的“运行”,并输入 cmd,然后执行以下指令:
net use x: \\vboxsvr\sharename
命令中的 x: 为映射的驱动器符号;sharename 为上一步所设置的共享文件夹名称kpjack。
因此就要输入以下这条命令:
#net use e: \\vboxsvr\kpjack
在命令成功执行后,通过XP的“我的电脑”你便可以看到和使用共享文件夹了。
以下是命令输入后回显:
linux-bknz:/home/hujintao # VBoxManage sharedfolder add "winxp" -name "kpjack" -hostpath "\home\kpjack"
VirtualBox Command Line Management Interface Version 2.1.0
(C) 2005-2008 Sun Microsystems, Inc.
All rights reserved.
[!] FAILED calling aVirtualBox->FindMachine(Bstr(argv[1]), machine.asOutParam()) at line 4291!
[!] Primary RC = VBOX_E_FILE_ERROR (0x80BB0004) - File not accessible or erroneous file contents
[!] Full error info present: true , basic error info present: true
[!] Result Code = VBOX_E_FILE_ERROR (0x80BB0004) - File not accessible or erroneous file contents
[!] Text = Could not find a registered machine named 'winxp'
[!] Component = VirtualBox, Interface: IVirtualBox, {339abca2-f47a-4302-87f5-7bc324e6bbde}
[!] Callee = IVirtualBox, {339abca2-f47a-4302-87f5-7bc324e6bbde}
linux-bknz:/home/hujintao #