Mounting a share on VirtualBox (Windows host, Mint guest)Posted: January 13, 2011
I’ve already mentioned a way to sync documents between computers, but what if you’re writing in a virtual machine, like I am? It doesn’t make sense to use Dropbox or some other file synchronization service between your VM and your computer “proper,” as you’d essentially be storing a redundant copy of your files. This is why VirtualBox gives you the option to share folders.
It’s pretty simple to do actually, but there is a subtle catch. Before you do anything, anything at all, make sure the user you’re logged in as is part of the group vboxsf. To do this, open the Users and Groups application under the Administration menu. Select your username (it’s usually selected by default) and click Manage Groups. Scroll down until you see vboxsf, then click Properties, and tick the box next to your username. (For the curious: if you don’t do this, you won’t have read/write access to the share you’ve mounted! Whoops!)
If you don’t see a group called vboxsf, don’t worry – you probably don’t have Guest Additions installed. (Though how you managed to live without them I’ll never know.) On the VM window itself, go to Devices -> Install Guest Additions and double-click the CD that pops up on your desktop. The script should run automatically; log out, then back in, and you’re set.
There are two kinds of shares – temporary and permanent. If you add a temporary share (that is, you don’t tick the “make permanent” box) you’ll have to mount it yourself by entering a couple commands into Terminal. First you have to make the empty directory you want to mount to (for example, let’s say I’m going to mount my Dropbox folder to my Desktop):
Now to perform the mount itself, let’s assume the share’s name is My_Dropbox:
sudo mount -t vboxsf My_Dropbox ~/Desktop/Dropbox
And that’s it. But if you want a permanent share, it’s even easier. When adding a permanent share, be sure to tick the “auto-mount” box – this means you won’t have to enter a mounting command every time you start up Linux again. Once you reboot, you’ll find the share mounted at /media/sf_sharename. Of course, that’s not terribly handy, so why not make a symlink to it (a shortcut)?
In this example I’m going to assume, again, that my share’s name is My_Dropbox, and I want to create a shortcut to it from the Desktop:
ln -s /media/sf_My_Dropbox ~/Desktop/Dropbox
The nice thing about permanent shares is that they’re, well, permanent, so you’ll never have to go through this procedure again unless you’re mounting another share.
And that’s it, now the writing on your hard drive is easily accessible from inside your virtual machine.