Tuesday, December 29, 2009

Access shared-folder in Ubuntu host from Ubuntu guest in Virtualbox

This is the scenario that you run Ubuntu as your host operating system and Ubuntu guest in VirtualBox, and that you want to access a specific folder from Ubuntu host.

First you have to make sure that have install Guest Additions. From the VirtualBox's menu go to Devices → Install Guest Additions... This will mount a virtual CD on your /media/cdrom. Normally this folder's window will show up. As root run the program VBoxLinuxAdditions.run. When the program completes reboot your VirtualBox.

With Guest Additions installed you may now go ahead and define the shared folder(s). From the VirtualBox's menu go to Devices → Shared Folders. A dialog will show up. In this dialog you can specify which folder from your Ubuntu host system you want to share with your Ubuntu guest. Press the button with the + symbol to add a new shared folder in the list. You will have to specify a Folder Name for each folder you add. Make sure you memorize that name because you will need it very soon.

When done with you shared folder(s) specification, you may now go ahead and actually mount these folders from Ubuntu. First you have to create a mounpoint, that is, a directory in your Ubuntu guest which will reflect the shared folder from Ubuntu host:

# sudo mkdir /media/host-share

Of course you may choose an alternative path for your mountpoint. With your mountpoint created you can now mount the shared folder, like this:

# sudo mount -t vboxsf folder-name /media/host-share

Where folder-name will be the name you assigned for this folder when you were adding it in the shared folders list.


No comments: