Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions

  




 

 

Subsections


Partitioning Your Hard Drive

Before you install Debian on your computer, it is generally a good idea to plan how the contents of your hard drive will be arranged. One part of this process involves partitioning your hard drive.


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; after that, adding furniture to one room doesn't affect any other room.

If you already have an operating system on your system (Windows 95, Windows NT, DOS, etc.) and you want to install Debian GNU/Linux on the same disk, you will probably need to repartition the disk. In general, changing a partition that already has a filesystem on it will destroy any information in that filesystem. Therefore, 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 your furniture. Luckily, there is an alternative for some users; see section 2.3.6 on page [*] for more information.

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 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 filesystem, 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 the very least, 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 since the operating system needs to use real files (besides swap space) for many things. It may not even be a problem of local origin. For example, unsolicited e-mail (``spam'') can easily fill a partition. By using more partitions, you protect the system from many of these problems. Using e-mail as an example again, by putting the directory /var/spool/mail on its own partition, the bulk of the system will work even if unsolicited e-mail fills that partition.

Another reason applies only if you have a large IDE disk drive and are using neither LBA addressing nor overlay drivers2.2. In this case, you will have to put the root partition into the first 1,024 cylinders of your hard drive, usually around 524 megabytes. See section 2.3.3 on page [*] for more information on this issue.

Most people feel that a swap partition is also a necessity, although this isn't strictly true. ``Swap'' is scratch space for an operating system, which allows the system to use disk storage as ``virtual memory'' in addition to physical memory. Putting swap on a separate partition allows Linux to make much more efficient use of it. It is possible to force Linux to use a regular file as swap, but this is not recommended.

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, either you will 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 may be wasting space that could be used elsewhere.


Planning Use of the System

Disk space requirements and your partitioning scheme are influenced by the type of installation you decide to create.

For your convenience, Debian offers a number of default ``profiles'' some of which are listed later in this section. Profiles are simply preselected sets of packages designed to provide certain desired capabilities on your system. Installation is easier since packages that fit your desired profile are automatically marked for installation. Each given profile lists the 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 a stripped-down server, that 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 the size of the software; any data you serve would be additional.

Dialup.
This profile would be good for a standard desktop box, including the X Window system, graphics applications, sound, editors, etc. The size of the packages will be around 500MB.
Work_std.
This profile is suitable for a stripped-down user machine without the X Window system or X applications. It is also suitable for a laptop or mobile computer. The size is around 140MB. It is possible to have a simple laptop setup including X with less than 100MB.
Devel_comp.
This is a desktop setup profile with all the popular development packages, such as Perl, C, and C++. It requires around 475MB. Assuming you are adding X and some additional packages for other uses, you should plan for approximately 800MB of disk space for this type of installation.
Remember that these sizes don't include all the other materials that are normally 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 directory contains a lot of state information. The installed package management files can easily consume 20MB of disk space. In general, you should allocate at least 50MB for the /var directory because system log files are also stored there.


PC Disk Limitations

A 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, there are limits to where on the drive the BIOS looks for boot information. More information can be found in the Linux Partition mini-HOWTO. This section will include a brief overview to help you plan most situations.

``Primary'' partitions are the original partitioning scheme for PC hard disks. However, there can be only four of them. To get past this limitation, ``extended'' or ``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. The number of logical partitions you can create is much less limited than the number of primary partitions you can create; however, you can have only one extended partition per drive.

Linux limits the number of partitions per drive to 15 partitions for SCSI drives (3 usable primary partitions, 12 logical partitions), and 63 partitions for IDE drives (3 usable primary partitions, 60 logical partitions).

The last issue you need to know about a PC BIOS is that your boot partition - that is, the partition containing your kernel image - needs to be contained within the first 1,024 cylinders of the drive. Because the root partition is usually your boot partition, you need to make sure your root partition fits into the first 1,024 cylinders.

If you have a large disk, you may have to use cylinder translation techniques, which you can set in your BIOS, such as LBA translation mode. (More information about large disks can be found in the Large Disk mini-HOWTO.) If you are using a cylinder translation scheme, your boot partition must fit within the translated representation of cylinder 1,024.


Device Names in Linux

Linux disks and partition names may be different from those in other operating systems. You should know the names that Linux uses when you create and mount partitions. The basic scheme can be found in Table 2.1 on page [*].

Table 2.1: Linux Device Names

