VirtualBox – Access Windows-host shared folder from Ubuntu-guest

Step 1)

Installing VirtualBox Guest Additions is necessary to enable folder sharing between host and guest operating systems on VirtualBox.

  1. Start the Ubuntu Server VM and insert the Guest Additions CD image (Devices menu, Install Guest Additions).

  2. Mount the CD Rom with the shell command:

    $ sudo mount /dev/cdrom /media/cdrom

    After that the install scripts should be accessible in the /media/cdrom/ directory:

    $ ls -l /media/cdrom/
    total 41942
    dr-xr-xr-x 3 root root     2048 Dec 19 13:11 32Bit
    dr-xr-xr-x 2 root root     2048 Dec 19 13:11 64Bit
    -r-xr-xr-x 1 root root      647 Aug 16  2011 AUTORUN.INF
    -r-xr-xr-x 1 root root     6966 Dec 19 13:02
    -r-xr-xr-x 1 root root     5523 Dec 19 13:02
    -r-xr-xr-x 1 root root  7361995 Dec 19 13:06
    -r-xr-xr-x 1 root root 14634496 Dec 19 13:08 VBoxSolarisAdditions.pkg
    -r-xr-xr-x 1 root root 13270208 Dec 19 12:55 VBoxWindowsAdditions-amd64.exe
    -r-xr-xr-x 2 root root   278832 Dec 19 12:48 VBoxWindowsAdditions.exe
    -r-xr-xr-x 1 root root  7383936 Dec 19 12:49 VBoxWindowsAdditions-x86.exe
  3. Install necessary build tools and build dependencies:

    $ sudo apt-get install -y dkms build-essential linux-headers-generic linux-headers-$(uname -r)


    Getting the headers solves a potential build error that is reported in /var/log/vboxadd-install.log

    Failed to install using DKMS, attempting to install without
    /tmp/vbox.0/Makefile.include.header:94: *** Error: unable to find the sources of your current Linux kernel. Specify KERN_DIR=<directory> and run Make again.  Stop.
  4. Build and install the Guest Additions:

    $ sudo /media/cdrom/


Step 2)

With Guest Additions installed you may now go ahead and define the shared folder(s). From the VirtualBox’s menu go to
Devices → Shared Folders → Press the button with the + symbol to add a new shared folder in the list.
You will have to specify a Folder Name for each folder you add. Make sure you memorize that name because you will need it very soon.

# sudo mkdir /media/windows-share

# sudo mount -t vboxsf folder-name /media/windows-share

Where folder-name will be the name you assigned for this folder when you were adding it in the shared folders list.

You could use the /etc/init.d/rc.local script to execute these commands on startup to have the shared folders automatically mounted every time you start your Ubuntu VirtualBox.