DOS-type partition tables describe partitions in units of one sector. Thus, in order to interpret a DOS-type partition table, one needs to know the hardware sector size. [Usually a sector has a length of 512 bytes, and many programs blindly assume this sector size.]
A partition descriptor is a 16-byte structure with the following fields:
[This byte is used by some boot loaders to indicate which of the primary partitions should be booted.]
[Cylinder/Head/Sector address of the partition start. For the format, see below.]
[This type generally indicates what operating system or file system can be found on the partition, or what the partition is used for. For a list, see the list of known partition types.] Here we shall always give types in two hexadecimal digits. Types 05, 0F and 85 (hex) indicate an extended partition. [DOS only knows about 05, Windows 95 introduced 0F, Linux introduced 85.]
[Cylinder/Head/Sector address of the partition end.]
The 4-byte little-endian value of the starting sector number (counting from 0) of the partition.
The 4-byte little-endian value of the size in sectors of the partition. If this value is zero, the partition descriptor should be ignored [and all other values in the descriptor should be zero as well]; in this case the partition descriptor is called unused.
h = byte1;
s = byte2 & 0x3f;
c = ((byte2 & 0xc0) << 2) + byte3;
For a disk with C cylinders, H heads, and S sectors per track,
the linear address corresponding to a CHS address (c,h,s) is found as
c*H*S + h*S + s - 1.
[Since CHS addresses have 24 bits only, they cannot address more
than 2^24 sectors, which is insufficient for modern disks.
Moreover, it is often unclear what values should be used for C, H, S.
Thus, these CHS addresses should be ignored.]
A partition table sector is a on-disk sector that holds four partition descriptors with (decimal) offset 446, 462, 478, 494, respectively, followed by a signature in the two bytes with offset 510 and 511. The signature has the hexadecimal value 0x55 in byte 510 and 0xAA in byte 511.
Sector 0 of a disk, known as the Master Boot Record (MBR), is a partition table sector, and thus contains four partition descriptors. The partitions described in the MBR are known as primary partitions. If a primary partition has a type indicating an extended partition, then the first sector of this partition is again a partition table sector. The partitions described in partition table sectors other than the MBR with a type not indicating an extended partition are known as logical partitions. The partitions described in partition table sectors other than the MBR with a type indicating an extended partition are known as inner extended partitions and start again with a partition table sector. All partition table sectors other than the MBR contain at most two used partition descriptors, namely at most one partition descriptor with a type not indicating an extended partition and at most one partition descriptor with a type indicating an extended partition. In this way the first sector of each primary extended partition becomes the head of a linked list of partition table sectors which ends with an partition table sector without partition descriptor with a type indicating an extended partition. [Usually there is only one primary extended partition, and hence only a single such linked list.]
A partition with a type not indicating an extended partition covers a single interval of disk area consisting of full sectors. The Partition Size field of its descriptor gives the number of sectors in the partition. The Partition Start field of its descriptor gives the sector offset of the start of the partition with respect to the partition table sector containing the descriptor. Thus, if a partition table sector at sector A contains a partition descriptor with a type not indicating an extended partition with Partition Size field N and Partition Start field S, then this partition descriptor describes a partition containing sectors A+S up to and including A+S+N-1.
[A partition with a type indicating an extended partition is only the carrier of partition table information but is not used as a data partition. Its size is irrelevant (as long as it is nonzero), only the address of the first sector matters.] The Partition Start field of a primary extended partition gives the sector number (counting from 0) of its first sector. The Partition Start field of an inner extended partition gives the sector offset of the first sector of the partition with respect to the first sector of the primary extended partition that is the head of the linked list containing its descriptor. Thus, if a partition table sector at sector A is a member of the linked list of partition table sectors starting with the first sector of a primary extended partition at sector E, and it contains a partition descriptor with a type indicating an extended partition with Partition Size field N and Partition Start field S, then this partition descriptor describes an inner extended partition with first sector E+S.
All partition table sectors must have the 55, AA signature. No partition ends past the end of the disk. No two non-extended partitions overlap. No two partition table sectors are at the same sector (and in particular, there is no loop in the linked lists). No partition table sector is inside a non-extended partition.