A simple guide to hard disk partitions



This guide is shamelessly based on the document http://www.diskwarez.com/articles/par.htm. Any new errors introduced are my own. I assume you are using a raw sector editor such as diskedit.com.

Traditionally, hard drives were accessed by cylinder, head, and sector (CHS), which represented the actual layout of data on the drive. Modern IDE/ATA drives have varying numbers of sectors per track, and individual sectors are naturally accessed with a simple count starting from 0 for the first sector. In order to provide backward compatibility, these drives can also be accessed by a simulated CHS, with translation into absolute sector numbers inside the drive. This internal drive translation can be changed using tools such as HD-MBOOT and examined with tools such as IDEATA.

Note that the lower limit (ie the first sector) for Cylinder,Head,Sector is 0,0,1. Everything is base zero EXCEPT the sector number.

The last physical cylinder on the drive used to be reserved for IBM disk diagnostics, but this is probably no longer an issue.

Unfortunately, the maximum count for Cylinder,Head,Sector is 1024,256,63 in the BIOS interface, but 65536,16,256 in the IDE/ATA interface. Thus, without further translation, we would be limited to the lowest common denominator 1024,16,63 which, with the sector size 512 bytes, gives a maximum disk size of 504Mb. To get around this, a modern BIOS translates the CHS from the drive by doubling the head count and halving the cylinder count until the cylinder count falls to 1024.

Again unfortunately, it turns out that DOS cannot cope with a head count of 256, so for drives over 4Gb, the head count needs to be translated to 255 rather than 256 by the BIOS. This gives an upper limit of 8Gb for the drive size.

A drive larger than 8Gb returns its C,H,S information as 16383,16,63; this is an indication that the CHS size information is wrong.

The region of a large drive beyond the 8Gb limit can only be accessed via the absolute (LBA) sector number. The first sector is number 0. Operating systems such as Windows NT4 Service Pack 4 and Linux can directly access the IDE/ATA drive in this way, but Windows 95 and Windows 98 rely on special INT 13 extensions in the BIOS and cannot go beyond the 8Gb limit without a suitable BIOS.


The Master Boot record is the first sector (C,H,S=0,0,1) on the disk. it contains 446 bytes of boot code space, followed by 4 partition tables (of 16 bytes each) and finishes with the standard "signature" of AA55h (2 bytes, little endian). The four tables start at offsets 0x1be, 0x1ce, 0x1de and 0x1ee in the sector.
             |                                |
             |                                |
            /\/             code             /\/
             |                                |
             |                          +-----|
             |                          |     |
             |table 1    |    table 2   |     |
             |table 3    |    table 4   |55|aa|

                       figure 1 - MBR
A Partition Table is a list of Partition start and end locations in cylinder, head, sector (CHS) format, the start location as an absolute sector, and a size in number of sectors; as well as partition type and whether or not the partition is bootable.

The CHS entries are in BIOS INT 13h format, with the cylinder number sharing some bits of the sector byte. The CHS values are used to interface with the BIOS which uses CPU registers for system calls.

  BYTES    0      1 - 3      4      5 - 7     8 - 11     12 - 15
       |      |           |      |         |           |          |
       |      |           |      |         |           |          |

                       Figure 2 - Partition Table

The CHS format is:
       | 7 6 5 4 3 2 1 0 | 7 6 5 4 3 2 1 0 | 7 6 5 4 3 2 1 0 |
       | H H H H H H H H | C C S S S S S S | C C C C C C C C |
       | DH              | CL              |CH               |

                        Figure 3 - CHS Format

where the first line is the BYTE/BIT numbers, the second line shows data (C = cylinder, H = head, S = sector), and the last line shows which CPU register is loaded with the data by a BIOS call. The two cylinder bits in CL are the high order bits, so we get
C,H,S = ((CL&0xC0)<<2+CH),DH,(CL&0x3F).

The ABS-START and NUM-SECS are each four-byte little-endian counts,

Unused partition tables should be set to all zeros, although it is often sufficient to set the TYPE to 0.

The BOOT byte should be set to 0x80 for the (only) bootable partition and to 0 in all other cases.

If the starting or ending sector is beyond the CHS limit, it should be set to CHS=1023,255,63 to show it invalid.

There can only be one FAT file system in the MBR. If you need more, or need more than four partitions in total, you need to use a DOS EXTended partition (type 05).

Partitions normally start at a cylinder boundary: C,H,S=??,0,1. The first partition in the MBR and the (only) partition in a DOS EXTended partition normally start one head in, at C,H,S=??,1,1.

The first sector of a DOS EXTended partition is laid out similarly to the MBR, except that there may only be two Partition Tables: one for a "real" partition and optionally one for another, chained, DOS EXT partition. Each DOS EXT partition contains its own "real" partition and all the chained partitions, and should be sized acordingly.

Partition Types

   Partition  Fdisk                                          Starting in
   Type       Reports      Size                  FAT Type    version
   01         PRI DOS      0-15 MB               12-Bit      MS-DOS 2.0
   04         PRI DOS      16-32 MB              16-Bit      MS-DOS 3.0
   05         EXT DOS      0-2 GB                n/a         MS-DOS 3.3
   06         PRI DOS      32 MB-2 GB            16-bit      MS-DOS 4.0
   07         ----  Windows NT NTFS [if Boot partition then < 4Gb] ----
   0E         PRI DOS      32 MB-2 GB            16-bit      Windows 95  *
   0F         EXT DOS      0-2 GB                n/a         Windows 95  *
   0B         PRI DOS      512 MB - 2 terabytes  32-bit      OSR2        *
   0C         EXT DOS      512 MB - 2 terabytes  32-bit      OSR2        *
   82         ---------------- Linux Swap ------------------------
   83         ---------------- Linux EXT2 (native) ---------------           
                               [in part from Microsoft KB article Q69912]

		* Types 0C..0F Use the ABS-START and NUM-SECS fields and thus
                  can extend beyond the 8Gb boundary.

Boot Sectors

A bootstrap needs to be present in the MBR. You might wish to use Linux LILO or something else. The standard Microsoft bootstrap code can be inserted in the MBR with the undocumented FDISK /MBR command.

The standard bootstrap uses the START-CHS field only, so boot partitions must start in the first 8Gb.

The active partition will then have its own bootstrap in its first sector; the Microsoft one is inserted by the FORMAT command. This bootstrap sector must also finish with the magic number AA55h (little endian, ie the bytes 55 AA. All bootstraps (MBR and partition) are executed at address 0000:7c00, but typically relocate themselves.

Denis A Nicole