Mounting a partition from a disk image

So you’ve dded a disk and you would like to mount its partitions from the resulting image file. Easy enough, first:

fdisk -l -u /path/to/disk.img

Which will yield a variation of the following output:

You must set cylinders.
You can do this from the extra functions menu.

Disk disk.img: 0 MB, 0 bytes
255 heads, 63 sectors/track, 0 cylinders, total 0 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000080

   Device Boot      Start         End      Blocks   Id  System
disk.img1              63    15631244     7815591   82  Linux swap / Solaris
disk.img2   *    15631245   113290379    48829567+  83  Linux
Partition 2 has different physical/logical endings:
     phys=(1023, 254, 63) logical=(7051, 254, 63)
disk.img3       113290380   210949514    48829567+  83  Linux
Partition 3 has different physical/logical beginnings (non-Linux?):
     phys=(1023, 254, 63) logical=(7052, 0, 1)
Partition 3 has different physical/logical endings:
     phys=(1023, 254, 63) logical=(13130, 254, 63)

Partitions available on the disk image are listed as disk.img1, disk.img2 & disk.img3. Great, pick which one you want to mount and look at where it starts.
disk.img2 starts at 15631245, multiply that by 512. 15631245 * 512 = 8003197440.
Finally, mount the disk image at the offset you calculated as such:

mount -o loop,offset=8003197440 -t auto /path/to/disk.img /mnt/disk_img_partition2

And done!

Leave a Reply

Your email address will not be published. Required fields are marked *