Quantcast
Viewing latest article 3
Browse Latest Browse All 5

Answer by scott.squires for How can I mount a disk image?

The kpartx tool makes this easier. It creates loop devices in /dev/mapper for each partition in your image. Then you can mount the loop device that corresponds with your desired partition without having to calculate the offset manually.

For example, to mount the first partition of the disk image:

kpartx -a -v myimage.disk
mount /dev/mapper/loop0p1 /mnt/myimage

When you're done with the image, remove the loop devices:

umount /mnt/myimage
kpartx -d -v myimage.disk

Alternatively, if you have a recent kernel, and pass loop.max_part=63 on boot (if loop is built-in) or to modprobe (if loop is a module), then you can do it this way:

losetup /dev/loop0 myimage.disk
partprobe /dev/loop0             # Re-read partition table if /dev/loop0 was used with a different image before
mount /dev/loop0p1 /mnt/myimage

When you're done with the loop:

losetup -d /dev/loop0

Viewing latest article 3
Browse Latest Browse All 5

Trending Articles