[ previous ] [ Abstract ] [ Copyright Notice ] [ Contents ] [ next ]

Installing Debian GNU/Linux 2.1 For Alpha - Chapter 4
Partitioning Your Hard Drive


4.1 Background

Partitioning your disk simply refers to the act of breaking up your disk into sections. Each section is then independent of the others. It's roughly equivalent to putting up walls in a house; if you add furniture to one room it doesn't affect any other room.

If you already have an operating system on your system (Windows95, Windows NT, OS/2, MacOS, Solaris, FreeBSD) and want to stick Linux on the same disk, you will probably need to repartition the disk. In general, changing a partition with a filesystem already on it will destroy any information there. Thus you should always make backups before doing any repartitioning. Using the analogy of the house, you would probably want to move all the furniture out of the way before moving a wall or you risk destroying it.

At a bare minimum, GNU/Linux needs one partition for itself. You can have a single partition containing the entire operating system, applications, and your personal files. Most people feel that the swap partition is also a necessity, although it's not strictly true. ``Swap'' is scratch space for an operating system, which allows the system to use cheap disk storage as ``virtual memory''. By putting swap on a separate partition, Linux can make much more efficient use of it. It is possible to force Linux to use a regular file as swap, but it is not recommended.

Most people choose to give GNU/Linux more than the minimum number of partitions, however. There are two reasons you might want to break up the filesystem into a number of smaller partitions. The first is for safety. If something happens to corrupt the file system, generally only one partition is affected. Thus, you only have to replace (from the backups you've been carefully keeping) a portion of your system. At a bare minimum, you should consider creating what is commonly called a ``root partition''. This contains the most essential components of the system. If any other partitions get corrupted, you can still boot into GNU/Linux to fix the system. This can save you the trouble of having to reinstall the system from scratch.

The second reason is generally more important in a business setting, but it really depends on your use of the machine. Suppose something runs out of control and starts eating disk space. If the process causing the problem happens to have root privileges (the system keeps a percentage of the disk away from users), you could suddenly find yourself out of disk space. This is not good as the OS needs to use real files (besides swap space) for many things. It may not even be a problem of local origin. For example, getting spammed with e-mail can easily fill a partition. By using more partitions, you protect the system from many of these problems. Using mail as an example again, by putting /var/spool/mail on its own partition, the bulk of the system will work even if you get spammed.

The only real drawback to using more partitions is that it is often difficult to know in advance what your needs will be. If you make a partition too small then you will either have to reinstall the system or you will be constantly moving things around to make room in the undersized partition. On the other hand, if you make the partition too big, you will be wasting space that could be used elsewhere. Disk space is cheap nowadays, but why throw your money away?


4.2 Planning Use of the System

It is important to decide what type of machine you are creating. This will determine disk space requirements and affect your partitioning scheme.

There are a number of default ``Profiles'' which Debian offers for your convenience (see Select and Install Profiles, Section 7.20). Profiles are simply sets of package selections which make it easier for you, in that a number of packages are automatically marked for installation.

Each given profile has a size of the resulting system after installation is complete. Even if you don't use these profiles, this discussion is important for planning, since it will give you a sense of how large your partition or partitions need to be.

The following are some of the available profiles and their sizes:

Server_std
This is a small server profile, useful for stripped down server which does not have a lot of niceties for shell users. It basically has an FTP server, a web server, DNS, NIS, and POP. It will take up around 50MB. Of course, this is just size of the software; any data you serve up would be additional.

Dialup
A standard desktop box, including the X window system, graphics applications, sound, editors, etc. Size of the packages will be around 500MB.

Work_std
A more stripped-down user machine, without the X window system or X applications. Possibly suitable for a laptop or mobile computer. The size is around 140MB. (Note that the author has a pretty simple laptop setup including X11 in even less, around 100MB).

Devel_comp
A desktop setup with all the development packages, such as Perl, C, C++, etc. Size is around 475MB. Assuming you are adding X11 and some additional packages for other uses, you should plan around 800MB for this type of machine.

Remember that these sizes don't include all the other materials which are usually to be found, such as user files, mail, and data. It is always best to be generous when considering the space for your own files and data. Notably, the Debian /var partition contains a lot of state information. The dpkg files (with information on all installed packages) can easily consume 20MB; with logs and the rest, you should usually allocate at least 50MB for /var.


4.3 Device Names in Linux

Linux disks and partition names may be different from other operating systems. You need to know the names that Linux uses when you create and mount partitions. Here's the basic naming scheme:

The partitions on each disk are represented by appending a decimal number to the disk name: ``sda1'' and ``sda2'' represent the first and second partitions of the first SCSI disk drive in your system.

Here is a real-life example. Let's assume you have a system with 2 SCSI disks, one at SCSI address 2 and the other at SCSI address 4. The first disk (at address 2) is then named ``sda'', and the second ``sdb''. If the ``sda'' drive has 3 partitions on it, these will be named ``sda1'', ``sda2'', and ``sda3''. The same applies to the ``sdb'' disk and its partitions.

Note that if you have two SCSI host bus adapters (i.e., controllers), the order of the drives can get confusing. The best solution in this case is to watch the boot messages, assuming you know yourself the drive models.


4.4 Recommended Partitioning Scheme

As described above, you should definitely have a separate smaller root partition, and a larger /usr partition, if you have the space. For examples, see below. For most users, the two partitions initially mentioned are sufficient. This is especially appropriate when you have a single small disk, since breaking out lots of partitions can waste space.

In some cases, you might need a separate /usr/local partition if you plan to install many programs that are not part of the Debian distribution. If your machine will be a mail server, you might need to make /var/spool/mail a separate partition. Often, putting /tmp on its own partition, for instance 20 to 32MB, is a good idea. If you are setting up a server with lots of user accounts, it's generally good to have a separate, large /home partition. In general, the partitioning situation varies from computer to computer depending on its uses.

For very complex systems, you should see the Multi Disk HOWTO. This contains in-depth information, mostly of interest to ISPs and people setting up servers.

With respect to the issue of swap partition size, there are many views. One rule of thumb which works well is to use as much swap as you have system memory, although there probably isn't much point in going over 64MB of swap for most users. It also shouldn't be smaller than 16MB, in most cases. Of course, there are exceptions to these rules. If you are trying to solve 10000 simultaneous equations on a machine with 256MB of memory, you may need a gigabyte (or more) of swap.

Note that Linux for your architecture will not use more than 512 megabytes of swap on a single swap partition. However, you can make multiple swap partitions by hand and edit /etc/fstab after you've installed to get more than 512 megabytes of swap. If your swap requirements are this high, however, you should probably try to spread the swap across different disks (also called ``spindles''). Or you can try the more recent Linux kernels (2.2 and higher) where this limitation was relaxed (be careful, it may require other changes in your system).


4.5 Example Partitioning

As an example, one of the authors' home machine has 32MB of RAM and a 1.7GB IDE drive on /dev/hda. There is a 500MB partition for another operating system on /dev/hda1 (should have made it 200MB as it never gets used). A 32MB swap partition is used on /dev/hda3 and the rest (about 1.2GB on /dev/hda2) is the Linux partition.


4.6 Partitioning Prior to Installation

There are two different times that you can partition: prior to the installation of Debian, or during installation of Debian. If your computer will be solely dedicated to Debian, you should partition as part of the boot process (``Partition a Hard Disk'', Section 7.6). If you have a machine with more than one operating system on it, you generally should let the native operating system create it's own partitions.

The following sections contain information regarding partitioning in your native operating system prior to installation. Note that you'll have to map between how the other operating system names partitions, and how Linux names partitions; see Device Names in Linux, Section 4.3.


[ previous ] [ Abstract ] [ Copyright Notice ] [ Contents ] [ next ]
Installing Debian GNU/Linux 2.1 For Alpha
version 2.1.11, 28 August, 1999
Bruce Perens
Sven Rudolph
Igor Grobman
James Treacy
Adam Di Carlo