VirtualBox Sharing

In my spare (and not so spare) time lately I’ve been playing around with Sun‘s VirtualBox. I’ve been using it for a long time now, but only recently did I decide I wanted to turn on “shared folders”. The thing is, there is no intuitive way of doing so.

More for myself, than anyone else, this is how I managed to share a folder in my Windows host “x:\shared\” and access it from within my virtual (guest) Ubuntu.

Though it is a bit dated, these instructions pretty much sum it up.

From within the VirtualBox launcher, select the Virtual OS that you want to share with. Click the settings button and select “Shared Folders” from the list. Click the little ‘+’ folder on the right side of the “Shared Folders” screen and create a directory that you want to share. Odds are you’ve already done that, which is why you’re here looking for the next step.

Start the Ubuntu VirtualBox and log in.
Open a terminal and type
sudo apt-get install build-essential module-assistant
followed by
sudo m-a prepare

I don’t understand why, but that’s what the instructions say. Now this is where I ran in to trouble (and maybe you did, too). A Google search will result with instructions telling you to “install Guest Additions” but they don’t tell you how. Here’s how.

You already have the virtual Ubuntu running so press the escape key (right-control by default) and you’ll notice along the top of that window is a “Devices” button.

Press the "Devices" button.

At the bottom of the menu that opens is where you’ll find “Install Guest Additions”.

Press "Install Guest Additions..."

For me, nothing seemed to happen. It appears that in the background VirtualBox downloaded a 10MB .iso to the VirtualBox directory.

Press "Mount CD/DVD-ROM" > "CD/DVD-ROM Image..."
Double-Click "VBoxGuestAdditions.iso"
sudo sh /media/cdrom0/

Though if that last command doesn’t work then you may have to mount it

sudo mount /dev/cdrom

or do what I did and navigate to the /media/cdrom0/ directory within a filebrowser (I used rox) to have it automatically mount the drive. Then try the command again.

Finally, mount the shared folder to a directory in the virtual OS

sudo mkdir /mnt/host
sudo mount -t vboxsf shared /mnt/host

Notice that you omit “x:\shared\” and reference the shared drive simply as “shared”. Now you can read (and write) files to the host folder through /mnt/host

Leave a Reply


Staypressed theme by Themocracy