# losetup --find --show --partscan --read-only 2013-02-09-wheezy-raspbian.img
/dev/loop7
# dd if=/dev/loop7p2 of=/dev/narnia bs=1M
If --partscan
doesn't work, you can also use one of:
# partx -a /dev/loop7
# kpartx /dev/loop7
or similar partition mapping solutions.
You should probably mount it first just to see if it's the right thing or what.
Of course you can also read the fdisk output and give dd
the skip=131072
or whatever directly, i.e. make it skip that many blocks of input so it starts reading at where the partition is located; but it's nicer to see actual partitions with a loop device.
The MBR partition format is three decades old, and subject to weirdness for historical reasons.
Back then, the computer needed to know the geometry of the hard disk. How is data organized on a hard disk? In three dimensions: cylinder, heads and sectors.
(Diagram by LionKimbro)
The geometry was stored with maximum values that were large enough for the time: 8 bits for the number of heads (1–255), 6 bits for the number of sectors on a track (1–63), and 10 bits for the number of tracks per head, i.e. the number of cylinders (1–1023), with one sector containing 512 bytes. Nowadays computers don't need to know the actual geometry of the disk (and those numbers aren't even meaningful), but the format remains, and disks using MBR partitioning have a size that's expressed in CHS format, but all that matters is that the product of the three numbers is equal to the total number of sectors.
The starting address of the start of a partition is expressed in CHS format, and a lot of older operating systems didn't support partitions spanning different tracks, i.e. a partition had to be aligned on a cylinder boundary. That means a multiple of 63 sectors for the first partition.
There's a space of 31 kB that isn't used for partition content. It can be used for a bootloader.
The modern GPT partition format, which is the standard for newer PCs with >1 TB disks, likes to align partition on 1 MB boundaries, so there's about 1023 kB free before the start of the first partition. Again, this can be used by a bootloader. Modern operating systems align MBR partitions on 1MB boundaries too, dropping the CHS compatibility, and ensuring that partitions fall on a sector boundary on drives with 4 kB sectors (= 8 traditional sectors of 512 kB). Aligning partitions on a sector boundary (as in, the actual sector size used by the disk, i.e. its preferred transfer size) helps performance.
Best Answer
The old 32KiB gap between MBR and first sector of file system is called DOS compatibility region or MBR gap, because DOS required that the partitions started at cylinder boundaries (and each cylinder had 64 sectors i.e. 64 sectors * 512 bytes/sector= 32KiB space).
Legacy GRUB (GRUB1) could've used it to install GRUB1 1.5-stage bootloader there: http://www.gnu.org/software/grub/manual/grub.html#BIOS-installation.
Additional links: