Partition (computing)
|
In computer engineering, hard disk drive partitioning is the creation of logical divisions upon a hard disk that allows one to apply operating system-specific logical formatting.
Disk partitioning is a simple technique which can be viewed as a precursor of Logical volume management.
Contents |
|
Purpose
Partitioning allows one to have multiple filesystems on a single hard disk. There are many reasons to do this including:
- Technical limitations of a filesystem or operating system (e.g. old versions of the Microsoft FAT filesystem or old linux kernals that can't boot on a partion with more than 1024 sectors)
- If one partition becomes corrupt, only that partition suffers and not your whole hard drive.
- On some OSes, e.g. Linux, the swap file is normally a partition of its own. When it is, systems with a dual boot configuration can make several OSes use the same swap partition and therefore save disk space.
- To prevent overgrown log or other files from making the whole computer unusable, they are put on their own partition. Then only one partition will run out of space.
- Often, two operating systems cannot coexist on the same partition, or use different "native" disk formats. The drive is partitioned into different logical disks for different OSes.
- The speed of the harddrive is partially dependent on the cluster size. For some filesystem types, smaller partitions on one physical harddrive decrease the cluster size (because cluster size is directly proportional to partition size for those filesystem types), thus helping increase read and write speed.
Implementions
Numerous partitioning schemes have appeared during the years, for almost all computer architectures in existence. Many of them are relatively transparent and allow convenient manipulation of the disk partitions; some however are obsolete in design and are accompanied by numerous quirks.
IBM PC (or clone)
History
The partition table, as used in the IBM PC architecture, was first devised in 1982, when hard drives were coming into use. In 1987 with DOS 3.3, an expansion of this format that provided for extended partitions which can contain logical partions.
Specifics
The partition table is located in the master boot record on the disk. The master boot record is the first sector on a disk. The partition table consists of 64 bytes. There are 4 partition table entries. Each is 16 bytes in length.
The partition table starts at offset (Hexadecimal) 0x1BE. Each partition table entry is 16 bytes in length so.
Master Boot Record (offset) 0x0000 to 0x01BD - First 446 bytes 0x01BE to 0x01CD - Partition entry 1 0x01CE to 0x01DD - Partition entry 2 0x01DE to 0x01ED - Partition entry 3 0x01EE to 0x01FD - Partition entry 4 0x01FE to 0x01FF - Boot signature
The two byte master boot record signature at the end tells your computer that this is the boot sector. On some computers the operating system will not boot if the boot signature is not present in the master boot record.
Each partition table entry has the following arrangement...
|==========================================================| | Byte Count | Description of contents | |==========================================================| | 1 | Boot indicator (0x00 for off, 0x80 for on) | |==========================================================| | 3 | Starting head, cylinder and sector | |==========================================================| | 1 | Filesystem descriptor | |==========================================================| | 3 | Ending head, cylinder and sector | |==========================================================| | 4 | Starting sector (relative to disk beginning)| |==========================================================| | 4 | Number of sectors in partition | |==========================================================|
Sample partition table entry... (please also keep in mind that all bytes are in little endian)
offset: value explanation ======: ===== =========== 0x01BE: 0x80 bootable flag (0x00 for flag off, 0x80 for on) 0x01BF: 0x00 0x02 0x00 starting head, cylinder and sector 0x01C2: 0x83 filesystem descriptor 0x01C3: 0x1A 0x5B 0x8C ending head, cylinder and sector 0x01C6: 0x02 0x00 0x00 0x00 starting sector (relative to beginning of disk) 0x01CA: 0x00 0x35 0x0C 0x00 number of sectors in partition
CHS
The CHS (cylinder, head, sector) area of a partition table entry can be confusing. The easiest way to address these values is in binary...
CHS format: =========== first 8 bits -> head next 2 bits -> first 2 bits of cylinder next 6 bits -> sector (remember sectors start at 1) last 8 bits -> last 8 bits of cylinder Example... 00000000 00 000010 00000000 -> starting starting head = 0 (00000000) starting cylinder = 0 (0000000000) starting sector = 2 (000010) 00011010 01 011011 10001100 -> ending ending head = 26 (00011010) ending cylinder = 396 (0110001100) ending sector = 27 (011011)
Active Partition
The Bootable Flag Determines the active partion. Only one partition can normally be active at a time. The active marker is used during boot: after the BIOS loads the MBR into memory and executes it, the MBR checks the partition table at its end, and locates the active partition. Then it proceeds to load the boot sector of that partition into memory and runs it. Usally a boot loader such as GRUB or NTLDR. Some operating systems require being installed on active partitions. For example, Microsoft Windows 2000 Professional marks its own partition active when it starts up. Thus NTLDR will run next time the system boots, even if the user intended to use another boot loader on a different partition.
Logical Partitions
Primary partions of which only 4 can be made per physical disk can be set to be extended partitions. Which are containers of logical partitions (a maximum of 24 each). Modern Operating Systems can use these partions the same as primary partions.
Other Partitioning Implementions
As the IBM PC architecture is extremely common, the partition tables are likely to stay for a while. However, a recent project of Intel and Microsoft developed for the IA-64 architecture (based around the Itanium or Itanium 2 CPU) called the Extensible Firmware Initiative (EFI) has a component called GUID Partition Table (GPT).
Partitioning Schemes
Microsoft Windows
With Windows the standard partitioning scheme is to create a single partition, the C: drive, where the operating system, data, and programs all reside. It is recommended, however, to create multiple partitions or use multiple hard drives where the first partition (C:) is stored on one partition with the rest of the partitions and/or drives allocated to applications and data. The "My Documents" folder, a "special folder" home directory, can be mounted to take up the entire free space on a separate partition.
UNIX Systems
For UNIX-based and UNIX-like operating systems, fancy partitioning creates separate partitions for /, /boot, /home, /tmp, /usr, /var, /opt and swap. This ensures that if one file system gets corrupted, the rest of the data (the other file systems) stay intact, minimizing data loss. This has the disadvantage of subdividing the drive into small, fixed-size partitions, so, for instance, a user can fill up their /home partition and run out of useable hard drive space, even though other partitions still have plenty of free space. A good implementation requires the user to predict how much space each partition will need; sometimes a difficult task. Typical desktop systems use the other convention; a "/" (root) partition containing the entire filesystem and a separate swap partition.
List of partition utilities
- GNU Parted, fdisk, cfdisk
- Norton's PartitionMagic
- Mandrake's DiskDrake
- Acronis's DiskDirectorSuite
- TeraByte Unlimited's BootIt NG
See also
External links
- partitioning primer (http://www.ranish.com/part/primer.htm)
- EFI specifications at Intel (http://developer.intel.com/technology/efi/download.htm)
- QTParted, a partition manager (http://qtparted.sourceforge.net/).
- GParted, a partition manager (http://gparted.sourceforge.net/)
- GNU Parted, a command line partition manager (http://www.gnu.org/software/parted/parted.html)
- http://tldp.org/HOWTO/Partition/index.html
- Andries Brouwer's partition types list (http://www.win.tue.nl/~aeb/partitions/partition_types-1.html)
- operating system loader (http://www.xosl.org/)
- Minimal Partition Table Specification (http://www.win.tue.nl/~aeb/partitions/partition_tables.html)
- List of Partition Identifiers (http://www.win.tue.nl/~aeb/partitions/partition_types-1.html)
- Minimal partition table specification (http://www.win.tue.nl/~aeb/partitions/partition_tables.html)
- Linux Partition HOWTO (http://www.tldp.org/HOWTO/mini/Partition/index.html)
- EFI specifications at Intel (http://developer.intel.com/technology/efi/download.htm)de:Partition (Festplatte)
fr:Partition de disque dur nl:Partitie pl:Partycja (informatyka)