After you have obtained a distribution of Linux, you're ready to prepare your system for installation. This takes a certain degree of planning, especially if you're already running other operating systems. In the following sections, we'll describe how to plan for the Linux installation.
While each release of Linux is different, in general the method used to install the software is as follows:
Repartition your hard drive(s). If you have other operating systems already installed, you will need to repartition the drives in order to allocate space for Linux. This is discussed in the section "Section 2.2.4, "Repartitioning Your Drives"" later in this chapter. In some distributions, this step is integrated into the installation procedure. Check the documentation of your distribution to see whether this is the case. Still, it won't hurt you to follow the steps given here and repartition your hard drive in advance.
Boot the Linux installation media. Each distribution of Linux has some kind of installation media--usually a "boot floppy"--or a bootable CD-ROM that is used to install the software. Booting this media will either present you with some kind of installation program, which will step you through the Linux installation, or allow you to install the software by hand.
Create Linux partitions. After repartitioning to allocate space for Linux, you create Linux partitions on that empty space. This is accomplished with the Linux fdisk program, covered in the section "Section 3.1.3, "Creating Linux Partitions"" in Chapter 3, "Installation and Initial Configuration" or some other distribution-specific program like the Disk Druid that comes with Red Hat Linux.
Create filesystems and swap space. At this point, you will create one or more filesystems, used to store files, on the newly created partitions. In addition, if you plan to use swap space, you will create the swap space on one of your Linux partitions. This is covered in the sections "Section 3.1.4, "Creating Swap Space"" and "Section 3.1.5, "Creating the Filesystems"," both in Chapter 3, "Installation and Initial Configuration".
Install the software on the new filesystems. Finally, you will install the Linux software on your newly created filesystems. After this, if all goes well, it's smooth sailing. This is covered in the section "Section 3.1.6, "Installing the Software"" in Chapter 3, "Installation and Initial Configuration". Later, in the section "Section 3.3, "Running Into Trouble"," also in Chapter 3, "Installation and Initial Configuration", we describe what to do if anything goes wrong.
People who want to switch back and forth between different operating systems sometimes wonder which to install first: Linux or the other system? We can testify that some people have had trouble installing Windows 95 after Linux. Windows 95 tends to wipe out existing boot information when it's installed, so you're safer installing it first and then installing Linux afterward using the information in this chapter.
We don't know whether Windows 98 will demonstrate the same cavalier behavior as Windows 95. Windows NT seems to be more tolerant of existing boot information.
Many distributions of Linux provide an installation program, that will step you through the installation process and automate one or more of the previous steps for you. Keep in mind throughout this chapter and the next that any number of the previous steps may be automated for you, depending on the distribution.
Important hint: While preparing to install Linux, the best advice we can give is to take notes during the entire procedure. Write down everything you do, everything you type, and everything you see that might be out of the ordinary. The idea here is simple: if (or when!) you run into trouble, you want to be able to retrace your steps and find out what went wrong. Installing Linux isn't difficult, but there are many details to remember. You want to have a record of all these details so that you can experiment with other methods if something goes wrong. Also, keeping a notebook of your Linux installation experience is useful when you want to ask other people for help, for example, when posting a message to one of the Linux-related Usenet groups. Your notebook is also something you'll want to show to your grandchildren someday.[13]
[13]Matt shamefully admits that he kept a notebook of all of his tribulations with Linux for the first few months of working with the system. It is now gathering dust on his bookshelf.
In general, hard drives are divided into partitions, where one or more partitions are devoted to an operating system. For example, on one hard drive, you may have several separate partitions--one devoted to, say, Windows, another to OS/2, and another two to Linux.
If you already have other software installed on your system, you may need to resize those partitions in order to free up space for Linux. You will then create one or more Linux partitions on the resulting free space for storing the Linux software and swap space. We call this process repartitioning.
Many MS-DOS systems utilize a single partition inhabiting the entire drive. To MS-DOS, this partition is known as C:. If you have more than one partition, MS-DOS names them D:, E:, and so on. In a way, each partition acts like a separate hard drive.
On the first sector of the disk is a master boot record along with a partition table. The boot record (as the name implies) is used to boot the system. The partition table contains information about the locations and sizes of your partitions.
There are three kinds of partitions: primary, extended, and logical. Of these, primary partitions are used most often. However, because of a limit on the size of the partition table, you can only have four primary partitions on any given drive. This is due to the poor design of MS-DOS; even other operating systems of the same era do not have such limits.
The way around this four-partition limit is to use an extended partition. An extended partition doesn't hold any data by itself; instead, it acts as a "container" for logical partitions. Therefore, you could create one extended partition, covering the entire drive, and within it create many logical partitions. However, you may have only one extended partition per drive.
Before we explain how to repartition your drives, you need an idea of how much space you will be allocating for Linux. We will be discussing how to create these partitions later, in the section "Section 3.1.3, "Creating Linux Partitions"" in Chapter 3, "Installation and Initial Configuration".
On Unix systems, files are stored on a filesystem, which is essentially a section of the hard drive (or other medium, such as CD-ROM or floppy) formatted to hold files. Each filesystem is associated with a specific part of the directory tree; for example, on many systems, there is a filesystem for all the files in the directory /usr, another for /tmp, and so on. The root filesystem is the primary filesystem, which corresponds to the topmost directory, /.
Under Linux, each filesystem lives on a separate partition on the hard drive. For instance, if you have a filesystem for / and another for /usr, you will need two partitions to hold the two filesystems.
Before you install Linux, you will need to prepare filesystems for storing the Linux software. You must have at least one filesystem (the root filesystem), and therefore one partition, allocated to Linux. Many Linux users opt to store all their files on the root filesystem, which, in most cases, is easier to manage than several filesystems and partitions.
However, you may create multiple filesystems for Linux if you wish--for example, you may want to use separate filesystems for /usr and /home. Those readers with Unix system administration experience will know how to use multiple filesystems creatively. In the section "Section 6.1.4, "Creating Filesystems"" in Chapter 6, "Managing Filesystems, Swap, and Devices", we discuss the use of multiple partitions and filesystems.
Why use more than one filesystem? The most commonly stated reason is safety; if, for some reason, one of your filesystems is damaged, the others will (usually) be unharmed. On the other hand, if you store all your files on the root filesystem, and for some reason the filesystem is damaged, you may lose all your files in one fell swoop. This is, however, rather uncommon; if you back up the system regularly, you should be quite safe.[14]
[14]Matt uses a single 200-MB filesystem for all his Linux files and hasn't had any problems (so far).
On the other hand, using several filesystems has the advantage that you can easily upgrade your system without endangering your own precious data. You might have a partition for the users' home directories, and when upgrading the system, you leave this partition alone, wipe out the others, and reinstall Linux from scratch. Of course, nowadays distributions all have quite elaborate update procedures, but from time to time, you might want a "fresh start."
Another reason to use multiple filesystems is to divvy up storage among multiple hard drives. If you have, say, 100 MB free on one hard drive, and 2 GB free on another, you might want to create a 100-MB root filesystem on the first drive and a 2-GB /usr filesystem on the other. Currently it is not possible for a single filesystem to span multiple drives; if your free hard drive storage is fragmented between drives, you need to use multiple filesystems to use all the storage.
In summary, Linux requires at least one partition, for the root filesystem. If you wish to create multiple filesystems, you need a separate partition for each additional filesystem. Some distributions of Linux automatically create partitions and filesystems for you, so you may not need to worry about these issues at all.
Another issue to consider when planning your partitions is swap space. You have two options. The first is to use a swap file that exists on one of your Linux filesystems. You will create the swap file for use as virtual RAM after you install the software. The second option is to create a swap partition, an individual partition to be used only as swap space. Most people use a swap partition instead of a swap file.
A single swap file or partition may be up to 128 MB (more with the latest kernels).[15] If you wish to use more than 128 MB of swap (hardly ever necessary), you can create multiple swap partitions or files--up to 16 in all. For example, if you need 256 MB of swap, you can create two 128-MB swap partitions.
[15]This value applies to machines with Intel processors. On other architectures like the Alpha, it can be higher.
Setting up a swap partition is covered in the section "Section 3.1.4, "Creating Swap Space"" in Chapter 3, "Installation and Initial Configuration", and setting up a swap file in the section "Section 6.2, "Managing Swap Space"" in Chapter 6, "Managing Filesystems, Swap, and Devices".
Therefore, in general, you will create at least two partitions for Linux: one for use as the root filesystem, and the other for use as swap space. There are, of course, many variations on partitioning, but this is the minimal setup. You are not required to use swap space with Linux, but if you have less than 32 MB of physical RAM, it is strongly suggested that you do.
Of course, you need to know how much space these partitions will require. The size of your Linux filesystems (containing the software itself) depends greatly on how much software you're installing and what distribution of Linux you are using. Hopefully, the documentation that came with your distribution will give you an approximation of the space requirements. A small Linux system can use 40 MB or less; a larger system anywhere from 100 to 300 MB, or more. Keep in mind that in addition to the space required by the software itself, you need to allocate extra space for user directories, room for future expansion, and so forth.
If you use several partitions, you can use a rather small partition for the root directory. 32 MB should suffice--use at least 30-50 MB more if you keep /var on the same partition, as most people do. On the other hand, you will probably want to have a largish /usr partition.
The size of your swap partition (should you elect to use one) depends on how much virtual RAM you require. A rule of thumb is to use a swap partition that is twice the space of your physical RAM; for example, if you have 4 MB of physical RAM, an 8-MB swap partition should suffice. Of course, this is mere speculation; the actual amount of swap space you require depends on the software you will be running. If you have a great deal of physical RAM (say, 64 MB or more), you may not wish to use swap space at all.
Because of BIOS limitations, it is usually not possible to boot from partitions using cylinders numbered over 1023. Therefore, when setting aside space for Linux, keep in mind you may not want to use a partition in the over-1023 cylinder range for your Linux root filesystem. Linux can still use partitions with cylinders numbered over 1023, but you may not be able to boot Linux from such a partition. This advice may seem premature, but it is important to know when planning your drive layout, and today, many people have large disks with more than 1023 cylinders.
If you absolutely must use a partition with cylinders numbered over 1023 for your Linux root filesystem, you can always boot Linux from floppy. This is not so bad, actually; it takes only a few seconds longer to boot than from the hard drive. At any rate, it's always an option.
In this section, we'll describe how to resize your current partitions (if any) to make space for Linux. If you are installing Linux on a "clean" hard drive, skip this section and proceed to Chapter 3, "Installation and Initial Configuration".
The usual way to resize an existing partition is to delete it (thus destroying all data on that partition) and recreate it. Before repartitioning your drives, back up your system. After resizing the partitions, you can reinstall your original software from the backup. However, there are several programs available for MS-DOS that resize partitions nondestructively. One of these is known as FIPS and can be found on many Linux FTP sites.
Also, keep in mind that because you'll be shrinking your original partitions, you may not have space to reinstall everything. In this case, you need to delete enough unwanted software to allow the rest to fit on the smaller partitions.
The program used to repartition is known as fdisk. Each operating system has its own analogue of this program; for example, under MS-DOS, it is invoked with the FDISK command. You should consult your documentation for whatever operating systems you are currently running for information on repartitioning. Here, we'll discuss how to resize partitions for MS-DOS using fdisk, but this information should be easily extrapolated to other operating systems.
The fdisk program (on any operating system) is responsible for reading the partition table on a given drive and manipulating it to add or delete partitions. However, some versions of fdisk do more than this, such as adding information to the beginning of a new partition to make it usable by a certain operating system. For this reason, you should usually only create partitions for an operating system with the version of fdisk that comes with it. You can't create MS-DOS partitions with Linux fdisk; partitions created in this way can't be used correctly by MS-DOS (actually, if you really know what you are doing, you might be lucky in creating MS-DOS partitions from Linux, but we would not advise doing so). Similarly, MS-DOS fdisk may not be able to recognize Linux partitions. As long as you have a version of fdisk for each operating system you use, you should be fine. (Note that not all systems name this program fdisk; some refer to it as a "disk manager" or "volume manager.")
Later, in the section "Section 3.1.3, "Creating Linux Partitions"" in Chapter 3, "Installation and Initial Configuration", we describe how to create new Linux partitions, but for now we are concerned with resizing your current ones.
Please consult the documentation for your current operating systems before repartitioning your drive. This section is meant to be a general overview of the process; there are many subtleties we do not cover here. You can lose all the software on your system if you do not repartition the drive correctly.
Let's say that you have a single hard drive on your system, currently devoted entirely to MS-DOS. Hence, your drive consists of a single MS-DOS partition, commonly known as C:. Because this repartitioning method will destroy the data on that partition, you need to create a bootable MS-DOS "system disk," which contains everything necessary to run FDISK and restore the software from backup after the repartitioning is complete.
In many cases, you can use the MS-DOS installation disks for this purpose. However, if you need to create your own system disk, format a floppy with the command:
Copy onto this floppy all necessary MS-DOS utilities (usually most of the software in the directory \DOS on your drive), as well as the programs FORMAT.COM and FDISK.EXE. You should now be able to boot this floppy and run the command:FORMAT /s A:
to start up FDISK.FDISK C:
Use of FDISK should be self-explanatory, but consult the MS-DOS documentation for details. When you start FDISK, use the menu option to display the partition table, and write down the information displayed there. It is important to keep a record of your original setup in case you want to back out of the Linux installation.
To delete an existing partition, choose the FDISK menu option "Delete an MS-DOS Partition or Logical DOS Drive." Specify the type of partition you wish to delete (primary, extended, or logical) and the number of the partition. Verify all of the warnings. Poof!
To create a new (smaller) partition for MS-DOS, choose the FDISK option "Create an MS-DOS Partition or Logical DOS Drive." Specify the type of partition (primary, extended, or logical) and the size of the partition to create (specified in megabytes). FDISK should create the partition, and you're ready to roll.
After you're done using FDISK, exit the program and reformat any new partitions. For example, if you resized the first DOS partition on your drive (C:), you should run the command:
You may now reinstall your original software from backup.FORMAT /s C:
Copyright © 2001 O'Reilly & Associates. All rights reserved.
This HTML Help has been published using the chm2web software. |