[ previous ] [ Contents ] [ 1 ] [ 2 ] [ 3 ] [ 4 ] [ 5 ] [ 6 ] [ 7 ] [ 8 ] [ 9 ] [ 10 ] [ 11 ] [ 12 ] [ next ]

Installing Debian GNU/Linux 3.0 For Intel x86
Chapter 6 - Partitioning for Debian


The ``Partition a Hard Disk'' menu item presents you with a list of disk drives you can partition, and runs a partitioning application. You must create at least one ``Linux native'' (type 83) disk partition, and you probably want at least one ``Linux swap'' (type 82) partition.


6.1 Deciding on Debian Partitions and Sizes

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 a separate 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 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 file system 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/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?


6.2 The Directory Tree

Debian GNU/Linux adheres to the Filesystem Hierarchy Standard for directory and file naming. This standard allows users and software programs to predict the location of files and directories. The root level directory is represented simply by the slash /. At the root level, all Debian systems include these directories:

            bin       Essential command binaries
            boot      Static files of the boot loader
            dev       Device files
            etc       Host-specific system configuration
            home      User home directories
            lib       Essential shared libraries and kernel modules
            mnt       Mount point for mounting a file system temporarily
            proc      Virtual directory for system information
            root      Home directory for the root user
            sbin      Essential system binaries
            tmp       Temporary files
            usr       Secondary hierarchy
            var       Variable data
            opt       Add-on application software packages

The following is a list of important considerations regarding directories and partitions.


6.3 PC Disk Limitations

The PC BIOS generally adds additional constraints for disk partitioning. There is a limit to how many ``primary'' and ``logical'' partitions a drive can contain. Additionally, with pre 1994-98 BIOS, there are limits to where on the drive the BIOS can boot from. More information can be found in the Linux Partition HOWTO and the Phoenix BIOS FAQ, but this section will include a brief overview to help you plan most situations.

``Primary'' partitions are the original partitioning scheme for PC disks. However, there can only be four of them. To get past this limitation, ``extended'' and ``logical'' partitions were invented. By setting one of your primary partitions as an extended partition, you can subdivide all the space allocated to that partition into logical partitions. You can create up to 60 logical partitions per extended partition; however, you can only have one extended partition per drive.

Linux limits the partitions per drive to 15 partitions for SCSI disks (3 usable primary partitions, 12 logical partitions), and 63 partitions on an IDE drive (3 usable primary partitions, 60 logical partitions). However the normal Debian GNU/Linux system provides only 20 devices for partitions, so you may not install on partitions higher than 20 unless you first manually create devices for those partitions.

If you have a large IDE disk, and are using neither LBA addressing, nor overlay drivers (sometimes provided by hard disk manufacturers), then the boot partition (the partition containing your kernel image) must be placed within the first 1024 cylinders of your hard drive (usually around 524 megabytes, without BIOS translation).

This restriction doesn't apply if you have a BIOS newer than around 1995-98 (depending on the manufacturer) that supports the ``Enhanced Disk Drive Support Specification''. Both Lilo, the Linux loader, and Debian's alternative mbr must use the BIOS to read the kernel from the disk into RAM. If the BIOS int 0x13 large disk access extensions are found to be present, they will be utilized. Otherwise, the legacy disk access interface is used as a fall-back, and it cannot be used to address any location on the disk higher than the 1023rd cylinder. Once Linux is booted, no matter what BIOS your computer has, these restrictions no longer apply, since Linux does not use the BIOS for disk access.

If you have a large disk, you might have to use cylinder translation techniques, which you can set from your BIOS setup program, such as LBA (Logical Block Addressing) or CHS translation mode (``Large''). More information about issues with large disks can be found in the Large Disk HOWTO. If you are using a cylinder translation scheme, and the BIOS does not support the large disk access extensions, then your boot partition has to fit within the translated representation of the 1024th cylinder.

The recommended way of accomplishing this is to create a small (5-10MB should suffice) partition at the beginning of the disk to be used as the boot partition, and then create whatever other partitions you wish to have, in the remaining area. This boot partition must be mounted on /boot, since that is the directory where the Linux kernel(s) will be stored. This configuration will work on any system, regardless of whether LBA or large disk CHS translation is used, and regardless of whether your BIOS supports the large disk access extensions.


6.4 Recommended Partitioning Scheme

For new users, personal Debian boxes, home systems, and other single-user setups, a single / partition (plus swap) is probably the easiest, simplest way to go. However, this might not be such a good idea when you have lots of disk capacity, e.g., 20GB or so. Ext2 partitions tend to perform poorly on file system integrity checking when they are larger than 6GB or so.

For multi-user systems or systems with lots of disk, it's best to put /usr, /var, /tmp, and /home each on their own partitions separate from the / partition.

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/mail a separate partition. Often, putting /tmp on its own partition, for instance 20 to 50MB, 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. 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.

On 32-bit architectures (i386, m68k, 32-bit SPARC, and PowerPC), the maximum size of a swap partition is 2GB (on Alpha and SPARC64, it's so large as to be virtually unlimited). This should be enough for nearly any installation. However, if your swap requirements are this high, you should probably try to spread the swap across different disks (also called ``spindles'') and, if possible, different SCSI or IDE channels. The kernel will balance swap usage between multiple swap partitions, giving better performance.

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.

For more examples, see Partitioning Strategies. For an idea of the space taken by tasks you might be interested in adding after your system installation is complete, check Disk Space Needed for Tasks, Section 11.4.


6.5 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 the drive models and/or capacities.

Linux represents the primary partitions as the drive name, plus the numbers 1 through 4. For example, the first primary partition on the first IDE drive is /dev/hda1. The logical partitions are numbered starting at 5, so the first logical partition on that same drive is /dev/hda5. Remember that the extended partition, that is, the primary partition holding the logical partitions, is not usable by itself. This applies to SCSI disks as well as IDE disks.


6.6 Debian Partitioning Programs

Several varieties of partitioning programs have been adapted by Debian developers to work on various types of hard disks and computer architectures. Following is a list of the program(s) applicable for your architecture.

fdisk
The original Linux disk partitioner, good for gurus; read the fdisk manual page.

Be careful if you have existing FreeBSD partitions on your machine. The installation kernels include support for these partitions, but the way that fdisk represents them (or not) can make the device names differ. See the Linux+FreeBSD HOWTO.

cfdisk
A simple-to-use, full-screen disk partitioner for the rest of us; read the cfdisk manual page.

Note that cfdisk doesn't understand FreeBSD partitions at all, and, again, device names may differ as a result.

One of these programs will be run by default when you select ``Partition a Hard Disk''. If the one which is run by default isn't the one you want, quit the partitioner, go to the shell (tty2) by pressing Alt and F2 keys together, and manually type in the name of the program you want to use (and arguments, if any). Then skip the ``Partition a Hard Disk'' step in dbootstrap and continue to the next step.

If you will be working with more than 20 partitions on your ide disk, you will need to create devices for partitions 21 and beyond. The next step of initializing the partition will fail unless a proper device is present. As an example, here are commands you can use in tty2 or under Execute A Shell to add a device so the 21st partition can be initialized:

     cd /dev
     mknod hda21 b 3 21 
     chgrp disk hda21
     chmod 660 hda21

Booting into the new system will fail unless proper devices are present on the target system. After installing the kernel and modules, execute:

     cd /target/dev
     mknod hda21 b 3 21 
     chgrp disk hda21
     chmod 660 hda21

Remember to mark your boot partition as ``Bootable''.


6.7 ``Initialize and Activate a Swap Partition''

This will be the next step once you have created disk partitions. You have the choice of initializing and activating a new swap partition, activating a previously-initialized one, or doing without a swap partition. It's always permissible to re-initialize a swap partition, so select ``Initialize and Activate a Swap Partition'' unless you are sure you know what you are doing.

This menu choice will first present you with a dialog box reading ``Please select the partition to activate as a swap device.''. The default device presented should be the swap partition you've already set up; if so, just press Enter.

Next, there is a confirmation message, since initialization destroys any data previously on the partition. If all is well, select ``Yes''. The screen will flash as the initialization program runs.

A swap partition is strongly recommended, but you can do without one if you insist, and if your system has more than 12MB RAM. If you wish to do this, please select the ``Do Without a Swap Partition'' item from the menu.


6.8 ``Initialize a Linux Partition''

At this point, the next menu item presented should be ``Initialize a Linux Partition''. If it isn't, it is because you haven't completed the disk partitioning process, or you haven't made one of the menu choices dealing with your swap partition.

You can initialize a Linux partition, or alternately you can mount a previously-initialized one. Note that dbootstrap will not upgrade an old system without destroying it. If you're upgrading, Debian can usually upgrade itself, and you won't need to use dbootstrap. For help on upgrading to Debian 3.0, see the upgrade instructions.

Thus, if you are using old disk partitions that are not empty, i.e., if you want to just throw away what is on them, you should initialize them (which erases all files). Moreover, you must initialize any partitions that you created in the disk partitioning step. About the only reason to mount a partition without initializing it at this point would be to mount a partition upon which you have already performed some part of the installation process using this same set of installation floppies.

Select ``Initialize a Linux Partition'' to initialize and mount the / disk partition. The first partition that you mount or initialize will be the one mounted as / (pronounced ``root'').

You will be asked whether to preserve ``Pre-2.2 Linux Kernel Compatibility?''. Saying ``No'' here means that you cannot run 2.0 or earlier Linux kernels on your system, since the file systems enable some features not supported in the 2.0 kernel. If you know you'll never need to run a 2.0 or earlier vintage kernel, then you can achieve some minor benefits by saying ``No'' here.

You will also be asked about whether to scan for bad blocks. The default here is to skip the bad block scan, since the scan can be time consuming, and modern disk drive controllers internally detect and deal with bad blocks. However, if you are at all unsure about the quality of your disk drive, or if you have a rather old system, you should probably do the bad block scan.

The next prompts are just confirmation steps. You will be asked to confirm your action, since initializing is destructive to any data on the partition, and you will be informed that the partition is being mounted as /, the root partition.[4]

Once you've mounted the / partition, if you have additional file systems that you wish to initialize and mount, you should use the ``Alternate'' menu item. This is for those who have created separate partitions for /boot, /var, /usr or others, which ought to be initialized and mounted at this time.


6.9 ``Mount a Previously-Initialized Partition''

An alternative to ``Initialize a Linux Partition'', Section 6.8 is the ``Mount a Previously-Initialized Partition'' step. Use this if you are resuming an installation that was broken off, or if you want to mount partitions that have already been initialized or have data on it which you wish to preserve.

If you are installing a diskless workstation, at this point, you want to NFS mount your root partition from the remote NFS server. Specify the path to the NFS server in standard NFS syntax, namely,

     server-name-or-IP:server-share-path

. If you need to mount additional file systems as well, you can do that at this time.

If you have not already set up your network as described in ``Configure the Network'', Section 7.7, then selecting an NFS install will prompt you to do so.


6.9.1 NFS Root Installation Workaround

Unfortunately, the woody release of boot-floppies does not support dpkg locking on NFS root installs. To work around this problem, take the following steps after mounting your target NFS share at /target. This example assumes installation from a CD, but it could just as well apply for installation from files placed on an NFS share and mounted at /instmnt (which is where the installer normally mounts installation media).

To enable NFS locking, make pre-arrangements to have this command sequence on the NFS share, or create it there using nano-tiny.

     #!/bin/sh
     mount /dev/hdc /instmnt  # substitute your cdrom device for /dev/hdc
     cd /target
     mkdir x
     cd x
     for i in g/glibc/libc6 t/tcp-wrappers/libwrap0 p/portmap/portmap n/nfs-utils/nfs-common
     do
       ar -x /instmnt/pool/main/$i''_*.deb
       zcat data.tar.gz | tar x
     done
     umount /instmnt
     mkdir -p /var/lib/nfs
     for i in portmap rpc.statd
     do
       LD_LIBRARY_PATH=lib sbin/$i
     done

Now install the base system as usual. Then install nfs-common:

     $ umount /instmnt
     $ chroot /target /bin/sh
     $ apt-cdrom add
     $ apt-get install nfs-common

The messages about missing /proc can be ignored, since portmap and statd are already running.

You'll need a kernel built with CONFIG_ROOT_NFS. The one on the installation CD isn't. If you don't have one and can't build one on another machine, you must build one right here in the chroot environment:

     $ apt-get install gcc make libc6-dev kernel-source-2.4.18 less screen links lynx wget ftp # etc.

When you've made arrangements to boot the new kernel, using the NFS share as root device, back out cleanly:

     $ exit # from chroot shell
     $ cd /
     $ killall portmap rpc.statd
     $ umount /target

Then reboot. If it fails, then boot the installation CD, mount the NFS share on /target, enable NFS locking, chroot /target, do what you forgot to do, back out cleanly, and reboot. If it fails, try again. Good luck.


6.10 Mounting Partitions Not Supported by dbootstrap

In some special situations, dbootstrap might not know how to mount your file systems (whether root or otherwise). It may be possible, if you're an experienced GNU/Linux user, to simply go to tty2 by pressing Alt and F2 keys together, and manually run the commands you need to run in order to mount the partition in question.

If you are mounting a root partition for your new system, just mount it to /target, the go back to dbootstrap and continue (perhaps running the ``View the Partition Table'' step to cause dbootstrap to re-compute where it is in the installation process.

For non-root partitions, you'll have to remember to manually modify your new fstab file so that when you reboot the partition will be mounted. Wait for that file (/target/etc/fstab) to be written by dbootstrap, of course, before editing it.


[ previous ] [ Contents ] [ 1 ] [ 2 ] [ 3 ] [ 4 ] [ 5 ] [ 6 ] [ 7 ] [ 8 ] [ 9 ] [ 10 ] [ 11 ] [ 12 ] [ next ]

Installing Debian GNU/Linux 3.0 For Intel x86

version 3.0.24, 18 December, 2002

Bruce Perens
Sven Rudolph
Igor Grobman
James Treacy
Adam Di Carlo