个人工具

UbuntuHelp:VirtualBox/SharedFolders

来自Ubuntu中文

跳转至: 导航, 搜索

Required: Virtualbox Guest Additions

Before trying to mount/map shared folder you must install Guest Additions (run machine and choose "Devices" -> "Install Guest Additions" from the menu.

Linux guest

If you are running a Linux guest, open a terminal and type:

cd /cdrom

in for instance Ubuntu Lucid, the cd image should mount at /media/<cd name> so that would be

cd /media/<cd name>

then, if you have 32 bit system:

sudo sh VBoxLinuxAdditions-x86.run

or

sudo sh VBoxLinuxAdditions-amd64.run

if you have a 64 bit system. Alternatively simply

./autorun.sh

that should handle the architecture - as well as the privileges - for you Make sure you have the image VBOXADDITIONS mounted as cdrom before installing it. Note: The client OS can not be open when adding share. You will have to reboot the guest machine.

Prepare host

On the host (ubuntu) computer, run

mkdir ~/VirtualBoxShare
VBoxManage sharedfolder add "XP" -name "share" -hostpath /home/your/shared/folder/VirtualBoxShare/

Where "XP" is the name of the virtual machine in VirtualBox, and "share" is the name of the share as the guest machine will see it. The hostpath must be a fully-qualified path.

Prepare guest

Windows

On the Windows client, run

net use x: \\vboxsvr\share

Linux

If the client is Linux, you have to mount and connect it to a folder. Run

mount -t vboxfs share mountpoint

For the above command if you get error as

mount: unknown filesystem type 'vboxfs'

Then just change the vboxfs to vboxsf means the command will be

mount -t vboxsf share mountpoint

See Section 4.4 Folder Sharing in the VirtualBox documentation. Note: above will mount folder as owned and writable only by root. If you want the user to be able to use it, mount with the following options

mount -t vboxsf -o uid=1000,gid=1000 share mountpoint

Troubleshooting

/sbin/mount.vboxsf: mounting failed with the error: Protocol error

The above error could be one of the following.

Reinstall Guest additions

Virtualbox Guest Additions have to be reinstalled after some updates. So install them as mentioned on the top of this wiki page.

Reboot

Did you reboot? You have to!

WRONG: same name for shared folder / mount point

Do NOT use the same name for the mount-point folder. The following example is WRONG:

$ cd Desktop
$ sudo mkdir shared
$ sudo mount -t vboxsf -o uid=1000,gid=1000 shared shared/
/sbin/mount.vboxsf: mounting failed with the error: Protocol error

The following example is CORRECT:

$ cd Desktop
$ sudo mkdir ubuntushared
$ sudo mount -t vboxsf -o uid=1000,gid=1000 shared ubuntushared/

As you can see, there is no error now. :-)