Home > ubuntu > Create a shared folder in Virtualbox

Create a shared folder in Virtualbox

You have a guest operating system in Virtualbox and you want to exchange some data between the host and the guest. For this purpose you want to use a shared folder. The shared folder should be writeable in the guest too.

In my case I had two Ubuntu systems as host and guest.

There are several guides for setting up a shared folder (one, two). In short:

  • create a shared folder on the host (e.g. /opt/shared.folder.vbox)
  • create a shared folder on the guest (it can have the same path, e.g. /opt/shared.folder.vbox)
  • install guest additions under the guest (Devices -> Install Guest Additions…), then restart the guest
  • under the guest, go to Devices -> Shared Folders… Under Shared Folders, add the path of your shared folder (here /opt/shared.folder.vbox). You can tick Auto-mount and Make Permanent if you want. Note that in my case, although I selected these two options, the shared folder was not mounted automatically.

Make the shared folder writeable
On the guest, you can manually mount the shared folder with the following command:

sudo mount -t vboxsf shared.folder.vbox /opt/shared.folder.vbox

As I figured out, only root can mount a shared folder.

However, it mounts the folder in read-only mode! To make it writeable, I had to add the following line(s) to /etc/fstab under the guest:

# shared folder
shared.folder.vbox /opt/shared.folder.vbox vboxsf defaults,rw,auto,uid=1000,gid=1000 0 0

I use the system as a normal user called jabba, and 1000 is its user id and group id. It can be found in /etc/passwd (columns 3 and 4):

$ cat /etc/passwd | grep jabba
jabba:x:1000:1000:Jabba Laci,,,:/home/jabba:/bin/bash

After a reboot, this folder is still not auto-mounted :( You can mount it with:

sudo mount /opt/shared.folder.vbox

But now it should be writeable…

Auto-mount shared folder at each boot
Now let’s put the dot on the “i” :) If you want your shared folder auto-mounted at each boot, add this line to /etc/rc.local on the guest:

mount /opt/shared.folder.vbox

Make sure that it comes before the line “exit 0“.

Troubleshooting (20160614)
On Ubuntu 16.04 I got this error: “/sbin/mount.vboxsf: mounting failed with the error: No such device”, though I had the Guest Additions installed. I found the solution here. Create the file /etc/modules-load.d/virtualbox.conf and add these lines in it:


Maybe vboxsf would be enough alone. These modules will be loaded with each boot.

  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

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

Google+ photo

You are commenting using your Google+ 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 )


Connecting to %s

%d bloggers like this: