Thursday 13 October 2011

how to dd a disk and mount it's partitions

Blatantly cribbed from differing areas of the internet and shamelessly reproduced in a single place :-)

using dmesg find out the identity of your block device, in my case sdc (a 2gb flash drive)
copy it using dd
1.) dd if=/dev/sdc of=/root/02streak.dd
mount it using linux's excellent loopback driver
2.) losetup /dev/loop0 /root/o2streak.dd
use fdisk to show you the block offset of the partitions
3.) fdisk -lu /dev/loop0

Device Boot Start End Blocks Id System
/dev/loop0p1 23 3964463 1982220+ 5 Extended
/dev/loop0p5 46 500663 250309 83 Linux
/dev/loop0p6 500687 3964463 1731888+ 83 Linux

so offset for partition 5 is (512x46) 23552
offset for partition 6 is (512x500687) 256351744

4.) Flashy use of the mount command using the offsets for it to mount the correct location
mount -o loop,ro,offset=23552 -t ext3 /root/o2streak.dd /media/tmp/
mount -o loop,ro,offset=256351744 -t ext3 /root/o2streak.dd /media/tmp/

Jobs a goodun