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!

n00b

Advertisements