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. Luckily, there is an alternative for some users; see Lossless Repartitioning When Starting From DOS, Win-32 or OS/2, Section 4.7.
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 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
/var/spool/mail on its own partition, the bulk of the
system will work even if you get spammed.
Another reason applies to you only if you have a large IDE disk, and are using neither LBA addressing, overlay drivers (sometimes provided by hard disk manufacturers), nor a new (post 1998) BIOS that supports large disk access extensions. In this case, you will have to put the boot partition into the first 1024 cylinders of your hard drive (usually around 524 megabytes, without BIOS translation).
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?
The following list describes some important directories. It should help you to find out what your partitioning scheme should be. If this is too confusing for you, just ignore it and reread it when you read the rest of the installation manual.
/: root represents the starting point of the directory hierarchy. It contains the essential programs that the computer can boot. This includes the kernel, system libraries, configuration files in
/etcand various other needed files. Typically 30-50 MB are needed but this may vary.
Note: do not partition
/dev as its own
partition; you won't be able to boot.
/dev: this directory contains the various device files which are interfaces to the various hardware components. For more information see Device Names in Linux, Section 4.3.
/usr: all user programs (
/usr/bin), libraries (
/usr/lib), documentation (
/usr/share/doc), etc., are in this directory. This part of the filesystem needs most of the space. You should provide at least 500 MB of disk space. If you want to install more packages you should increase the amount of space you give this directory.
/home: every user will put his data into a subdirectory of this directory. The size of this depends on how many users will be using the system and what files are to be stored in their directories. Depending on your planned usage you should reserve about 100 MB for each user, but adapt this value to your needs.
/var: all variable data like news articles, e-mails, websites, APT's cache, etc. will be placed under this directory. The size of this directory depends greatly on the usage of your computer, but for most people will be dictated by the package management tool's overhead. If you are going to do a full installation of just about everything Debian has to offer, all in one session, setting aside 2 or 3 gigabytes of space for
/varshould be sufficient. If you are going to install in pieces (that is to say, install services and utilities, followed by text stuff, then X, ...), you can get away with 300 - 500 megabytes of in
/var. If harddrive space is at a premium and you don't plan on using APT, at least not for major updates, you can get by with as little as 30 or 40 megabytes in
/tmp: if a program creates temporary data it will most likely go in
/tmp. 20-50 MB should be usually enough.
It is important to decide what type of machine you are creating. This will determine disk space requirements and affect your partitioning scheme.
Debian offers the
tasksel tool to assist the user during
installation. (see Simple
Package Selection -- The Task Installer, Section 7.29). Tasks are
collections of packages which are automatically marked for installation as a
group, to implement a given type of Linux installation. Checking the sizes of
various tasks will give you a sense of how large your partition or partitions
need to be for your intended usage.
Link to a page dynamically generated using current tasksel to list tasks with associated sizes. Delete following outdated list.
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,
/var partition contains a lot of state information.
dpkg files (with information on all installed packages) can
easily consume 20 MB; with logs and the rest, you should usually allocate at
least 50 MB for
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
HOWTO and the
FAQ, but this section will include a brief overview to help you plan
``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).
The last issue about the PC BIOS which you need to know is that your boot
partition, that is, the partition containing your kernel image, needs to be
contained within the first 1024 cylinders of the drive, unless 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 fallback, 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
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-10 MB 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.
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.
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
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.
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 32 MB, 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
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 64 MB of swap for most users. It also shouldn't be smaller than 16 MB, in most cases. Of course, there are exceptions to these rules. If you are trying to solve 10000 simultaneous equations on a machine with 256 MB 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 2 GB (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 32 MB of RAM and a 1.7 GB
IDE drive on
/dev/hda. There is a 500 MB partition for another
operating system on
/dev/hda1 (should have made it 200 MB as it
never gets used). A 32 MB swap partition is used on
the rest (about 1.2 GB on
/dev/hda2) is the Linux partition.
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 installation 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 its 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.
If you are manipulating existing FAT or NTFS partitions, it is recommended that you either use the scheme below or native Windows or DOS tools. Otherwise, it is not really necessary to partition from DOS or Windows; the Linux partitioning tools will generally do a better job.
One of the most common installations is onto a system that already contains DOS (including Windows 3.1), Win32 (such as Windows 95, 98, NT), or OS/2, and it is desired to put Debian onto the same disk without destroying the previous system. As explained in the Background, Section 4.1, decreasing the size of an existing partition will almost certainly damage the data on that partition unless certain precautions are taken. The method described here, while not guaranteed to protect your data, works extremely well in practice. As a precaution, you should make a backup.
Before going any further, you should have decided how you will be dividing up the disk. The method in this section will only split a partition into two pieces. One will contain the original OS and the other will be used for Debian. During the installation of Debian, you will be given the opportunity to use Debian portion of the disk as you see fit, i.e., as swap or as a filesystem.
The idea is to move all the data on the partition to the beginning, before changing the partition information, so that nothing will be lost. It is important that you do as little as possible between the data movement and repartitioning to minimize the chance of a file being written near the end of the partition as this will decrease the amount of space you can take from the partition.
The first thing needed is a copy of
fips which is available in the
tools/ directory on your nearest Debian mirror. Unzip the archive
and copy the files
ERRORS.TXT to a bootable floppy. A bootable floppy can be created
using the command sys a: under DOS.
fips comes with
very good documentation which you may want to read. You will definitely need
to read the documentation if you use a disk compression driver or a disk
manager. Create the disk and read the documentation before you
defragment the disk.
The next thing needed is to move all the data to the beginning of the
defrag, which comes standard with DOS 6.0 and later
can easily do the job. See the
fips documentation for a list of
other software that may do the trick. Note that if you have Windows 95, you
defrag from there, since DOS doesn't understand VFAT,
which is used to support for long filenames, used in Windows 95 and higher.
After running the defragmenter (which can take a while on a large disk), reboot
fips disk you created in the floppy drive. Simply type
a:\fips and follow the directions.
Note that there are many other other partition managers out there, in case
fips doesn't do the trick for you.
If you are partitioning for DOS drives, or changing the size of DOS partitions,
using Linux tools, many people experience problems working with the resulting
FAT partitions. For instance, some have reported slow performance, consistent
scandisk, or other weird errors in DOS or Windows.
Apparently, whenever you create or resize a partition for DOS use, it's a good
idea to fill the first few sectors with zeros. Do this prior to running DOS's
format command, from Linux:
dd if=/dev/zero of=/dev/hdXX bs=512 count=4
Installing Debian GNU/Linux 2.2 For Intel x86version 2.2.27, 14 Listopad, 2001