LINFO

Partition Definition



A partition is a logical division on a hard disk drive (HDD).

HDDs are the main storage device on most computers. Storage refers to devices or media that can retain data for relatively long periods of time, in contrast with memory, whose contents can be accessed (i.e., read and written to) at extremely high speeds but which are retained only temporarily (i.e., while in use or only as long as the power supply remains on).

The desired number and sizes of partitions can be easily created on a HDD during the installation of an operating system. New partitions can also be created after the operating system has been installed by using available free space (i.e., space that has not yet been partitioned) or by erasing existing partitions to create free space.

An operating system can be installed on a single, unpartitioned HDD, and this is often done with the Microsoft Windows operating systems. However, the ability to divide a HDD into multiple partitions offers some important advantages. They include:

(1) A way for a single HDD to contain multiple multiple operating systems. Although there are other ways to provide multiple operating systems on a single computer, such as by having multiple HDDs, it is often the most convenient and/or economical to have them all on the same HDD.

(2) The ability to encapsulate data. Because filesystem corruption is local to a partition, the ability to have multiple partitions makes it likely that only some data will be lost if one partition becomes damaged. It also allows the contents of one partition to be reinstalled without affecting the contents of other partitions. For example, if the operating system becomes corrupted and needs to be reinstalled, having data on one or more separate partition means that the data on those partitions will not be affected during reinstallation of the operating system.

(3) Some filesystems (e.g., old versions of the Microsoft FAT filesystem) have size limits that are far smaller than modern HDDs. Thus, multiple filesystems make it possible to use more of the HDD.

(4) Prevent runaway processes (i.e., instances of programs in execution) and overgrown log (and other) files from consuming all the spare space on the HDD and thus making the entire HDD, and consequently the entire computer, unusable. Separate partitions ensure that such processes and files will limit their total disk space consumption to individual partitions at most.

(5) Simplify the backing up of data. Partition sizes can be made sufficiently small that they fit completely on one unit of backup medium for a daily or other periodic backup.

(6) Increase disk space efficiency. Partitions can be formatted with varying block sizes, depending on usage. If the data is in a large number of small files (less than one kilobyte each) and the partition uses 4KB sized blocks, 3KB is being wasted for every file. In general, an average of one half of a block is wasted for every file, and thus matching block size to the average size of the files is important if there are numerous files.

There are several constraints on partitions: (1) they cannot overlap, as this would cause data corruption and other problems, (2) they cannot be moved, although they can be resized and copied and (3) there should be no gap between adjacent partitions, because gaps waste disk space. Disks need not be partitioned completely; that is, unpartitioned space can be left at the end of a disk and thus be available for partitioning at a later date if desired.

Although partitions are logically independent, they become logically connected when they are mounted (i.e., attached to the main filesystem). This can be accomplished automatically when the system is booted (i.e., started up), or it can be performed manually by using the mount command.

On Microsoft operating systems (i.e., MS-DOS and the various Windows systems) each HDD and each of its partitions as well as each other storage device is designated by a drive letter (which consists of an upper case letter followed by a colon). The first partition on the first HDD is always represented by C:, and subsequent letters such as D: and E: are used to represent other partitions on the same and other HDDs and other storage devices, such as CDROM and USB key drives.

There are several ways that information about partitions can be obtained on Linux and other Unix-like operating systems. Perhaps the easiest is to use df command, although this shows only those partitions that are currently mounted. It is particularly convenient to use this command with its -h (i.e., human readable) option, i.e.,

df -h

fdisk, which is located in the /sbin directory, is a more powerful command that not only shows all of the partitions on the system (not only just those currently mounted), but which also can be used to change them. Thus it can be dangerous (e.g., render a system inoperable and cause data loss), and, consequently, on most systems only the root account (i.e., administrative user) is permitted to use it.

On systems in which an ordinary user is permitted to become the root user, such as a home computer, the switch to root can be accomplished easily using the su command. Then fdisk can be used to access the desired HDD, with the first HDD designated by /dev/hda, the second designated by /dev/hdb (for a computer which has a second HDD), etc. Thus, the following would access the first HDD:

/sbin/fdisk /dev/hda

The partition table for the designated HDD can then be viewed by typing the letter p and pressing the ENTER key. Typing the letter m provides a menu of commands.






Created February 15, 2006. Updated November 8, 2006.
Copyright © 2006 The Linux Information Project. All Rights Reserved.