mount VirtualBox vdi image

Aug. 13, 2019    Tags: admin  virtualbox

None

A lot of people saying that it is not possible to mount a vdi image and to access the data in there. But it is. Just use the right tools and know how to do it.

The following description was done on a linux host.

Requirements

We need the debian package which contains `qemu-ndb` (nbd == network block device).

Therefore install one of the following packages:

  • qemu-kvm (contains qemu-utils as a dependency)
  • qemu-utils (containing qemu-nbd)

This can be done with the following command:

apt-get install PACKAGE

Do the magic

  1. load the network block device module
    modprobe nbd
  2. run `qemu-nbd`, which is a user space loopback block device server for QEMU-supported disk images.
    That command will expose the entire image as a block device named /dev/nbd0, and the partitions within it as subdevices.
    qemu-nbd -c /dev/nbd0 VDI-FILE
  3. mount an individual partition
    mount /dev/nbd0p1 /mnt
  4. do your stuff
  5. umount the partition
    umount /mnt
  6. shutdown the qemu-ndb service
    qemu-nbd -d /dev/nbd0

And thats it. Pretty easy and streight forward.

 

[Photo by Markus Spiske on Unsplash]