Mount a Partition from inside a Disk Image

You need sfdisk and losetup.

sfdisk -l -uS disk_image.raw
# look for the start sector of the partition, e.g. 2

mount -o loop,offset=$((2 * 512)) disk_image.raw /mnt
#mount the partition to /mnt (replace 2 with the output from sfdisk)

You could of course also use kpartx to create special device files for the partitions.


  1. This comment has been removed by a blog administrator.

  2. I had a hard time figuring this out but thanks to you I managed to pull it off, thanks, now I can migrate my VMs to LVM


I appreciate comments. And I do read them.