Go to the first, previous, next, last section, table of contents.


The format of partition table

Overview the partition table

FDISK creates all partition records (sectors). The primary purpose of a partition record is to hold a partition table. The rules for how FDISK works are unwritten but so far most FDISK programs seem to follow the same basic idea.

First, all partition table records (sectors) have the same format. This includes the partition table record at cylinder 0, head 0, sector 1 -- what is known as the Master Boot Record (MBR). The last 66 bytes of a partition table record contain a partition table and a 2 byte signature. The first 446 bytes of these sectors usually contain a program but only the program in the MBR is ever executed (so extended partition table records could contain something other than a program in the first 466 bytes). For more information, see section The structure of Master Boot Record.

Second, extended partitions are nested inside one another and extended partition table records form a linked list. I will attempt to show this in a diagram at section The format of the table entry.

Each partition table entry is 16 bytes and contains things like the start and end location of a partition in CHS, the start in LBA, the size in sectors, the partition type and the active flag. Older versions of FDISK may compute incorrect LBA or size values. And when your computer boots itself, only the CHS fields of the partition table entries are used (another reason LBA doesn't solve the >528MB problem). The CHS fields in the partition tables are in L-CHS format, see section CHS addressing and LBA addressing.

The list of the type code

There is no central clearing house to assign the codes used in the one byte type field. But codes are assigned (or used) to define most every type of file system that anyone has ever implemented on the x86 PC: 12-bit FAT, 16-bit FAT, HPFS, NTFS, etc. Plus, an extended partition also has a unique type code.

In the FDISK program `sfdisk', the following list is assumed:

00
Empty
01
DOS 12-bit FAT
02
XENIX /
03
XENIX /usr
04
DOS 16-bit FAT <32M
05
DOS Extended
06
DOS 16-bit FAT >=32M
07
HPFS / NTFS
08
AIX boot or SplitDrive
09
AIX data or Coherent
0A
OS/2 Boot Manager
0B
Windows95 FAT32
0C
Windows95 FAT32 (LBA)
0E
Windows95 FAT16 (LBA)
0F
Windows95 Extended (LBA)
10
OPUS
11
Hidden DOS FAT12
12
Compaq diagnostics
14
Hidden DOS FAT16
16
Hidden DOS FAT16 (big)
17
Hidden HPFS/NTFS
18
AST Windows swapfile
24
NEC DOS
3C
PartitionMagic recovery
40
Venix 80286
41
Linux/MINIX (sharing disk with DRDOS)
42
SFS or Linux swap (sharing disk with DRDOS)
43
Linux native (sharing disk with DRDOS)
50
DM (disk manager)
51
DM6 Aux1 (or Novell)
52
CP/M or Microsoft SysV/AT
53
DM6 Aux3
54
DM6
55
EZ-Drive (disk manager)
56
Golden Bow (disk manager)
5C
Priam Edisk (disk manager)
61
SpeedStor
63
GNU Hurd or Mach or Sys V/386 (such as ISC UNIX)(14)
64
Novell Netware 286
65
Novell Netware 386
70
DiskSecure Multi-Boot
75
PC/IX
77
QNX4.x
78
QNX4.x 2nd part
79
QNX4.x 3rd part
80
MINIX until 1.4a
81
MINIX / old Linux
82
Linux swap
83
Linux native(15)
84
OS/2 hidden C: drive
85
Linux extended
86
NTFS volume set
87
NTFS volume set
93
Amoeba
94
Amoeba BBT
A0
IBM Thinkpad hibernation
A5
BSD/386
A7
NeXTSTEP 486
B7
BSDI fs
B8
BSDI swap
C1
DRDOS/sec (FAT-12)
C4
DRDOS/sec (FAT-16, < 32M)
C6
DRDOS/sec (FAT-16, >= 32M)
C7
Syrinx
DB
CP/M or Concurrent CP/M or Concurrent DOS or CTOS
E1
DOS access or SpeedStor 12-bit FAT extended partition
E3
DOS R/O or SpeedStor
E4
SpeedStor 16-bit FAT extended partition < 1024 cyl.
F1
SpeedStor
F2
DOS 3.3+ secondary
F4
SpeedStor large partition
FE
SpeedStor >1024 cyl. or LANstep
FF
Xenix Bad Block Table

The format of the table entry

The 16 bytes of a partition table entry are used as follows:

    +--- Bit 7 is the active partition flag, bits 6-0 are zero.
    |
    |    +--- Starting CHS in INT 13 call format.
    |    |
    |    |      +--- Partition type byte.
    |    |      |
    |    |      |    +--- Ending CHS in INT 13 call format.
    |    |      |    |
    |    |      |    |        +-- Starting LBA.
    |    |      |    |        |
    |    |      |    |        |       +-- Size in sectors.
    |    |      |    |        |       |
    v <--+--->  v <--+-->     v       v

   0  1  2  3  4  5  6  7  8 9 A B  C D E F
   DH DL CH CL TB DL CH CL LBA..... SIZE....

   80 01 01 00 06 0e be 94 3e000000 0c610900  1st entry

   00 00 81 95 05 0e fe 7d 4a610900 724e0300  2nd entry

   00 00 00 00 00 00 00 00 00000000 00000000  3rd entry

   00 00 00 00 00 00 00 00 00000000 00000000  4th entry

Bytes 0-3 are used by the small program in the Master Boot Record to read the first sector of an active partition into memory. The DH, DL, CH and CL above show which x86 register is loaded when the MBR program calls INT 13H AH=02h to read the active partition's boot sector. For more information, see section The structure of Master Boot Record.

These entries define the following partitions:

  1. The first partition, a primary partition DOS FAT, starts at CHS 0H,1H,1H (LBA 3EH) and ends at CHS 294H,EH,3EH with a size of 9610CH sectors.
  2. The second partition, an extended partition, starts at CHS 295H,0H,1H (LBA 9614AH) and ends at CHS 37DH,EH,3EH with a size of 34E72H sectors.
  3. The third and fourth table entries are unused.

Some basic rules for partition table

Keep in mind that there are no written rules and no industry standards on how FDISK should work but here are some basic rules that seem to be followed by most versions of FDISK:

  1. In the MBR there can be 0-4 primary partitions, OR, 0-3 primary partitions and 0-1 extended partition entry.
  2. In an extended partition there can be 0-1 secondary partition entries and 0-1 extended partition entries.
  3. Only 1 primary partition in the MBR can be marked active at any given time.
  4. In most versions of FDISK, the first sector of a partition will be aligned such that it is at head 0, sector 1 of a cylinder. This means that there may be unused sectors on the track(s) prior to the first sector of a partition and that there may be unused sectors following a partition table sector. For example, most new versions of FDISK start the first partition (primary or extended) at cylinder 0, head 1, sector 0. This leaves the sectors at cylinder 0, head 0, sectors 2...n as unused sectors. This same layout may be seen on the first track of an extended partition. See example 2 below. Also note that software drivers like Ontrack's Disk Manager depend on these unused sectors because these drivers will hide their code there (in cylinder 0, head 0, sectors 2...n). This is also a good place for boot sector virus programs to hang out.
  5. The partition table entries (slots) can be used in any order. Some versions of FDISK fill the table from the bottom up and some versions of FDISK fill the table from the top down. Deleting a partition can leave an unused entry (slot) in the middle of a table.
  6. And then there is the hack that some newer OS's (OS/2 and Linux) use in order to place a partition spanning or passed cylinder 1024 on a system that does not have a CHS translating BIOS. These systems create a partition table entry with the partition's starting and ending CHS information set to all FFH. The starting and ending LBA information is used to describe the location of the partition. The LBA can be converted back to a CHS -- most likely a CHS with more than 1024 cylinders. Since such a CHS can't be used by the system BIOS, these partitions can not be booted or accessed until the OS's kernel and hard disk device drivers are loaded. It is not known if the systems using this hack follow the same rules for the creation of these type of partitions.

There are no written rules as to how an OS scans the partition table entries so each OS can have a different method. For DOS, this means that different versions could assign different drive letters to the same FAT file system partitions.

@unnumbered{Appendices and Indices}


Go to the first, previous, next, last section, table of contents.