Partition Planning

Before partitioning a disk drive, plan exactly how you want it partitioned. To do this properly, you need to understand what partitions are and why they are used. If you have a Unix background, this is probably something you understand well, but if you're coming from a Microsoft background, an explanation is probably needed.

Despite the fact that the DOS partitioning program and the Linux partitioning program share the same name (fdisk), the concept of partitioning for these two operating systems is subtly different. The DOS fdisk program divides a large disk drive into smaller logical drives. Using fdisk, for example, the C drive might become both C and D. Each of these logical drives has it own root filesystem, and looks to the operating system and to the user as if they are physically separate devices. Conceptually, the DOS fdisk command is used to divide things.

On the other hand, the Linux fdisk command is part of a system that unifies things. Linux (and all other Unix-like operating systems) unifies all of the physical disk drives under a single root. Instead of seeing a separate device or partition as a logical drive (C or D), the user sees the partition as a directory in the filesystem, such as /home.

The directory to which a device or partition is "attached" is called a mount point. This term springs from the fact that Unix has been around for a long time. Back in the dark ages, a computer operator had to manually mount a "disk pack" on the spindle in the disk drive assembly. Disk packs are no longer used, but the flexibility of mounting and dismounting physical devices to directories within the filesystem lives on in the mount and umount commands.

The partition table you create is written directly to the disk drive. The mount points and the partitions that are mapped to them are written to the /etc/fstab file from where they are read during the boot process, and mounted using a mount -a command. The mount command is covered in detail in Chapter 9.

The philosophy of the DOS and Linux filesystems may be different, but the ultimate purpose of partitioning is the same. Partitions keep incompatible data separated, and they divide a large storage space into pieces that are more manageable and can be more effectively used. At a minimum, Linux requires two partitions: a swap partition and a root partition.

Most administrators use more than two partitions. Providing a partition to hold user files and another to hold the operating system software is an example of what administrators do to organize and manage their disk space. Table A.1 lists the most common partitions and describes the purpose of each.

Table A.1: Common Partitions

Partition Name



Required. It holds the swap space for the operating system.

root (/)

Required. The root is the foundation of the entire filesystem.


Some distributions place the boot files in a separate directory so that a boot partition can be created separate from the root partition.


The usr partition contains most of the system software.


The home partition contains all of the user home directories and almost all of the user files.


The var directory holds all the printer spool files, the mail files, the news file, and the system log files.


The opt directory holds optional software. Some third-party software packages assume that the /opt directory is available, and install themselves there by default.

Swap Partitions

Swap Partitions

The swap partition is needed to provide swap space for the operating system. Linux, like all Unix operating systems, uses virtual memory. In other words, it uses disk storage as an extension of the RAM memory. Inactive processes are swapped out of memory and held on disk whenever the RAM they occupy is needed by an active process.

The disk drive, and therefore swapping, is very slow. You want to design your server to avoid swapping to the greatest extent possible. If you need more memory, add more RAM—not more swap space. Swap space should be needed only for spikes of activity that temporarily create an unusually large number of processes.

The swap space should be twice the size of real memory; however, the less real memory available to your machine, the more important swap space becomes. For systems with 256MB or less memory, you should always plan for a swap partition twice as large as memory. If the memory is greater than 256MB, a swap space that is the same size as the memory might be adequate for your server.

Additionally, if you have disks on multiple controllers, you can speed up swap access by having a small swap partition on each disk rather than just one big one. For example, assume that you want 512MB of swap space and you have four disks; you could create a swap partition of 128MB on each disk. Linux will automatically round-robin between them all, resulting in faster access times.

Root Partitions

Planning the swap partition is easy: You should have one, and it will probably be twice the size of real memory. Planning the other partitions takes a little more thought. There are two basic schools of thought on partitioning: one school says to take all of the remaining disk space and create one large root partition, and the other says to create several carefully-sized partitions. Each school of thought has some merit.

