Install virtualbox guest additions and mount a shared folder on an ubuntu virtual machine

First install vbox guest additions.

Select “install guest additions” from the vbox menu and perform the following commands:

sudo apt-get update
sudo apt-get install dkms build-essential linux-headers-generic
sudo mount /dev/sr0 /media/cdrom
sudo sh /media/cdrom/

next add a shared folder using the settings menu from vbox. Make sure to select the options “connect automatically” and “make permanent”.

To mount this share on linux, run the following command:

mkdir /shared
sudo mount -t vboxsf sharedfolder /shared

After a reboot, the volume will be dismounted again.
To automatically mount the volume at boot time, add the mount command in /etc/rc.local using the following command.

sudo sed -i -e ‘$i mount -t vboxsf sharedfolder /shared &n’ /etc/rc.local