Search This Blog

Thursday, December 10, 2009

How do I access a shared folder in Virtual Box under an Ubuntu guest?

I use Virtual Box everyday and love it. One of its nice features is the ability to expose the host's file system to the guest OS. When running an Ubuntu Linux guest, however, you need to make a few hand tweaks to get the shared folder to automatically mount.

First, we need to test that we can mount the folder by hand. Examine the shared folder settings of your VM to find the name of the share. Mine has the very original name of share. Create a directory that will be used as the mount point for the shared folder. I created ~/vbox. Finally, mount the shared folder to the Ubuntu file system using the following command:

sudo mount -t vboxsf share ~/vbox

Do an ls of ~/vbox to verify that your shared files exist. If you do an ls of the mount directory, you'll notice that it is owned by root which could be a problem if you try to write to that folder. We need to fix that. Unmount the share using sudo umount ~/vbox/ so we can make some adjustments. Remount the shared folder using a slightly different set of options: sudo mount -t vboxsf -o uid=1000,gid=1000 shared ~/vbox. In this variant, I specified my account's user and group ids. Now the directory is mounted with the proper permissions.

I want this done automatically each time I boot up, so I placed the following in my /etc/rc.local file:

mount -t vboxsf -o uid=1000,gid=1000 RKurr /home/rkurr/vbox/

I have to use the fully qualified path to the mount point because the root user will be running the command and ~ will not expand correctly.

No comments:

Post a Comment