The main advantage of creating a single large root partition is that it is easy. It also avoids the "root file system full" error that occurs when /tmp or /opt grow too large. If the entire disk is dedicated to the root directory, you won't have a full root filesystem until the entire disk really is full of data.

The problem with this approach is that it is too easy. It doesn't take the variability and load of a server into account. It works fine for a single-user client system with a single disk drive, but a server environment is more complex:

• A server usually has more than one disk drive. A single partition cannot span multiple disk drives.

• A server supports many users. The /home directory holds the files for these users, and often grows very large.

A single partition is simply not flexible nor reliable enough for a server. Placing all files in the root partition reduces the reliability of that critical partition by increasing the chance that the partition may become corrupted.

The root partition is critical because it contains the files necessary to boot the system. Some Linux distributions consider this important enough to place the critical boot files in /boot so that a separate partition can be created just for them. Additionally, placing the critical boot files in a separate /boot partition creates a partition that is small enough to place almost anywhere on the disk. If either the Workstation or Server installation classes are selected on a Red Hat system, a /boot partition is created. The Workstation installation class creates a swap partition, a /boot partition, and a root partition. This is a slight variation on the "single large root" partition scheme. The server installation class creates a swap partition, a /boot partition, a root partition, a /usr partition, a /home partition, and a /var partition. Although different Linux vendors recommend different partitioning schemes, they all recommend more than one partition for a server.

A Basic Server Partitioning Scheme

It is possible to create too many partitions. This creates a confusing structure, and can waste space. The Red Hat server installation class provides a reasonable example of partitioning for a server. A basic partition structure for multiuser, multidisk server based on the Red Hat scheme is

• A swap partition that is twice the size of real memory.

• A /var partition of 300MB. Create a /var/tmp directory, and symbolically link /tmp to it. The size of the /var partition can vary greatly, depending on the number of users who leave their mail on the server, and whether or not the server is a news server. Network news consumes an enormous amount of space—many gigabytes every day. If this is the enterprise news server, you need a larger /var partition. However, if the users don't store mail on the server and it isn't the news server, a separate /var partition is not needed at all. A 300MB /var partition is adequate for most departmental servers, particularly if the growth of log and spool files is closely monitored.

• A /usr partition of 3GB. Create a /usr/local directory to contain local software. Create a /usr/ opt directory, and symbolically link /opt to it. 3GB is adequate for the Linux software, but if you plan to install lots of large third-party software packages, you may need a /usr partition that is twice as large.

• User data is placed in the /home directory. If you have multiple disk drives specifically to hold user data, create a /home/userl partition encompassing the remainder of the first disk drive, a /home/user2 partition encompassing the entire second disk drive, and so on. Segmenting the directory in this way allows it to span multiple disks.

Tip To simplify the pathnames for the users and to simplify moving users between physical disks, create a small /home partition on the first disk that contains only symbolic links to the users' real home directories that reside on other disks. User accounts are covered in Chapter 3, "Login Services."

Symbolic Links

In Linux, directories can be "linked" together by creating a pointer from one directory to another. These pointers are called symbolic links. Use the ln command to create symbolic links. For example, to create a "directory" named /opt that links to the real directory /usr/opt, enter ln -s /usr/opt /opt

After this symbolic link is created, references to the link /opt have a corresponding effect on the directory /usr/opt. An ls of /opt lists the directory contents of /usr/opt. A file stored in /opt is really stored in /usr/opt. Symbolic links increase the flexibility of the Linux filesystem.

No suggestions from anyone, no matter how experienced, can take the place of your own judgment. You know what you want to do with your server, you know how many people it will serve, and you know the tasks it will perform. Use this knowledge to plan your partitions.

After you have developed a partition plan, you need to write the partition scheme onto the hard disk. Red Hat provides two tools to do this: the widely used Linux fdisk program and the Red Hat program Disk Druid.

Was this article helpful?

0 0

Post a comment