Understanding MultiBooting
and Booting Windows from an Extended Partition

by Dan Goodell

Background - Sectors, Partitions, and LBA

The term "drive" has an imprecise definition. Sometimes it is used in a logical context (as in "drive C:" or "drive E:"), and sometimes in a physical context (as in "Seagate drive" or "slave drive"). Which is the more correct usage? Well, probably neither is any more correct than the other. Both were pretty much the same back in the days when the term came into usage for hard disks. As it has become commonplace in modern times to divide hard disks into multiple partitions, care should be taken to avoid using the term ambiguously. To avoid confusion we will henceforth use the term "disk" to refer to the physical unit. A hard disk may be composed physically of one or more disk platters, and logically of one or more partitions.

Hard disk geometry consists of platters divided into concentric rings ("tracks"), with each ring divided into a number of sectors. There may be one or more platters, with a head for each platter surface ("side"). A vertical slice of the same corresponding rings through all platters and sides is called a cylinder. Sectors (at least in the first 8 GB) can be addressed in terms of CHS coordinates--cylinder, head (synonymous with "side") and sector values. For various reasons we won't go into here, the range of valid values for these parameters is limited to 0-1023 cylinders, 0-255 heads, and 1-63 sectors. Now, modern hard disks don't really have as many as 256 heads (that would be 128 platters!), there's a bit of trickery that goes on. Regardless of the actual physical structure, the integrated controller on the hard disk unit itself alters the numbers so the computer BIOS thinks there are as many heads, cylinders, and sectors as the controller says there are. The subject of drive geometry "translation" is beyond the scope of this discussion. All that matters are the computer's BIOS thinks this is the disk's geometry and the disk itself goes along with the charade. Note C and H are 0-based, while S is 1-based, so the first sector on a hard disk is CHS 0/0/1. Since sectors are blocks of 512 bytes, the maximum size of a hard disk defined in CHS terms is about 8 GB (1024*256*63*512).

For compatibility reasons the BIOS code in new computers continues to use CHS, at least at boot time. Fortunately, a modern BIOS with amended code ('Int13h extensions') can switch to 'Logical Block Addressing' (LBA) to use disks greater than 8 GB in capacity. LBA treats the data blocks as one long string of consecutive sectors from the beginning of the disk to the end. The sequence starts with all sectors on track 0 of head 0, then all other heads in the same cylinder, and finally all other cylinders. Assuming a disk using the maximum permissible values, the first 63 sectors (numbered LBA 0 to LBA 62) on the drive correspond to CHS 0/0/1 to 0/0/63. This is followed by CHS 0/1/1, the 64th sector--ironically, numbered '63' because LBA starts counting at zero. Following CHS 0/255/63 is CHS 1/0/1 (aka, LBA 16,128).

If your computer's BIOS does not support Int13h extensions it will only be able to address a specific sector in terms of the CHS coordinates, meaning the last addressable sector will be 1023/255/63--about 8GB. It will not be able to properly use a hard disk larger than 8 GB. However, the disk manufacturer may provide drive overlay software to get around this limitation. Examples of overlay software include "EZ-Drive" and "Disk Manager". This software installs itself at the beginning of the disk, where it will load at boot time (during Step 1 of the boot process) and amends the computer's BIOS routines on the fly to add the support for Int13h extensions.

The first sector of the disk (LBA 0 or CHS 0/0/1) contains the master boot record (MBR) and the primary or master partition table (MPT). The MBR is a short bit of code that is executed when the computer tries to boot from the hard disk. Most of the remaining sectors on the disk are grouped into partitions, the boundaries of which are defined in the MPT.

The Partition Table

Powerquest's Partition Table Editor is a valuable tool for exploring the partition tables in detail.

The MPT is a kind of "table of contents" to the disk's primary partitions. The MPT identifies the type and location on the disk of up to four primary partitions. Each partition is defined by a partition type (a single byte shown in two-character hexadecimal notation, representing FAT, FAT32, Linux ext2, HPFS, etc.), the partition's beginning and ending sectors in CHS, the number of "sectors before" the start of the partition (i.e., the relative offset in sectors from the table to the partition), and the size of the partition in total sectors. There is also a marker flagging whether this partition is the active boot partition--a hexadecimal value of 80 here identifies which partition the BIOS and MBR will attempt to boot when the computer is turned on.

One of the four primary partitions may optionally be defined as type "Extended". This extended primary partition can contain one or many logical volumes, also commonly called logical partitions. Using an extended partition permits us to create more than four total partitions on the disk.

Logical partitions are not defined in the MPT, but rather in an extended partition table (EPT) on the first sector of the extended partition itself. Powerquest calls this first sector an EPBR ("extended partition boot record"). The EPT is a secondary partition table using the same format as the MPT. Like the MPT, the EPT has room for four entries, but there will never be more than two entries in any EPT. One entry will define a single logical volume, and the second entry will define the remainder (if any) of the extended partition unused by that volume.

