Dark-Fx.com
Disk Images: Mounting partitions from dd hard disk images in Linux2008-04-09 22:55:42 posted by Dark-Fx
Okay, So you did a dd copy of an old disk you were using and just now need to grab something off of one of the partitions. You have a few choices of how to do this. You can use dd to copy just the specific partition out, or you can mount that partition as a loopback device with losetup. The latter is much more efficient.
First step, locate the image. Then run fdisk -lu on it:
$ fdisk -ul diskimage
You must set cylinders.
You can do this from the extra functions menu.
Disk diskimage: 0 MB, 0 bytes
15 heads, 17 sectors/track, 0 cylinders, total 0 sectors
Units = sectors of 1 * 512 = 512 bytes
Disk identifier: 0x00000000
Device Boot Start End Blocks Id System
diskimage1 * 17 254999 127491+ 6 FAT16
This spits out all the information we need to actually mount the loopback device to get this to work. Take the Starting sector number and multiply it by 512. In my case here, it's 17 * 512 = 8704. This number is needed for losetup to specify where the starting offset is.
Now run losetup:
$ losetup -o 8704 /dev/loop0 diskimage $ losetup -a /dev/loop/0: [0901]:16793696 (diskimage) offset=8704This shows that the loopback device is up and at the proper offset. Now just mount loop0 as if it were something like /dev/hda1. We want to mount it Read Only so we don't modify any of the image on accident.
$ mount /dev/loop0 /mnt -oro $ mount | grep loop0 /dev/loop0 on /mnt type vfat (rw)That's about it. To get rid of the loop device, umount the partition and run:
losetup -d /dev/loop0