Detailed analysis of disk partitioning

Terminology used

First and foremost I have attempted to not use the term partition table as it is confusing what exactly is being referred to. At least when I've used it in the past I have either been refering to the group of 4 partition records in sector 0 (for example) or I have been refering to the whole chain of partition records spread across the disk. For this reason I have decided to use the term primary partition table when refering to the group of 4 partition records in sector 0, and use secondary partition table when refering to a group of partition records that are inside a primary extended partition. See the glossary for further details.

All references to a “byte” as in a kilobyte (kb) a megabyte (Mb) are replaced by the term octet hence ko and Mo, since the term byte is ambiguous.1 It is unclear the number of bits being described, admittedly this is not an issue for x86 architectures but hey if I'm going to bother putting this down it might as well be complete.

Numbering always starts from the number 1 and not 0,2 counting from 0 makes about as much sense as specifying a kilooctet / kilobyte is 1,024 (which thank goodness a kilooctet is now officially defined as 1,000), so yes you guess correctly that I use ko to refer to 1,000 octets and Mo to refer to 1,000,000 octets.

You may have noticed when I was using the units above of kilooctet and megaoctet I am not capitalising the k in ko but I am for the m in Mo, this is due to the detail spelt out in the International System for Units (SI). However no letters are capitalised when the full form of the name is used ie. gigaoctet. And the reason the o for octet (and the same goes for the b of byte) is never capitalised is simply that octet is not someone's name. If you disagree with any of the detail here feel free to contact me and I'll see about correcting any details that are incorrect.3

Multiple Prefix Symbol
10 deka da
102 hecto h
103 kilo k
106 mega M
109 giga G
1012 tera T
1015 peta P
1018 exa E
1021 zetta Z
1024 yotta Y

Following details are only necessary for people unfamiliar with common computing terms and notation.

Structure of a partition record

Field Name Boot Starts @ Head Starts @ Sector Starts @ Cylinder Type Ends @ Head Ends @ Sector Ends @ Cylinder Starts @ Sector Length in Sectors
Length in bits 8 8 6 10 8 8 6 10 32 32

Note: The bits in this structure are in the order of octets in increasing address from left to right and the individual bits within each octet are from least significant to most significant (again left to right). Problem is IBM compatible hardware plays a little game which makes it seem as if the bits are most significant to least (hence right to left).

The only reason this is of any concern is that some of the fields do not span a whole number of octets. Following details are provided for handling with these situations.

More detail on bit ordering

As previously mentioned IBM compatibles are designed to make octets appear as if the bits are ordered from high to low whereas in actual fact they are ordered from low to high.

The following two tables display an octet of value cah.

It can initially appear that the order of the bits in an octet is as detailed in the following table ie. from left to right.

Bit No. 8 7 6 5 4 3 2 1
Bits 1 1 0 0 1 0 1 0

In actual fact they are ordered from right to left in the octet, otherwise the bits of the field Starts @ Cylinder would be separated into two groups with the 6 bits of Starts @ Sector inbetween.

Bit No. 1 2 3 4 5 6 7 8
Bits 0 1 0 1 0 0 1 1

Location of partition records

The location of the four partition records whether they be part of a primary or secondary partition table begins at octet 447 and ends at octet 510 (note countig from 1). The last two octets are set aside for the Master Boot Record signature which have been applied to secondary partition tables, this appears to be informal as code doesn't appear to check it.

So the four partition records each at 16 octets makes a 64 octet block, and with the signature it means the last 66 octets of a partitioning sector is used up to detail the partition.

Partitioning scheme for multiboot systems

For a partition table that is compatible between as many possible operating systems structure your partition table in the following way. Subsequently many of the details are not hard and fast rules for partitioning your disk but are instead guidelines for ensuring your partitioning will be handled perfectly fine by all your operating systems.

Note: cylinder and head counts in partition records start at 0 whereas sector counts start at 1, subsequently cylinder and head details in partition records need to be increased by 1 when comparing to geometry details. A disks geometry details can be found in BIOS or by using a partitioning tool such as fdisk.

