How to mount a .vmdk image in Linux with QEMU

This section has been copied from Jason Murray’s blog post. Full credits go to him, and I highly suggest reading up his blog!!!

Mounting #

Install qemu utils: #

sudo apt install qemu-utils

Enable network block device module #

sudo modprobe nbd

Create the network block device #

sudo qemu-nbd -r -c /dev/nbd1 /path/to/your/image.vmdk

List the images created & create mount points accordingly #

ls -la /dev/nbd1p* | sed 's/^.*nbd1p/\/mnt\/VM/g' | sudo xargs mkdir

This will create mountpoints /mnt/VM[i] for each partitions/images created by nbd.

Mount the images to the mountpoint #

ls -la /dev/nbd1p* | sed 's/^.*nbd1p/\/mnt\/VM/g' > mounts
for file in /dev/nbd1p*; do read line;  sudo mount "${file}" "${line}";  done < mounts

Find the partition of interest #

ls -la /mnt/VM*/

Unmounting #

Unmount the Virtual Machine #

sudo umount /mnt/VM*

Detach the Network Block Device #

sudo qemu-nbd -d /dev/nbd1
Updated on 17th May 2023
Table of Contents