
上QQ阅读APP看书,第一时间看更新
Mounting loopback disk images with partitions more quickly
We can manually pass partition offsets to losetup to mount partitions inside a loopback disk image. However, there is a quicker way to mount all the partitions inside such an image using kpartx. This utility is usually not installed, so you will have to install it using your package manager:
# kpartx -v -a diskimage.img add map loop0p1 (252:0): 0 114688 linear /dev/loop0 8192 add map loop0p2 (252:1): 0 15628288 linear /dev/loop0 122880
This creates mappings from the partitions in the disk image to devices in /dev/mapper, which you can then mount. For example, to mount the first partition, use the following command:
# mount /dev/mapper/loop0p1 /mnt/disk1
When you're done with the devices (and unmounting any mounted partitions using umount), remove the mappings by running the following command:
# kpartx -d diskimage.img loop deleted : /dev/loop0