Wednesday, May 7, 2014

Virtual Box: Sharing folders with Windows 8.1 host and Ubuntu guest

I like to do my development on Linux platform, though I love to have my Windows do all the front-end.
For this I run multiple Virtual Boxes with Ubuntu terminal on it. One of the main problems, I faced was sharing of code between the different Virtual Boxes.

To do this, I have shared my Windows user/<user-name>/documents/ directory.

Doing this was not trivial and I have spent many hours trying to fix this.

Step 1:
Share the folder on VBox Settings

Step 2:
You need to install VBox-guest-additions.
This is the place I had the maximum problem.

This should be straight forward but it was not for some reason.
Step 2-a:  This command should have worked

However no matter what I did, it was not able to detect the CD.

So I looked at alternative steps.
Step 2-b:
sudo apt-get install virtualbox-guest-additions-iso

To check this, we should find that the files are in /opt/VBoxGuestAdditions-4.3.10.
But these files were not there even though the package was showing installed. Tried multiple times to re-install this but no luck.

Step 2-c:
However what this did was that the virtualbox itself got installed on my instance.
With this, I could now find the guestAddition CD on instance itself. So I mounted this
mount -o loop /usr/share/virtualbox/VBoxGuestAdditions.iso  /mnt/vbox/

With this, I could now go to
and thankfully this worked.

Step 3
Mount the disk
sudo mkdir /mnt/$sharename
sudo chmod 777 /mnt/$sharename
sudo mount -t vboxsf -o uid=1000,gid=1000 $sharename /mnt/$sharename
ln -s /mnt/$sharename $HOME/Desktop/$sharename

However I still found a problem and this was
mount: wrong fs type, bad option, bad superblock on hostshare, missing codepage or helper program, or other error (for several filesystems (e.g. nfs, cifs) you might need a /sbin/mount.<type> helper program) In some cases useful info is found in syslog - try dmesg | tail  or so

The problem was that the mount.vboxsf was not linked properly.
ln -s /opt/VBoxGuestAdditions-4.3.10/lib/VBoxGuestAdditions/mount.vboxsf /usr/sbin/mount.vboxsf
ln -s /opt/VBoxGuestAdditions-4.3.10/lib/VBoxGuestAdditions/mount.vboxsf /usr/sbin/mount.vboxsf

Finally the mount worked.

Step 4: Automount.
In final step, go to
vi /etc/rc.local
sudo mount -t vboxsf -o uid=1000,gid=1000 documents /mnt/<sharename>

Some useful links