Tips for Disk Partitioning

The x86 PC supports a method of dividing disk space into several segments, known as partitions. Partitions can be used to separate different OSs' files from one another, or to divide a single OS's files into logical groups. In Linux and other UNIX-like OSs, partitions are used for several reasons:

Chapter 5

• Security Placing critical files on separate partitions can give you fine control over mount options that can influence how users can access the partitions' files. For example, you can mount a partition that contains critical files (such as system software files) as read-only to prevent users from writing to the filesystem even in the event of an error in a directory's permissions.

• Protection from runaway file creation Sometimes a program creates a file or files that are much larger than expected. For example, if you operate your own mail server, and if some inconsiderate or malicious individual sends a 1GB email message, that file could end up consuming a huge amount of disk space—possibly enough to overrun your available disk space and cause problems in other programs. If you split critical directories into separate partitions, you can reduce the damage such an overrun can cause, thus keeping the system mostly operational. The downside is that each partition is smaller than it would be otherwise, so you're more likely to encounter a problem as the disk space consumption rises.

• Protection from filesystem damage Disk errors are a fact of life. When an error damages a disk partition, you're better off if that partition holds only a fraction of your data. In the event of a complete and unrecoverable error, a single small partition can be easier and quicker to restore than a larger partition containing all your data. In the event of a non-catastrophic error, a small partition is usually quicker to check for errors than is a large partition.

• Speed Particularly if you have more than one hard disk, creating separate partitions can improve your system's speed, by spreading disk accesses across two hard disks. I cover this aspect of disk partitioning later in this chapter in the section titled "Using Multiple Disks for Better Performance."

• Easier system upgrades When you want to upgrade your Linux system, it's sometimes desirable to completely wipe your existing installation and start again. When you do so, it's easier if your users' home directories—and perhaps directories containing programs that aren't part of the OS itself—reside on separate partitions. That way, you can leave those partitions alone, completely wipe the Linux partitions, and install a new version of the OS.

On the other hand, creating many partitions has its downside, as well:

• Uncertainties about partition size Unless you're an experienced administrator, it can be difficult to judge how large to make each partition. A wrong guess can cause a great 5

deal of trouble as you resize partitions or use symbolic links and strange directory structures to get around the problem. A

• Reduced performance If you lay out partitions on the disk in a less-than-optimal ° order, you can hinder your overall disk speed. S

Part II

• Reduced ability to create hard links A hard link is a way to create two directory entries that point to the same file. Such links can only exist when both directory entries are on the same partition as the file in question. You can, however, create a symbolic link from one partition to another. Symbolic links operate more slowly than do hard links.

If you're new to Linux, I recommend you make do with just two to four of the following partitions:

The swap partition sion area for RAM.

The swap partition, which I describe shortly, serves as an expan-

The root (/) partition All Linux distributions require a root filesystem, and this resides on a hard disk partition. All other partitions are mounted at some point on the root partition, or on a partition that is itself mounted on the root partition or another partition. Figure 5.1 illustrates this integrated directory tree structure.

Figure 5.1

Linux allows you to mount a partition at almost any location in its unified directory tree.

Figure 5.1

Linux allows you to mount a partition at almost any location in its unified directory tree.

Chapter 5

• A /home partition Most Linux distributions place user files in a directory called /home; each user has a subdirectory under this / home directory. For instance, in Figure 5.1, each of six users has a subdirectory in which to store files. Isolating user files from the rest of the OS is one of the best uses of partitioning, because it provides some of the greatest benefits. Also, most new administrators find it easier to estimate space required for user files as opposed to space required for various subdirectories in the Linux directory tree.

• A /usr/local partition Traditionally, /usr/local is used for programs you build yourself, as opposed to installing from a pre-built package file. These files are therefore customized for your local installation. It's common to want to keep these files when you upgrade your OS, so putting them on a separate partition makes sense.

Note

Figure 5.1 shows /usr/local mounted onto a separate/usr partition. This arrangement isn't required, however; /usr/local can mount directly onto the root partition. Figure 5.1 is drawn the way it is to illustrate the fact that partitions can mount onto partitions other than the root partition, and to illustrate the desirability of a separate /usr partition for more advanced administrators.

If you've used Linux before and want to create a more advanced configuration, you might want to consider creating additional partitions for one or more of the following directories:

• /usr The /usr directory contains many program and configuration files. In fact, the bulk of a Linux distribution resides in the /usr directory.

• /usr/XllR6 This directory contains files related to X, including the X server and most X programs.

• /opt Many recent third-party programs have taken to installing in /opt by default. It can be a good candidate for splitting into a separate partition for many of the same reasons /usr/local is. Some people prefer to create one partition for both /opt and /usr/local, and have one be a symbolic link to a subdirectory in the other.

• /var The /var directory stores operating files for a variety of system tools and servers. For instance, most Linux systems store operating logs in /var/log and print jobs are typically stored in /var/spool/lpd until they can be printed. Mail and news servers also store files in this directory tree. Systems that function primarily as servers for these protocols often benefit by separating this directory into a separate partition.

Part II

• /tmp Linux programs typically store temporary files in the /tmp directory. Using a separate partition for this directory can protect the rest of the OS from problems should a program create a temporary file that's too large.

• /boot Many Linux distributions place the Linux kernel in the /boot directory. If your hard disk has more than 1024 cylinders (as do all hard drives of more than 8GB capacity), it can be convenient to create a small (~5-20MB) /boot partition that resides near the beginning of the hard disk. In this way, you can be sure you can boot even from a large hard disk and when the rest of Linux falls partly or completely above the 1024-cylinder limit.

• Other OS partitions If your computer hosts both Linux and some other OS or OSs, you can create mount points specifically to access files from those OSs. For instance, you might create a /win2k partition to access Windows 2000 files, and a /beos partition to access BeOS files.

Even advanced Linux administrators probably don't want to create all the partitions I've outlined here, although some might. Most administrators use somewhere between two and six partitions, plus a swap partition, and find this to be quite adequate.

Was this article helpful?

0 0
The Ultimate Computer Repair Guide

The Ultimate Computer Repair Guide

Read how to maintain and repair any desktop and laptop computer. This Ebook has articles with photos and videos that show detailed step by step pc repair and maintenance procedures. There are many links to online videos that explain how you can build, maintain, speed up, clean, and repair your computer yourself. Put the money that you were going to pay the PC Tech in your own pocket.

Get My Free Ebook


Post a comment