is the creation of separate divisions of a hard disk drive
using partition editors
. Once a disk is divided into several partitions, directories and files of different categories may be stored in different partitions. More partitions provide more control but too many become cumbersome. The way space management, access permissions and directory searching are implemented depends upon the type of file system
installed on a partition. Careful consideration of the size of the partition is necessary as the ability to change the size depends on the file system
installed on the partition.
Purposes for partitioning:
- Separation of the operating system files from user files
- Having an area for operating system virtual memory swapping/paging
- Keeping frequently used programs and data near each other.
- Having cache and log files separate from other files. These can change size dynamically and rapidly, potentially making a file system full.
- Use of multi booting setups, which allow users to have more than one operating system on a single computer. For example, one could install Linux, Mac OS X, Microsoft Windows or others on different partitions of the same hard disk and have a choice of booting into any operating system (supported by the hardware) at power-up.
- Protecting or isolating files, to make it easier to recover a corrupted file system or operating system installation. If one partition is corrupted, none of the other file systems are affected, and the drive's data may still be salvageable. Having a separate partition for read-only data also reduces the chances of the file system on this partition becoming corrupted.
- Raising overall computer performance on systems where smaller file systems are more efficient. For instance, large hard drives with only one NTFS file system typically have a very large sequentially-accessed Master File Table (MFT) and it generally takes more time to read this MFT than the smaller MFTs of smaller partitions.
PC BIOS partition types
This section describes partitions as used in MS-DOS
, Microsoft Windows
on PC compatible
computer systems; for examples of partitioning schemes used in other operating systems, see Slice (disk)
and BSD disklabel
A PC hard disk can contain up to four partitions. Each of them can be a primary partition and at most one can be an extended one. All these partitions are described by 16-byte entries that constitute the Partition Table which is (normally) located in the Master Boot Record.
The "type" of a partition is identified by a 1-byte code found in its partition table entry. Some of these codes (such as 0x05 and 0x0F) may be used to indicate the presence of an extended partition, but most are used by operating systems that examine partition tables to decide if a partition contains a file system they can mount/access for reading or writing data.
Once a specific partition's type has been identified, additional information about its purpose and probable contents may be found (see: List of partition identifiers for PCs as one such resource). For example, some type codes are used to hide a partition's contents from various operating systems. However, if an OS or some partitioning tool has been programmed to also examine the boot sectors of any partition, then its file system may no longer remain hidden. (Note: There are no officially assigned partition types; thus, more than one kind of file system may lay claim to the same code value.)
Primary (or logical)
A primary (or logical) partition contains one file system. In MS-DOS
and earlier versions of Microsoft Windows
systems, the first partition (C:) must be a "primary partition". Other operating systems may not share this limitation; however, this can depend on other factors, such as a PC's BIOS
(see Boot sequence on standard PC
for more information).
The "partition type" code for a primary or logical partition can either correspond to a file system contained within (e.g. 0x07 means either an NTFS or an OS/2 HPFS file system) or indicate the partition has a special use (e.g. code 0xBC may mean an Acronis Secure Zone and code 0x82 usually indicates a Linux swap partition). The FAT16 and FAT32 file systems have made use of quite a number of partition type codes over time due to the limits of various DOS and Windows OS versions. Though a Linux operating system may recognize a number of different file systems (ext2, ext3, reiserfs, etc.), they have all consistently used the same partition type code: 0x83 (Linux native).
An extended partition is secondary to the primary partition(s). A hard disk may contain only one extended partition; which can then be sub-divided into logical drives
, each of which is (under DOS and Windows) assigned additional drive letters
For example, under either DOS or Windows, a hard disk with one primary partition and one extended partition, the latter containing two logical drives, would typically be assigned the three drive letters: C: for the primary partition, and D: and E: for the two logical drives.
See extended boot record for information on the structure of an extended partition.
Hard disks are sometimes compressed to create additional space. Under MS-DOS
and early Microsoft Windows, programs such as STACKER (DR-DOS except 6), SuperStor (DR-DOS 6), DoubleSpace
, or DriveSpace (Windows 95) were used. This compression was done by creating a very large file on the partition, then storing the disk's data in this file. At startup, device drivers opened this file and assigned it a separate letter. Frequently, to avoid confusion, the original partition and the compressed drive had their letters swapped, so that the compressed disk is C:, and the uncompressed area (often containing system files) is given a higher name. (SuperStor required a separate device driver to be loaded, DEVSWAP.COM).
Versions of Windows using the NT kernel, including the most recent versions, XP and Vista, contain intrinsic disk compression capability. The use of separate disk compression utilities has declined sharply.
DOS, OS/2, and Windows
With DOS, OS/2
, and Microsoft Windows
, the standard partitioning scheme is to create a single active primary partition, the C: drive, where the operating system, utilities, applications, user data, and page/swap file all reside. Some users, however, prefer to create multiple partitions so that the operating system can be stored separately from other kinds of data. Proponents of multiple partitions generally point to the benefit of being able to erase a single partition (typically the operating system itself) while retaining the other data. When used in conjunction with third-party partition management programs such as Acronis Disk Director
, Norton PartitionMagic
, Norton Ghost
, or specialized recovery programs that come with computers manufactured by most major manufacturers, the use of multiple partitions allows computer users to quickly recover from viruses
, and trojan horses
or an otherwise damaged, corrupt or compromised operating system.
Windows Vista includes an inbuilt 'Disk Management' program which allows for the creation, deletion and movement of partitions.
-based and Unix-like
operating systems such as Linux
and Mac OS X
, the creation of separate partitions for /boot, /home, /tmp, /usr, /var, /opt, swap
and all remaining files under the "/" (root directory
) is possible. (The same is true for Sun operating systems, except their partitions are called slices
.) Such a scheme has a number of potential advantages: if one file system
gets corrupted, the rest of the data (the other file systems) stay intact, minimizing data loss; partitions can be accessed read-only and the execution of setuid
files disabled thus enhancing security; performance may be enhanced due to less disk head travel. This method has the disadvantage of subdividing the drive into fixed-size partitions, so a user could run out of hard drive space in his or her /home
partition, even though other partitions still have plenty of usable space. A good implementation requires the user to predict how much space each partition will need, which may be a difficult task; especially for new users. Logical Volume Management
, often used in servers, increases flexibility by allowing data in volumes to expand into separate physical disks (which can be added when needed); another option is to resize existing partitions when necessary. Typical desktop systems are often comprised of a single "/" (root directory
) containing the entire filesystem plus a much smaller swap partition
. By default, Mac OS X systems use a single "/" (root directory
) containing the entire filesystem (including the swap file) as a point of simplicity (but other setup options do exist).
When a partition is deleted, in general, only its partition table entry is removed from a table; and although the data is no longer accessible, it still remains on the disk until being overwritten. Specialized recovery utilities, (such as TestDisk
), can locate lost
file systems and recreate a partition table which includes entries for these recovered file systems. However, some disk utilities may also overwrite a number of beginning sectors of a partition they delete. For example, if Windows Disk Management (Windows 2000/XP, etc.) is used to delete a partition, it will overwrite the first sector (relative sector 0) of the partition before removing it. It may be possible to restore a FAT32
partition if a backup boot sector is available.