Disk Partition Table (2.X)

The partition table information is usually written in the first sector (512 bytes) of the device, which is therefore called master boot sector (MBS). The MS-DOS master boot sector begins with a JUMP instruction (three bytes). The disk parameters follow (offset 0x003), and then there is the DOS kernel loader (at offset 0x03E). The master boot sector is terminated by the magic number, 0xAA55, for the bios in the final two bytes (offset 0x1FE).
A hard disk is more complicated than a floppy, because it has partitions. However the BIOS boots from a hard disk as if it were a floppy. Therefore the first sector (master boot record) must have the structure of a MBS, ie, the first instruction that is executed is at offset 0x000, and there must be the magic number 0xAA55 at offset 0x1FE. The master boot record contains the information about the dist partition. More precisely each partition is described by 16 bytes, The first partition descriptor is at offset 0x1BE. The second at 0x1CE, the third at 0x1DE, and the fourth at 0x1EE.
C/H/S geometry Hard disks used to have a geometry, described by "cylinders", read/write "heads" and "sectors" (see figure). Now the disk geometry is more a logical concept than a physical one. Nevertheless it is still used. The units of disk are the sectors. Each cylinder contains "head" * "sect" sectors. The C/H/S triples are stored in three bytes in the format 10+8+6. This is ok if there are at most 1024 cylinders, which nowadays is mostly not the case. Therefore the triples are not used by Linux.
[more about extended partitions]

Exercise
Write a C program that reads the partition table from your hard disk(s), and check the result with fdisk -lu.


Here is an example dpt.c

Marco Corvi - 2003