To mount a specific partition inside a disk image, use the fdisk utility to see where the partition boundaries are.

# fdisk -l out.bin
Disk out.bin: 58.6 MiB, 61440000 bytes, 120000 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
Disklabel type: dos
Disk identifier: 0x000981cb

Device     Boot  Start     End Sectors  Size Id Type
out.bin1          8192  122879  114688   56M  c W95 FAT32 (LBA)
out.bin2        122880 5785599 5662720  2.7G 83 Linux

The first partition starts on sector 8192. Since each sector is 512 bytes, we can mount this particular partition by passing an offset of 8192 * 512 bytes.

# mount -o loop,offset=$((8192 * 512)) out.bin /mnt/card

Alternatively, you may want to set up a loopback device specifically for a partition using losetup:

# losetup /dev/loop0 disk.img -o $((10860003 * 512))
# file -s /dev/loop0
/dev/loop0: Linux rev 1.0 ext3 filesystem data
# mount /dev/loop0 /mnt
[...]
# umount /mnt
# losetup -d /dev/loop0


See Also[edit]

  1. http://madduck.net/blog/2006.10.20:loop-mounting-partitions-from-a-disk-image/