Shared folder is a great feature of Virtualbox to share data between the host and guest OS. This post shows how to mount the shared folder during boot on a Ubuntu 16.04 guest OS running on Windows 10 host OS.

Setup the Shared Folder

Suppose you want to share D:\vbox_share on the host OS to the guest OS. First, open up the virtual machine configuration window in Virtualbox, in Shared Folders tab, click the add button, shown as follows.

Virtual Shared Folders Configuration

In the pop up windows, enter D:\vbox_share in the Folder Path box -- this is the path to the folder on the host OS. In Folder Name box, give an alias to that folder which we will use later in guest OS. Here I use vbox_share as an example.

Optionally, check the Auto-mount and Make Permarnent box as you wish.

Then, boot into your Ubuntu virtual machine, open a terminal, and use this command to mount the shared folder. Here I assume the mount point is /mnt/vbox_share.

$ sudo mount -t vboxsf vbox_share /mnt/vboxshare

Mount on Boot

To mount the shared folder during boot, we need to do two things.

First, add this entry to /etc/fstab

vbox_share    /mnt/vbox_share  vboxsf  defaults    0   0

Second, add this entry to /etc/modules.

vboxsf

This is because the vboxsf module will not be loaded by Linux by default during boot. Therefore the mounting will fail. Then entry in /etc/modules tells Linux to load the module first before trying to mount the shared folder.

Thanks to this post: http://askubuntu.com/questions/365346/virtualbox-shared-folder-mount-from-fstab-fails-works-once-bootup-is-complete