Sunday, March 1, 2015

How to setup VirtualBox Guest Additions Shared Folder on Ubuntu Server

Install Ubuntu Server in VirtualBox (with out any additional packages, may change depending on your need)

Create a Shared folder on your VM's settings.

Setup the build enviorment in the VM:
sudo apt-get build-essentials linux-headers-generic

Insert the CD image:
Devices->Insert Guest Additions CD image

It will be mounted at /dev/cdrom (most likely). If not identify the image using:
sudo blkid

Mount it to a directory in your system so that you can access the contents
sudo mount <source> <target>

Go to the mounted directory and Install the Guest Additions:
sudo sh ./VBoxLinuxAdditions.run

Reboot your system

Add an entry in rc.local for automatic mount:
sudo vi /etc/rc.local

And make the below entry

mount.vboxsf <share_name> <target_directory> vboxsf

Now you may create a shortcut to the target

ln -s <target_directory> /home/<username>/<sharename>

Reboot the system, you should be able to access your share using the target_directory or the symbolic link