Monday, January 11, 2010

Map partition from a disk for mounting

/* Say there is a disk image(disk_image.img) where individual partitions needs
to be mounted */

# file disk_image.img
disk_image.img : x86 boot sector; partition 4: ID=0x4, active, starthead 1, startsector 32, 8160 sectors, extended partition table (last)\011

/* simple matter of using kpartx utility */
# kpartx -av disk_image.img

/* the output will be ... */
loop1p1 : < string showing start - ends >
...

/* mount the required partition */
# mount /dev/mapper/loop1p1 /mnt/ -o loop

/* clean up */
# kpartx -d disk_image.img