Bitzenbytes.com

CompuClues Forum

  User  Password
Sunday, July 06, 2008 - 04:57 AM
Search
Main Menu
Who's Online
MEMBERS ONLINE

You are an anonymous user. You can register for free by clicking here
User name
Password
 Remember me
Firefox
Get Firefox 110
Languages
Preferred language:

Partitioning 101 - CompuClues Arcanum
Partitioning 101
Date: March 18, 2002
From: K9MkII (Bill)
 
Partitions: What are they and what are they good for?

Partitions are synonymous with Hard Disk Drives (HDD) for PCs.  All hard drives have them, but there seems to be a fair amount of confusion about what they really are and what they can be used for.

Background

Before we can understand partitions and how they work, we need to establish some concepts and terms related to the physical structure and operation of the hardware.

HDDs contain two elements related to data storage and retrieval; platters and heads. Each platter has two sides, a head is required for each side.

The read/write process is very similar to that used for magnetic tape, such as cassette tapes. Cassette tape is coated with magnetic material, and the heads are mounted in the cassette deck. There are a total of four 'heads' usually contained in a single metal structure. This construction provides for four 'tracks' on the tape, two for each direction. This read/write mechanism is designed so that, when you flip the tape over, the heads are positioned over the two tracks for the other direction.

On a HDD, however, the magnetic material is coated on the platters. In place of the linear motion of the tape moving across the heads, the platters of a disk drive are rotated so that they move under the heads.  After low-level formatting of the magnetic media, each head (for each platter) has its own track rotating underneath it. The heads are mounted on an access arm that moves, in and out, to access multiple tracks on each recording surface (the platter sides). Each track holds multiple fixed-length records called Sectors. In what I believe to be a carry-over from the early floppy days, a sector is normally 512 bytes.

Cylinders, clusters, sectors, tracksIn order to properly visualize the addressing structure used to locate specific records on a HDD, we need to introduce some more concepts. For a single position of the access arm, all of the heads, and therefore the tracks, are lined up vertically. Because the platters are round, this corresponds nicely to the three-dimensional mathematical concept of a cylinder. This accounts for all of the area under the heads at that time. Each different position of the heads forms a cylinder with a slightly different radius. This leads to the concept of a cylinder address, which specifies which of the possible positions of the access arm is to be used.

Within each cylinder we have multiple heads, each with its own surface to record on. So the second part of our addressing scheme is to specify which of the possible heads is to be used.

The final piece to the puzzle is to determine which record or sector to use within the track by using the sector (record) number.

Putting all these together, we have the C-H-S (Cylinder-Head-Sector) form of addressing a HDD used by employing interrupt 13 (int 13h), the BIOS disk access routine. With those three values you can locate any specific sector on the disk.

The CHS addressing scheme worked fine when the size of the media was small (at one time a 10MB HDD was the largest available). Advances in hardware fairly quickly exceeded the capacity of the CHS schema within the constraints of the sizes initially chosen as limits for the values. The initial data structures defined to hold CHS addresses were 10 bits for the cylinder address (0-1023), 8 bits for head address (0-255) and 6 bits for sector address (0-63). This gives the maximum size of a disk under C-H-S as:

(64 sectors x 256 heads x 1024 cylinders x 0.5K bytes/sector) / 1024 KB/MB = 8192MB (8GB)

All is not lost however; there is an alternate method of addressing disks. Since we know that the disk is made up of fixed length records and the controller for the drive can perform calculations, we can also simply number the sectors on the disk sequentially, and leave it up to the drive controller to convert it into the appropriate C-H-S address for the attached drive. This addressing scheme is known as Logical Block Address or LBA and was introduced with the Int 13h Extensions. To take advantage of LBA, support for these extensions is required in the system BIOS and the operating system. The maximum number of 'blocks' that can be maintained is still a constraint. However, 512 byte records are quite small and disks can have a very large number of them. This leads us to the next concept: clusters.

A cluster is the smallest unit of allocation, that is, the smallest amount of disk space that can be allocated to a file. If you extend the concept backwards, the original cluster size was 512 bytes--the same as a single sector size. By grouping sectors into clusters, we can reduce the size of the numbers that the file system has to keep track of for large disks.

