Mount a VirtualBox shared folder inside a guest VM

0

VirtualBox makes it easy to share folders between the host OS and various guest virtual machines, but it can be difficult to remember the exact way to go about mounting the shared folder within a guest VM. Here is the way to do it correctly.

First off make sure you have installed VirtualBox guest additions.

Switch to root or use sudo.
$ su -

Create the directory and mount the shared folder to the mount point of your choice. Use the shared name you assigned to it when you originally created the shared folder, in this case it is “virtualbox_share”.
# mkdir /media/share
# mount virtualbox_share -t vboxsf /media/share

You can have this automatically mounted by adding the following line in /etc/fstab
virtualbox_share /media/share vboxsf defaults 0 0

Unfortunately the share will be owned by root. To make it owned and therefore writeable by a user use the following line instead. Replace the uid and gid with your information.
virtualbox_share /media/share vboxsf defaults,uid=500,gid=500 0 0

Here’s how to find your uid:
id -u username

And gid:
id -g username

Share.