Mounting RAW virtual machine images
So you got some virtual machines for the your development, tests. Need to extract some files, do a backup, without messing with the other messy OS?
For one thing there is some qemu fuse code patch (or so), floating around. However, the simple, robust and straight forward way is to simply loop-back mount the partition on a RAW file at the given offset. You can determine the offset with your favorite partition editor, or disktype. Once you know the sector offset you simply multiply it with 512 (usual sector size) as the offset like so:
mount -o loop,offset=$((123456* 512)) img.raw /mnt/tmp
Update: and for qcow et al images:
odprobe nbd
qemu-nbd -c /dev/nbd0 image.img
mount /dev/nbd0p2 /mnt
…
qemu-nbd –disconnect /dev/nbd0
June 19th, 2010 at 6:56
another possibilty is to use kpartx which uses device-mapper to create entries for each partition