mount VirtualBox vdi image
Aug. 13, 2019 Tags: virtualbox admin

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
- load the network block device module
modprobe nbd
- 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
- mount an individual partition
mount /dev/nbd0p1 /mnt
- do your stuff
- umount the partition
umount /mnt
- shutdown the qemu-ndb service
qemu-nbd -d /dev/nbd0
And thats it. Pretty easy and streight forward.