Abstract
A disk is physically divided into sectors. A sequence of sectors can form a partition. Roughly speaking, you can create as many partitions as you wish, up to 67 (3 primary partitions and a secondary partition containing up to 64 logical partitions inside): each partition is regarded as a single hard drive.
To simplify, a hard disk is merely a sequence of sectors, which are the smallest data unit on a hard disk. The typical size of a sector is 512 bytes. The sectors on a hard disk of “n” sectors are numbered from “0” to “n-1”.
The use of multiple partitions enables you to create many virtual hard drives on your real physical drive. This has many advantages:
Different operating systems use different disk structures (called file systems): this is the case with Windows® and GNU/Linux. Having multiple partitions on a hard drive also allows you to install various operating systems on the same physical drive.
For performance reasons, an operating system may
prefer different drives with various file systems on them because
they may be used for completely different things. One example is
GNU/Linux which requires a second partition called
Swap
. The latter is used by the virtual memory manager as
virtual memory.
Even if all of your partitions use the same file system, it may prove useful to separate the different parts of your OS into different partitions. A simple configuration example would be to split your files into two partitions: one for your personal data, and another one for your programs. This allows you to update your OS, completely erasing the partition containing the programs while keeping the data partition safe.
Because physical errors on a hard disk are generally located on adjacent sectors, not scattered across the disk, distributing your files across different partitions could limit data loss if your hard disk is physically damaged.
Normally, the partition type specifies the file system which the partition is supposed to contain. Each operating system might recognize some partition types, but not others. Please see Chapter 8, File Systems and Mount Points, and Chapter 9, The Linux File System, for more information.
This
scenario would imply only two partitions: one for the Swap
space, the other one for the files[2].
Separate
data from programs. To be even more efficient, one usually defines a
third partition called root
and labelled as
/
. It will contain the programs required to start
your system and to perform basic maintenance.
Therefore we could define four partitions:
A
Swap
partition whose size is roughly twice the size
of physical RAM.
/
The most important partition. Not only does it contain critical data and programs for the system, it also acts as a mount point for other partitions (see Chapter 8, File Systems and Mount Points).
The needs of the root partition in terms of size
are not great, 400MB is generally enough. However, if
you plan to install commercial applications, which are often
located in the /opt
directory, you will
need to increase the size of the root partition accordingly.
Alternatively, you could create a separate partition for
/opt
.
/usr
Most packages install the majority of their
executables and data files under the
/usr
directory. The advantage of
creating a separate partition is that it allows you to
easily share it with other machines over a
network.
The recommended size depends on the packages you wish to install, and can vary from 100MB for a very lightweight installation, to several GB for a full installation. A compromise of two or three GB (depending on your disk size) is usually sufficient.
/home
This directory contains the personal directories for all of the users hosted on your machine. The partition size depends on the number of users hosted and their needs.
Another solution is to not create a
separate partition for the /usr
files:
/usr
could simply be a directory inside the root
(/
) partition, however you would need to increase
the size of your root (/
) partition
accordingly.
Finally, you could also only create the Swap
and root
(/
) partitions, in case
you're not sure what you want to do with your computer. In this case,
your /home
directory would be located on the
root
partition, and so would the /usr
and /var
directories.
When setting up your machine for specific
uses –– such as a web server or a
firewall –– the needs are radically different
to that of a standard desktop machine. For example, a FTP
server will probably need a large separate partition for
/var/ftp
, while the
/usr
directory could be relatively
small. In these situations, you're encouraged to carefully
think about your needs before even beginning the installation
process.