To define multiple logical partitions, a linked list is used of multiple EPTs daisy-chained together. At the beginning of the extended primary partition is the first EPT, which will contain two entries: the first logical volume, and the remainder of the extended partition. At the beginning of this remaining portion of the extended partition is another EPT, defining one more logical volume and any portion still remaining. Each "remainder" entry is an Extended type entry pointing to the next EPT. In this way, EPTs are daisy-chained together until all logical volumes are defined.

Be aware that the order of the entries in the partition table does not always correspond with the physical order of the actual partitions themselves. While your actual partitions could be in the physical order 1-2-3-4, it's permissible to appear in the MPT in the order 1-3-4-2, for example. Although there is no harm in reordering the entries (nor in leaving them out of order), most partitioning utilities--including those from Microsoft as well as numerous third-party providers--don't bother to resort the MPT as they do their work on the partitions.

Typically, you'll find the MPT order follows the chronological order in which the corresponding partitions were created. For example, suppose you create the first partition at the front of the disk: it will be listed first in the MPT. Then you shrink it, leaving unallocated space at the front: it's still listed first. Then you create a new partition in front: the new entry is added in the second slot of the MPT, and now your MPT is out of order with the physical partitions. There could even be a blank entry (all zeroes) between two entries if a partition is deleted--even if the partition space was merged into a neighboring partition. Again, the order partitions are listed in the MPT has no significance . . . although it does affect how the partitions are identified in the boot.ini file--more on that later.

Any partition can effectively be hidden from an OS merely by changing the partition-type code in the MPT to something the OS doesn't recognize. For example, Windows 98 can recognize another partition if it is a FAT32 type, but if we change the type to something Win98 doesn't know, the partition is effectively hidden. The other parameters of the partition table entry for that partition still define the space so the OS knows something is there, but it won't know what and will ignore it. Note we're not really changing the format of the partition, we're just changing the MPT entry so Win98 thinks it can't recognize the format. In fact, it would be more accurate to say we're "disguising" it rather than "hiding" it--it's still there, Windows knows it's still there, but Windows is fooled into thinking it isn't a valid Windows file system.

Drive Letters

So which is the "C:" partition? Well, that designation only has meaning within the context of whichever OS installation is booted. Partitions do not have drive letters affixed to them. If the computer is turned off, there is no such thing as "drive C:". Some OS's (linux, for example) do not even use drive letter references. Even if an OS uses drive letters, the drive letter assignments may change depending on how the OS is configured. A partition may be designated as C: by one OS but the same partition may be called by a different letter when another OS is booted. It is the boot OS which assigns drive letters when it starts up, and that assignment has no meaning unless that OS is the one booted. In a manner of speaking, drive letters exist "only in the mind of the OS that is booted."

While a given partition may be assigned different drive letters by different boot OS's, ideally it would be more convenient if that partition is assigned the same drive letter by all OS's. In our project, we deliberately arrange things so the two data partitions will be known by the same drive letters regardless of which OS is booted.

Partition Boundaries

Partitions normally begin and end on cylinder boundaries, so for all primary partitions other than the first, the partition boot record resides on head 0, sector 1--the first sector of that particular cylinder. The exception is the first primary partition, which must leave room on the first track (head 0 of the first cylinder) for the master partition table. Thus, the first primary partition and its PBR begins on the next track--head 1 of the first cylinder. This means the first primary partition begins at CHS 0/1/1, while all other primary partitions begin at CHS xxx/0/1.

Note this results in 62 of the first 63 sectors (the rest of side 0 following the MBR) being officially unused. Since those sectors are outside of any partition, they are not part of any logical "drive" and cannot be used to store "files" in the usual sense. However, note that some boot managers usurp that space to store some of their own information by writing directly to the hardware sectors. This is understandable behavior because boot managers must, after all, operate outside the scope of any partition. However, some recent Windows programs have been guilty of trying to hide their own copy-protection data in those sectors--a very dangerous practice because there is no way of knowing if that space is already being used by something else (remember, that space is outside the control of any file system, so its use or availability cannot be recorded anywhere).

Logical volumes in the extended partition must also leave room for a partition table (the EPT) in front of each one, so they follow the same scheme as the first primary partition--the EPT is on CHS xxx/0/1 and the logical volume and its boot record begins on CHS xxx/1/1.

Although the MPT can define only four primary partitions, by making one of them an extended partition enclosing many logical partitions we can have more than four partitions overall. However, most instructions for installing multiboot systems only cover installing OS's in primary partitions, not in logical partitions. Since the number of primary partitions is limited, their instructions leave you on your own to figure out how to put more than a few OS's on a single hard disk. With a thorough understanding of partitions and the boot process, you should be able to modify the installation instructions of your boot manager to accomodate as many OS's as you wish to install.

If you need more background in these concepts, an excellent tutorial on hard disks can be found at The PC Guide. The following sections are particularly useful to understand for our project:

author: Dan Goodell, ©2003-2004