Mounting shared folders inside VirtualBox Ubuntu VM

Mounting shared folders from the host system (in this case Windows) is quite easy, by adding those mount lines to a config file the shares can be made ‘permanent’.

First step is to install Guest Additions. You can do this by clicking ‘Install Guest Additions’ under device in the menu of the VM. http://www.virtualbox.org/manual/ch04.html

Once the guest additions are installed you can mount shared folders. Now two pieces of info are required: name of the share and the location where the shared folder will be mounted. When selecting a folder to share in VirtualBox you need to provide a share name. For example: I named the ‘My Music’ folder from the Windows library Music. The mountline to write the music file on /home/$USER/music is:

mount -t vboxsf Music /home/erik/Music

Note that the mount location needs to exist before you start mounting. /home/$USER/Music is already in place after installation but if it’s a custom folder you might need to create it first. An example command to do that:

mkdir ~/vboxshare

if this required the creation of a new folder inside another new folder you can use the “-p” option.

mkdir -p ~/vboxmounts/somefolder

If you execute the mount command once, and it’s successful you can try to browse the folder in nautilus to see if everything works. Unfortunately the share folders will not be mounted when you restart your system.

To accomplish this the mount lines need to be added to the file /etc/rc.local This does require root privileges. So you can edit the file with sudo nano /etc/rc.local and enter your mount lines in the file before the ‘exit 0’ line and after the commented lines. That should be it.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s