Hi, people!
The title's pretty self explanatory, so I'll just dive right in...
Update: 31-Jul-12
qemu-nbd is somewhat broken in Ubuntu Precise at the moment. Here's a new method (note: You will need quite a large amount of free HDD space to do this, as we make 2 separate copies of the original VDI). I've also written a script, which should do the whole process for you (although you'll still need to install qemu-utils yourself).
sudo apt-get install qemu-utils
You need qemu-utils for the command qemu-img. This command is for *buntu. Use your distribution's package manager to install the package.
sudo apt-get install qemu-utils
This will show you a list of all your VM VDIs. Note down the UUID for the VDI you want to mount.
VBoxManage clonehd UUIDGOESHERE outputfilename.vmdk --format=VMDK
This command converts the VDI to a VMDK using VirtualBox's CLI.
qemu-img convert -f vmdk inputfilename.vmdk -O raw outputfilename.raw
Here, we convert the HDD into a format readable by a generic Linux distribution.
parted rawfilename.raw unit b print
Now, we list the partitions available in the raw disk image, to see their offsets. Note down the offset (remove the letter B from the end) of the partition you want to mount.
sudo losetup -f
This will tell you the next free loopback device. It will be in the format /dev/loop[n], where [n] is a number. On my machine, it's /dev/loop0, so I'll use that in the next example.
sudo losetup -o OFFSETGOESHERE /dev/loop0 rawfilename.raw
Connect a loopback device to the file at the offset we noted down before.
Now you can mount the loopback device (/dev/loop0 in my case) wherever you like.
Any questions, just ask!
n00b