Mount partitions from a VirtualBox VDI in Linux.

7 07 2011

Hi, people!

The title’s pretty self explanatory, so I’ll just dive right in…

I needed to access data on a VM which had no network connectivity, and therefore needed a way to mount partitions from the host (Ubuntu 11.04 in this case).

After a little research, I found this article. It explains in simple steps how to go about this. Here’s my much shortened (but far less complete) version:

First, you need to have the package qemu-kvm installed. This can be done in Ubuntu by running the following command:
sudo apt-get install qemu-kvm

Next, load the nbd kernel module.
sudo modprobe nbd

Now you’re ready to make the partitions available to the host OS by running:
sudo qemu-nbd -c /dev/nbd0 {VDI FILE}

This will allow you to access the partitions as /dev/nbdp{number}. For example, to mount the first partition of the VDI in /mnt, you would run the following command:
sudo mount /dev/nbd0p1 /mnt.

For a whole bunch more information on this, click the link to the original article I mentioned before.

Any questions, just ask!



Resizing a VirtualBox HDD

28 04 2009

Today I came up with a problem involving a VirtualBox VM which had run out of space. “Damn” I thought, as I read so many postings by so many nay-sayers telling me that it “Just Can’t Be Done”.

C’mon guys… There’s almost no such thing as can’t with the plethora of useful gadgetry that the world of FOSS has brought us.

A slightly more extensive search turned up this site. Exactly what I was looking for.

What I’m interested in finding out is if this will work on a real HDD… This could fix all of my pain-in-my-ass HDD upgrade problems if I can just clone a disk into a larger partition! Infinitely expandable storage!

I’ll post here when I get a chance to try it.


UPDATE 08/05/09

Nick Heppleston, the author of the original article, has confirmed that using this method to clone data from a smaller partition to a larger partition on either the same disk or a separate disk works! This is going to make my Windows administration a lot easier, that’s for certain.

Thanks Nick!