MobileDyne Systems, Inc.

PC fdisk Partitions and Unix

What is a Partition?
Because the word "partition" is so simple and clear, both the PC and Unix worlds use it to express the same concept: "a portion of a single disk". And as long as PC hardware boots a PC operating system, and Unix hardware boots Unix, there is no confusion. The two camps use the same word to describe the same concept, but they implement that concept in different ways.

But our topic steps directly into the confusion: booting Unix on PC hardware. Now we must be careful to specify the type of partition we are talking about. For clarity, we'll drop the unqualified use of the word "partition", and talk only about PC-style "fdisk partitions" and "Unix partitions".

Boot Firmware: BIOS and Boot PROMs
The boot firmware is stored in a chip on the system board. On a PC, the system board is often called a motherboard, and the boot firmware is called the "motherboard BIOS", or just "the BIOS". On hardware made for Unix, the equivalent is called "the boot PROM", or something similar. The PC BIOS includes a nice table editing utility to change BIOS settings, while the Unix boot PROM includes a very simple command line editor. Once the system is booted, a similar editor program can also be used, such as Sun's "eeprom" (edit EPROM).

The PC Master Boot Record (MBR)
When booted, both PCs and Unix hardware begin execution of their respective firmware programs. Each type of system then transfers execution to a program stored in the boot sector of a bootable disk. This little program does little more than figure out where to find the real operating system, and transfer control to that address. It consults a table to answer that question.

Disks are defined by three geometric specifications: Cylindars, Heads, and Sectors. PC disks have varying numbers of cylinders and heads, but they always have a sector size of 512 bytes. The boot sector of a PC disk is the very first sector on the disk, "sector zero". The MBR occupies all 512 bytes of sector zero. The MBR data structure contains both a 446 byte post-BIOS bootstrap program, and the MBR partition table. Because this teeny little program uses up almost all of the MBR, there are only 66 bytes left. Within this meager remaining space, 64 bytes are devoted to defining the only four fdisk partitions there can ever be.

Fdisk Partitions
Each of the four fdisk partitions is defined by the same woefully inadequate data structure. The individual bits of the Cylinder, Head, and Sector variables in the fdisk data structure have been re-jiggered beyond their natural limits, and yet it is still not enough to describe a big disk. All of the confusion regarding physical versus logical PC disk geometry could be eliminated if this ancient little data structure could only be re-designed or expanded. Since it can't, we are left scratching our heads over the relationship between physical geometry, and Logical Block Addressing, or LBA. But that's another story.

What is a Unix Partition?
A Unix partition is implemented by a completely different data structure. In Solaris 2.x, this data structure is called the "vtoc", or virtual table of contents. In Solaris 2.x, Unix partitions are called "slices", though you can still find the occasional man pages using the word "partition". Older Sun operating systems, as well as many other Unixes, call them "partitions".

Even when Solaris is installed on a PC, the Solaris vtoc has nothing to do with the PC Master Boot Record partition table. No data in the MBR partition table has any reference to the vtoc or the underlying Unix partitions. Instead, the MBR partition table defines the same fdisk partitions it always does, and inside the fdisk partition containing Unix lies the vtoc. So the Unix partitions are all inside a single fdisk partition. PC fdisk programs can't tell what Unix does inside of its fdisk partition. The benefit of this design is that within the fdisk partition used by Solaris, the slice layout looks identical to a native SPARC disk.

What about Linux?
Because it was written from scratch without incorporating any of the original Bell Labs Unix source code, Linux is not strictly a "unix" operating system. It was designed from the ground up to run on PC hardware, without any other "native system" to maintain compatibility with. Consequently, it does not create its own partition structure like Solaris. It simply uses the fdisk partitions directly.

Primary and Extended Fdisk Partitions
There was originally only one type of PC disk partition: the "Primary" partition. This so called "primary partition" is what we have been calling an "fdisk partition". The primary partitions are the ones listed in the MBR partition table.

To add more partitions to a disk, a backwards compatible scheme was devised to create a new partition type, the "Extended" partition. The Extended Partition is really a special type of Primary Partition. It must be sub-divided into "Logical Partitions" if it is to be of any use. The "logic" defining the logical partition is exactly this sub-dividing data structure. Finding the actual data structure describing the boundaries of a logical partition requires you to follow a pointer from the MBR to a linked list beginning in the first sector of the Extended Partition. Some fdisk programs are blind to logical partitions because they don't know how to do that.

Having suffered from the four partition limit of the MBR, the designers of the Extended partition weren't about to be caught short. They exchanged the table structure of the MBR for a linked list!

Conceptually, an Extended Partition is much like a Primary Partition in which Unix has defined its own vtoc. Both are containers beginning with data structures that define another level of partitions.

The Fdisk Program
The universal name to call a program that edits the MBR partition table is "fdisk", but there are many versions and vintages of fdisk. Some allow you to set values that others misinterpret, although compatibility is obviously a goal. Not all of these fdisk partition table editors even have the same feature set. Some non-fdisk programs can also edit the MBR partition table, notably Partition Magic.

PC disk partitions can be categorized in three ways:

  1. Status: Active or Inactive - - ("active" means bootable. The Status of any given partition is determined by whether "0" or "128" is written into the first variable ("bootid") of the partition entry)
  2. Primary, Extended, or Logical
  3. Visible or Hidden - - with respect to the ability of Microsoft Windows to see the partition and therefore assign a "drive letter" to it. Fdisk programs can always see "hidden" partitions.

Most fdisk programs allow at most one partition of the four in the MBR p-table to be Extended on a particular disk. Because the potential number of logical partitions in an Extended partition is not limited, there is no need to Extend more than one Primary. If you wrote a program that actually Extends more than one Primary, it will produce a table that other fdisk programs consider corrupt.

A usable Extended partition must contain at least one logical partition. It is not possible to write a filesystem directly into an extended partition and expect any OS to recognize it. If you wrote your own program to do that, it would overwrite the first record of the extended partition with the beginning of a filesystem. But the first sector has to contain a linked list laying out the logical partitions within. Corruption! So let's not talk about filesystems in the extended partition - - there can't be any. There can only be filesystems in logical partitions that are contained by the extended partition. In practice, most OS's / fdisk programs recognize at least two dozen logical partitions.

Can I Link This Page?

Home FedSock
PowerShip Server
Company Clients Public

© 1994-1999, MobileDyne Systems, Inc.
Atlanta, Georgia

make:   09/16/99 at 09:06:57