|The Linux System Administrator's Guide: Version 0.7|
|Prev||Chapter 6. Using Disks and Other Storage Media||Next|
It is not easy to partition a disk in the best possible way. Worse, there is no universally correct way to do it; there are too many factors involved.
The traditional way is to have a (relatively) small root filesystem, which contains /bin, /etc, /dev, /lib, /tmp, and other stuff that is needed to get the system up and running. This way, the root filesystem (in its own partition or on its own disk) is all that is needed to bring up the system. The reasoning is that if the root filesystem is small and is not heavily used, it is less likely to become corrupt when the system crashes, and you will therefore find it easier to fix any problems caused by the crash. Then you create separate partitions or use separate disks for the directory tree below /usr, the users' home directories (often under /home), and the swap space. Separating the home directories (with the users' files) in their own partition makes backups easier, since it is usually not necessary to backup programs (which reside below /usr). In a networked environment it is also possible to share /usr among several machines (e.g., by using NFS), thereby reducing the total disk space required by several tens or hundreds of megabytes times the number of machines.
The problem with having many partitions is that it splits the total amount of free disk space into many small pieces. Nowadays, when disks and (hopefully) operating systems are more reliable, many people prefer to have just one partition that holds all their files. On the other hand, it can be less painful to back up (and restore) a small partition.
For a small hard disk (assuming you don't do kernel development), the best way to go is probably to have just one partition. For large hard disks, it is probably better to have a few large partitions, just in case something does go wrong. (Note that `small' and `large' are used in a relative sense here; your needs for disk space decide what the threshold is.)
If you have several disks, you might wish to have the root filesystem (including /usr) on one, and the users' home directories on another.
It is a good idea to be prepared to experiment a bit with different partitioning schemes (over time, not just while first installing the system). This is a bit of work, since it essentially requires you to install the system from scratch several times  , but it is the only way to be sure you do it right.
The Linux distribution you install will give some indication of how much disk space you need for various configurations. Programs installed separately may also do the same. This will help you plan your disk space usage, but you should prepare for the future and reserve some extra space for things you will notice later that you need.
The amount you need for user files depends on what your users wish to do. Most people seem to need as much space for their files as possible, but the amount they will live happily with varies a lot. Some people do only light text processing and will survive nicely with a few megabytes, others do heavy image processing and will need gigabytes.
By the way, when comparing file sizes given in kilobytes or megabytes and disk space given in megabytes, it can be important to know that the two units can be different. Some disk manufacturers like to pretend that a kilobyte is 1000 bytes and a megabyte is 1000 kilobytes, while all the rest of the computing world uses 1024 for both factors. Therefore, my 345 MB hard disk was really a 330 MB hard disk.
Swap space allocation is discussed in Section 7.5.
I used to have a 109 MB hard disk. Now I am using a 330 MB hard disk. I'll explain how and why I partitioned those disks.
The 109 MB disk I partitioned in a lot of ways, when my needs and the operating systems I used changed; I'll explain two typical scenarios. First, I used to run MS-DOS together with Linux. For that, I needed about 20 MB of hard disk, or just enough to have MS-DOS, a C compiler, an editor, a few other utilities, the program I was working on, and enough free disk space to not feel claustrophobic. For Linux, I had a 10 MB swap partition, and the rest, or 79 MB, was a single partition with all the files I had under Linux. I experimented with having separate root, /usr, and /home partitions, but there was never enough free disk space in one piece to do much interesting.
When I didn't need MS-DOS anymore, I repartitioned the disk so that I had a 12 MB swap partition, and again had the rest as a single filesystem.
The 330 MB disk is partitioned into several partitions, like this:
|5 MB||root filesystem|
|10 MB||swap partition|
|180 MB||/usr filesystem|
|120 MB||/home filesystem|
|15 MB||scratch partition|
Adding more disk space for Linux is easy, at least after the hardware has been properly installed (the hardware installation is outside the scope of this book). You format it if necessary, then create the partitions and filesystem as described above, and add the proper lines to /etc/fstab so that it is mounted automatically.
The best tip for saving disk space is to avoid installing unnecessary programs. Most Linux distributions have an option to install only part of the packages they contain, and by analysing your needs you might notice that you don't need most of them. This will help save a lot of disk space, since many programs are quite large. Even if you do need a particular package or program, you might not need all of it. For example, some on-line documentation might be unnecessary, as might some of the Elisp files for GNU Emacs, some of the fonts for X11, or some of the libraries for programming.
If you cannot uninstall packages, you might look into compression. Compression programs such as gzip or zip will compress (and uncompress) individual files or groups of files. The gzexe system will compress and uncompress programs invisibly to the user (unused programs are compressed, then uncompressed as they are used). The experimental DouBle system will compress all files in a filesystem, invisibly to the programs that use them. (If you are familiar with products such as Stacker for MS-DOS or DriveSpace for Windows, the principle is the same.)
This is not actually true, it is possible to move partitions and mountpoints without reinstalling, but it is (currently) beyond the scope of this book to explain how. It is on the TODO list to write a section on this. If you have experience and knowledge in this area then perhaps you could write it for me and save me the bother? :)
This section is somewhat out of date. Most people these days have disks that stretch into the multiple Gigabytes. It is still quite scalable (just multiply by some factor to make it fit your hardware) for the moment though, updating it to take account of larger disks is planned.