Before we go any farther, we need to make a distinction between the physical data storage on the disk and its organization and use. The physical data only has meaning within the context of its structure. Within a partition, this structure is known as a file system, and there are a lot of them (see Bob's treatise on partition types in the Arcanum). The hardware is still going to be dealing with cylinders, heads and sectors. The concept of clusters and allocating space to files belongs to the file system.

MBR and Partition Tables

Following the use of a partition utility to partition a hard drive, the very first sector of a PC HDD is assigned a special use, and a special name, the Master Boot Record or MBR. For our purposes the part of the MBR we're concerned with is the Partition Table.

The partition table is a fixed-length data structure that describes the partitions on the disk. It can contain a maximum of four 16-byte partition entries. Each entry contains:

  • the partition type
  • a flag to indicate if this is the 'active' partition (there can be only one active partition)
  • the starting and ending addresses of the partition for C-H-S drives or the starting sector and number of sectors in the partition for an LBA drive.

Most all of today's drives will be LBA. All of the partitions defined in the partition table of the MBR are, by definition, primary partitions.

By now some of you are probably thinking, "Only four partitions? That seems like an awfully small number" or "I know I've built more than four partitions on a drive". Well, that's sort of true. What solves those two quandaries is one of the primary partition types, the Extended partition. The Extended partition type is a special case that is designed solely to contain logical drives. One Extended partition can contain many logical drives. Although the partition table can contain up to four partition entries, Win9x software will only 'see' two primary partitions on a given HDD, one active primary partition (the boot drive) and one DOS extended partition which can contain multiple logical drives. Under Windows XP, disk management functions will see the hidden partition, but it will not be an available as a disk and will not be assigned a drive letter.

Boot Partition Size Limit

It is unlikely that anyone will run into this boot partition size limit with current hardware and software. If your system BIOS does not support int 13h extensions, any partition that will be used to load (boot) an Operating System must be contained within the first 8GB of the drive. This limitation is imposed due to the facilities available at the time the OS loads.  At that time disk access is limited to what is provided by int 13h. Without the int 13h extensions, and support for them in the OS loader, this limits the size of the boot partition to 8GB.

What are Partitions Good For?

Now that we've got a fairly good understanding of what partitions are, how can we use them effectively? That's going to be difficult to answer. Each person is going to have different needs that will affect their choice of a partitioning scheme. I can only discuss the reasons I have chosen for my partitioning strategy.

Do you need partitions? The easy answer to that is yes, you can't use a HDD without at least one primary partition. And if you buy a PC 'off the shelf' it will likely only have one primary partition. You'll have a C: drive that encompasses the entire HDD. For most users this is probably fine.

Probably the most popular reason for having multiple partitions is to allow the installation of multiple Operating Systems, or multiple versions of the same operating system, on a machine without having them interfere with each other. This is known as a multi-boot configuration and it can be configured in many ways. The most basic is to do it manually. You use a partitioning tool to select which partition is marked 'active' and thus, which OS boots up. There are also several 'boot managers' that can be used to display a menu of your choices at each startup so you can pick the one you want each time.

Segregating data is another good use of partitions. By isolating your data from the OS and other programs you provide a more conducive environment for a 'Nuke & Pave' (well, for the Pave part anyway, if you use the debug script to remove the partition table, no partitions on that drive will survive.)

With established partitions, the OS and programs can be wiped out and replaced with a fresh installation without affecting the data on the other partition(s). Instead of having to do a number of restores to replace your data you simply need to inform the re-installed products where your configuration and data files still reside.

Partitions, and some partition management software, can also be handy for recovering from system modifications gone bad. A Win9x-based system's inability to see multiple primary partitions can be exploited to provide a quickly available backup of a running system. Prior to making the changes, the currently active partition is copied to another 'hidden' primary partition. In the event the system is unable to boot following your changes, you use your partition management software (on floppies) to mark the previously hidden partition as active and you are back in business. I haven't experimented yet to see how XP handles swapping active partitions while it isn't looking. I'm not sure you can use this trick under XP. Although the drive letters straighten themselves out in the BIOS, the statements in boot.ini reference the partition(s) by physical number which does not change. This means that the statement in boot.ini would have to be changed to correctly reference the partition you now want to boot from. For example, the statement to boot from the first physical partition on the disk would be something like:

multi(0)disk(0)rdisk(0)partition(1)\WINDOWS="Microsoft Windows XP Professional" /fastdetect

If you then 'hide' that partition and 'unhide' the second physical partition on the disk, you would need to change that to:

multi(0)disk(0)rdisk(0)partition(2)\WINDOWS="Microsoft Windows XP Professional" /fastdetect

Drive Letters

The assignment of drive letters for a DOS or Win9x system is fixed. The boot drive will be the active primary partition on the primary master drive (in an IDE system) and it will be referenced as drive C:. If there are any other HDDs that contain primary, non DOS Extended partitions they will be assigned consecutive drive letters. For example if you have all four IDE devices populated with HDDs containing a primary partition, the primary master will be drive C:, the primary slave will be drive D:, the secondary master will be drive E: and the secondary slave will be drive F:. Once all primary partitions have been accounted for, we go back to the beginning and look for DOS Extended partitions containing logical drives. Continuing our previous example let's assume each drive also has a DOS Extended partition on it. The primary master has two logical drives defined in its extended partition so they become drives G: and H:. The primary slave only has one logical drive in its extended partition so it becomes drive I:. The secondary slave has three logical drives, which become drives J:, K: and L:. The secondary slave only has one logical drive, M:.

This assignment method can be very confusing if you add to, or change, your HDD configuration. Many drive letters will change which tends to confuse installed products and users. One method of reducing the drive letter changes is to only define a primary partition on the physical boot drive. The physical boot drive is the only one that is required to have an active primary partition; it is perfectly legal to have Extended partitions only on all other disks. The only drawback that I'm aware of is the loss of a small amount of disk space. The defined Extended partition will start with logical cylinder 1 so one cylinder's worth of space will not be usable on the drive (for an IBM 40GB drive, you lose 7.9MB).

A summary of Microsoft OS Partition Information can be found here.

[Printer friendly page | Send to a friend]