Also common extended partitions are partitions of type 05h, 0fh and 85h and type 00h is used to identify the record is not used.

  1. The first primary partition if it is a data partition starts at head 1, sector 1 and ends on a cylinder boundary.
  2. Second, third and fourth primary partitions start at head 0, sector 1 and end on a cylinder boundary.
  3. Extended partitions start at head 0, sector 1 and end on a cylinder boundary.
  4. Secondary data partitions start at head 1, sector 1 and end on a cylinder boundary.
  5. Primary extended partitions contain a whole partition chain.
  6. Secondary extended partitions only contain 1 secondary data partition, the secondary extended partition starts at the sector where the contained secondary data partitions record exists and extends to the end of the secondary data partition.
  7. CHS addresses of all partition records are absolute addresses, whether the record exists inside a primary extended partition or not.
  8. The value in the Starts @ Sector field of partition records in the primary partition table are absolute addresses.
  9. The value in the Starts @ Sector field of partition records of type data inside a primary extended partition is relative to the start of its immediate parent extended partition.
  10. The value in the Starts @ Sector field of partition records of type extended inside a primary extended partition is relative to the start of the primary extended partition.
  11. All partition records must point to further down the disk than where the record itself resides.

Subsequent implications

  1. A partition chain can not link back on itself, hence creating a circular linked list.
  2. Partition records exist in the order the partitions are placed on disk.

The following table is provided to make some of the rules listed above a little more clear.

Starts @ Head Starts @ Sector Ends @ Head Ends @ Sector
First primary partition if data 1 1 Last Last
Second, third and fourth primary partitions 0 1 Last Last
Extended partitions 4 0 1 Last Last
Secondary data partitions 1 1 Last Last

Fundamentals

  1. A partitions starting location must be before its ending location.
  2. Partitions can not overlap.
  3. Sector number, both Starts @ Sector and Ends @ Sector must never be 0.
  4. Cylinder numbers, that is Starts @ Cylinder and Ends @ Cylinder must never be greater than or equal to the number of Cylinders.
  5. Head numbers, that is Starts @ Head and Ends @ Head must never be greater than or equal to the number of Heads.
  6. Sector numbers, that is Starts @ Sector and Ends @ Sector must never be greater than the number of sectors per track.
  7. Boot field must either be 00h or 80h.
  8. Only one partition record in the primary partition table can have its boot field set to 80h at any one time. (More precisely, only one at boot time. But it is better to not let MS systems ever see an odd partition table)

What you are not restricted from

What you ought to avoid

Reasoning for some of the rules

What I am unsure about

What abiding by this scheme will mean

A combination of any of the following operating systems will be able to coexist on the one disk and you can even exchange data between the systems by using commonly recognised partitions.

A further good reason to abide by these rules means recovery is greatly simplified in the event that your partitioning becomes corrupt. This also leads of into another topic of discussion, partition recovery.

Glossary

Foot notes

1 - If anyone reads this I'm sure they'll disagree with at least this point if not all the others. But a byte is simply a collection of bits that are dealt with as a unit and a word consists of bytes, though does not have to be a complete number of bytes (eg. several bytes followed by a parity bit all within a single word). Back to the myth “a byte is 8 bits” firstly this is completely wrong as machines have been made that have no hardware for handling a byte, all they do is deal with words. It is part of the configuration of the machine that defines the way in which to handle discreet sections of a word eg. bytes and since you can define them they can be however many bits you like. Now please note I'm talking about hardware that most people in the IT industry have never seen and that includes me, I've just read and heard about it.

2 - Unfortunately I am not always able to stick to this when refering to certain things, such as addressing where sector 0 is the first sector.

3 - For anyone that still does not agree with my use of the units, take a look into the Weights and Measures laws passed. The legislation catagorically states that to use units they must be used as I have stated. And you'll note none of the hard disk manufactures for example are being sued for disks they are turning out for inaccurately stating the size of their disks. The reason is they use the legally defined units and not the child like approach to units used in computing circles. And now I'm certainly showing my bias :).

4 - If the first primary partition record is an extended partition then it can not start at Cylinder 0 Head 1 Sector 1 because data partitions are only able start in either Head 0 or Head 1 and if an extended partition start in Head 1 then its sibling data partition would have to start in Head 2 which is not supported by all systems.

Page last modified: Unknown since javascript not enabled

1