Device Linux Name
First floppy drive /dev/fd0
Second floppy drive /dev/fd1
First partition on /dev/hda (typically C: in other OSs) /dev/hda1
Fifth partition on /dev/hdc /dev/hdc5
Second partition on /dev/sdb /dev/sdb2
Entire Primary-Master IDE hard disk or CD-ROM /dev/hda
Entire Primary-Slave IDE hard disk or CD-ROM /dev/hdb
Entire Secondary-Master IDE hard disk or CD-ROM /dev/hdc
Entire Secondary-Slave IDE hard disk or CD-ROM /dev/hdd
First SCSI disk /dev/sda
Second and remaining SCSI disks /dev/sdb and so forth
First serial port (COM1 in other OSs) /dev/ttyS0
Second, third, etc. serial ports /dev/ttyS1, /dev/ttyS2, etc.
SCSI tape units (automatic rewind) /dev/st0, /dev/st1, etc.
SCSI tape units (no automatic rewind) /dev/nst0, /dev/nst1, etc.
SCSI CD-ROMs /dev/scd0, /dev/scd1, etc.


The partitions on each disk are represented by appending a number to the disk name. For example, the names hda1 and hda2 represent the first and second partitions of the first IDE disk drive in your system. Linux represents the primary partitions with 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 drives as well as IDE drives.

Let's assume you have a system with two 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 three 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.


Recommended Partitioning Scheme

As described above, you should have a separate smaller root partition and a larger /usr partition if you have the space. For most users, the two partitions initially mentioned are sufficient. This is especially appropriate when you have a single small disk, because creating 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 may need to make /var/spool/mail a separate partition. Putting /tmp on its own 20 to 32MB partition, for instance, 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 to store user home directories. 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. It contains in-depth information, mostly of interest to people setting up servers.

Swap partition sizes should also be considered. There are many views about swap partition sizes. One rule of thumb that 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 10,000 simultaneous equations on a machine with 256MB of memory, you may need a gigabyte (or more) of swap space.

As an example, consider a machine that 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. A 32MB swap partition is used on /dev/hda3 and the rest, about 1.2GB, on /dev/hda2 is the Linux partition.

Partitioning Prior to Installation

There are two different times that you can partition: prior to or during the installation of Debian. If your computer will be solely dedicated to Debian you should partition during installation as described in section 3.5 on page [*]. If you have a machine with more than one operating system on it, you should generally let the other operating system create its own partitions.

The following sections contain information regarding partitioning in your native operating system prior to Debian installation. Note that you'll have to map between how the other operating system names partitions and how Linux names partitions; see Table 2.1 on page [*].

Partitioning from DOS or Windows

If you are manipulating existing FAT or NTFS partitions, it is recommended that you use either 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.


Lossless Repartitioning

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 section 2.3.1 on page [*], 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 divide up the disk. The method in this section will only split a partition into two pieces. One will contain the original operating system, and the other will be used for Debian. During the installation of Debian, you will be given the opportunity to use the 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 you need is a copy of FIPS, which is available in the tools directory on your Debian CD-ROM. This disk must be bootable. Under DOS, a bootable floppy can be created using the command sys a: for a previously formatted floppy or format a: /s for an unformatted floppy. Unzip the archive and copy the files RESTORRB.EXE, FIPS.EXE and ERRORS.TXT to the bootable floppy. FIPS comes with very good documentation that you may want to read. You should definitely read the documentation if you use a disk compression driver or a disk manager. Create the disk and read the documentation before you continue.

The next thing to be done is to move all the data to the beginning of the partition. 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 also work. Note that if you have Windows 95 or higher, you must run DEFRAG from there, because DOS doesn't understand VFAT, which is used to support long filenames in Windows 95 and higher.

After running the defragmenter (which can take a while on a large disk), reboot with the FIPS floppy disk you created. Simply type a:\ fips and follow the directions.

Note that there are many other other partition managers out there, in case FIPS doesn't work for you.

Debian Installation Steps

As you initially install Debian, you will proceed through several different steps:

  1. Boot the installation system
  2. Initial system configuration
  3. Install the base system
  4. Boot the newly installed base system
  5. Install the rest of the system
Booting the Debian installation system, the first step, is generally done with the Rescue Floppy or from the CD-ROM.

Once you've booted into Linux, the dbootstrap program will launch and guide you through the second step, the initial system configuration. This step is described in detail in section 3 on page [*].

The ``Debian base system'' is a core set of packages that are required to run Debian in a minimal, stand-alone fashion. dbootstrap will install it from your CD-ROM, as described in section 3.12 on page [*]. Once you have configured and installed the base system, your machine can ``stand on its own.''

The final step is the installation of the remainder of the Debian system. This would include the applications and documents that you actually use on your computer, such as the X Window system, editors, shells, and development environments. The rest of the Debian system can be installed from CD-ROM. At this point, you'll be using the standard Debian package management tools, such as dselect. This step is described in section 3.20 on page [*].

John Goerzen / Ossama Othman

 
 
  Published under the terms of the GNU General Public License Design by Interspire