Mount a RAW Qemu Image File to your Linux system

You may need to mount a qemu RAW image to your linux system for various reasons. To do so, please follow the next steps:


Mounting a raw image file with one partition is pretty straight forward. Assuminug the RAW image file name is VirtualMachineImage.raw  and the directory to mount the disk is /mnt


losetup /dev/loop0 VirtualMachineImage.raw  
kpartx -a /dev/loop0  
mount /dev/mapper/loop0p1 /mnt


Now you can go to the directory /mnt and you’ll find all files inside the RAW image.




To mount a qcow2 file, assuming the qcow2 file name is VirtualMachineImage.qcow2 proceed as follows:

modprobe nbd max_part=63
qemu-nbd -c /dev/nbd0 VirtualMachineImage.qcow2
mount /dev/nbd0p1 /mnt