Running Debian 9 in VirtualBox is easy but figuring out how to get Shared Folders working properly can be a hassle. Here’s how to do it.

– You have a VirtualBox VM set up with Debian 9.3 and nothing more.
– The user who’s running the X sessions is called Vorkbaard.
– The Windows folder you’re sharing is called D:\vbox.
– The Linux mount point is /home/vorkbaard/host.
– The session user has sudo rights.

Click any image to open a larger version.

First order of business is installing the Guest Additions (source):

# apt-get install build-essential module-assistant
# m-a prepare

In the gui click Devices, select Insert Guest Additions CD Image.

As the session user:

$ sudo sh /media/cdrom0/

Restart the VM and resize its window to verify the Guest Additions were installed correctly. The Desktop Environment should be scaled along with the VM window. If it doesn’t, kick it until it does.

From the Devices menu select Shared Folders > Shared Folders Settings.

Select Machine Folders and click the + icon. Select your host’s folder path and enter a folder name to be used in the guest. Make things easy and don’t use spaces or weird characters.

Also note that you should not use the same name for your host folder and mountpoint.

Transient folders will exist only for the duration of this VM session. Machines folders will remain.

While you’re at it, enable bidirectional sharing of the clipboard and Drag and Drop. This had nothing to do with folder sharing, it is a matter of preference.

Reboot your VM or reset your X session for the new settings to take, then test if you can mount your share. First make a directory host to function as your mountpoint:

$ mkdir host

Mount the share:

$ sudo mount -t vboxsf vbox /home/vorkbaard/host

Test if you can read and write in the folder. If you can’t write here the problem is most likely that you chose a host folder in the wrong location (C:\ or %userprofile%). Try a location at C:\Somefolder\ or D:\vbox.

You should not need options like rw,uid=1000,gid=1000, and so on in your mount command.

Now this is all good and well but we want to mount the share automatically upon boot so we should enter the mount in /etc/fstab.

Unmount the share with

$ sudo umount host

Note that umount is not spelled uNmount.

Add your user to the vboxsf group, otherwise you will not be able to actually use the share:

$ sudo usermod -a -G vboxsf vorkbaard 

Open /etc/fstab and add:

vbox    /home/vorkbaard/host    vboxsf	comment=systemd.automount     0       0

Again, you should not need gid and uid definitions here.

Mount all shares defined in fstab:

$ sudo mount -a

Test to see if it works:

$ touch host/test

If it doesn’t work, scream at it until it does. Note that Gedit will not write to files at the share, apparently this is a problem between Gedit and VirtualBox. Other editors have no problem with it.

Reboot, verify that it is still working and rejoice \o/