Sometimes you may need to mount a VHD disk image file in order to inspect its contents or even recover specific files. On Linux you can use the QEMU Disk Network Block Device Server utility – qemu-nbd
– to access disk images in different formats as if they were block devices.
First, you may want to check if the nbd module is loaded:
modprobe nbd
If not present you will see an error informing the module was not found. You may also want to check if the QEMU command line tools are installed, or install with
dnf install -y qemu-img
To mount a VHD file run:
qemu-nbd --connect=/dev/nbd0 <vhd_file>
mount /dev/nbd0p1 /mnt/
Code language: HTML, XML (xml)
After you’re done, you can unmount and disconnect the nbd device with:
mount /mnt
qemu-nbd --disconnect /dev/nbd0