Mounting a raw partition image made from dd
Inspect Image
sudo file sdcrd.img
sdcard.img: DOS/MBR boot sector; partition 1 : ID=0xc, start-CHS (0x40,0,1), end-CHS (0x3ff,3,32), startsector 8192, 524288 sectors; partition 2 : ID=0x83, start-CHS (0x3ff,3,32), end-CHS (0x3ff,63,32), startsector 532480, 30583808 sectors
sudo fdisk -l sdcard.img
Disk sdcard.img: 14.86 GiB, 15931539456 bytes, 31116288 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: 0x999999999 Device Boot Start End Sectors Size Id Type sdcard.img1 8192 532479 524288 256M c W95 FAT32 (LBA) sdcard.img2 532480 31116287 30583808 14.6G 83 Linux
Mounting 1st Partition
Pay attention to the Start field.
Here we are wanting to mount the 1st Partition.
It starts at 8192.
So 8192 * 512 = 4194304
Mount Partition 1
sudo mount -o ro,loop,offset=4194304 sdcard.img /mnt/sdcardp1
Mounting 2nd Partition
Pay attention to the Start field.
Here we are wanting to mount the 2nd Partition.
It starts at 532480.
So 532480 * 512 = 272629760
Mount Partition 2
mount -o ro,loop,offset=272629760 sdcard.img /mnt/sdcardp2
Troubleshooting
While writing this was unable to mount the 2nd partition
mount: /mnt/sdcard: can’t read superblock on /dev/loop14.
It was be due the the disk not being dismounted properly before imaging.
To fix it
sudo losetup --offset 272629760 /dev/loop14 harddrive.img
sudo fsck /dev/loop14
sudo mount /dev/loop14 /mnt/loop14