How to mount img file

From HyperSecurity Wiki
Jump to: navigation, search

An easy solution is using kpartx: it will figure out the partition layout and map each to a block devices. After that all you have to do is mount the one you want.

Open Terminal, locate the disk image, and enter this command:

kpartx -av disk_image.raw

add map loop0p1 (252:2): 0 3082240 linear /dev/loop0 2048

add map loop0p2 (252:3): 0 17887232 linear /dev/loop0 3084288

This created loop0p1 and loop0p2 under /dev/mapper. From the output you can see the sizes of the partitions which helps you identify them. You can mount the one you want with:

mount /dev/mapper/loop0p2 /mnt

When you are done, unmount what you mounted and remove the device mapping:

umount /mnt
kpartx -d disk_image.raw