As raw disk access as we previously discussed provides too much risk to our precious media, and NFS seems to cause our performance to take a hit, the solution is to use VirtualBox's "shared folder" functionality. when you use this with a Windows Guest, it shows up as a Samba Share. When you use it with linux, it does something more interesting. the shared folder becomes a new type of mount for the operating system, similar to NFS. the difference is that it doesn't route through the network, but instead talks directly to the host OS using special drivers provided by
VirtualBox Guest Additions. Set-up is actually quite simple:
Alright, for the sake of this guide, I'll be assuming a few things:
a. You have installed VirtualBox on your host (My host is Ubuntu Server 10.10)
b. You have set up your guest VM the way you like, again with Ubuntu Server 10.10 as the OS.
To add the shared folder to the VM, you can pass it along with the VBoxManage command. In PuTTY for you Windows users, or through ssh for the linux users among us run this command as the user that controls your VMs on your
Host Machine:
Code: Select all
VBoxManage sharedfolder add NameofVM --name whateveryouwanttonameit --hostpath /path/to/folder/to/share
my media resides in "/media/UserData" and my VM is called "MediaServer" so for me the command looked like this:
Code: Select all
VBoxManage sharedfolder add MediaServer --name UserData --hostpath /media/UserData
note that the "--name" can be whatever you like, it doesnt need to correspond to the name of the folder. I just thought it made sense to do it that way.
Now, we need to make it so the Guest can mount it. As I said, this is done through VirtualBox Guest Additions. installing them is pretty easy in ubuntu, as they are pre-packaged and in the repositories for our use, so we can install them with apt-get.
this time we need to pass commands to the guest, so get to a terminal however you access your
Guest OS (PuTTY, ssh, or rdesktop) and pass along this command:
Code: Select all
sudo apt-get install virtualbox-ose-guest-x11
after this, you need to restart the guest OS, so the changes can take affect:
next we need to create the mount point, like any other mount:
I chose to mount it in the same place it was on the host to make things easy on myself, so I ran:
now we can mount the shared folder with this command:
Code: Select all
sudo mount -t vboxsf nameyougavefolderearlier /path/to/mount/to
so in my example, the command is:
Code: Select all
sudo mount -t vboxsf UserData /media/UserData
this will mount it as owned by root:root. this isn't terribly important as the folder will naturally have rwxrwxrwx permissions, but if you want to own it as a different user you can:
Code: Select all
sudo mount -t vboxsf -o uid=1000,gid=1000 UserData /media/UserData
and to mount it automatically at boot you just add this to /etc/fstab:
Code: Select all
#VirtualBox Shared Folder
UserData /media/UserData vboxsf defaults 0 0
or
Code: Select all
#VirtualBox Shared Folder
UserData /media/UserData vboxsf uid=1000,gid=1000 0 0
That's it! you should be all set up.