Наши партнеры

Книги по Linux (с отзывами читателей)

Библиотека сайта rus-linux.net

Linux System Administrator's Survival Guide lsg03.htm

Previous Page TOC Next Page

Chapter 3

Installing and Updating Linux

You probably already have installed Linux. Even so, you may not be happy with the installation, either because of poor organization or because you were experimenting with it and would like to try again with a better configuration. This chapter discusses the issues you should address when you install Linux for the first time (or reinstall it, as the case may be) and how to update your existing Linux installation with new software releases.

The process for installing Linux is straightforward, although lots of little potential problems are scattered throughout the process. Don't believe the easy installation claims on many packages of the distribution software! Several steps require patience, experimentation, and a knowledge of what is going on before Linux will install painlessly. The essential steps for installing Linux are as follows:

  1. Create boot and root disks for Linux.

  2. Partition the hard disk.

  3. Boot Linux from a floppy disk.

  4. Create a swap file partition.

  5. Create a Linux filesystem.

  6. Install the Linux software.

  7. Configure the kernel.

  8. Set the boot process.

  9. Reboot into Linux from your hard disk.

This chapter covers each of these steps in more detail. The process is very similar for installing from a CD-ROM and from a floppy disk (which may have come from an FTP site, for example). Because CD-ROM is the most common form of installation, this chapter uses that process as an example.

If you are installing from floppy disks and have downloaded the distribution files (or copied them from a CD-ROM), you will need a DOS-formatted floppy disk for each file in the distribution disk set. You can use standard DOS COPY commands to copy the disk set files to the floppy disks, using one floppy for each file in the distribution set. The files are all numbered so you know which floppy disk is in which set, and what their order should be.

Creating Boot and Root Disks

Even if you are installing from CD-ROM, you need two high-capacity floppy disks (either 1.2M or 1.44M). These disks are the boot and root floppy disks. The boot floppy disk holds the kernel that is used to start Linux the first time, leading to your installation. The root floppy disk holds a small filesystem that includes utilities needed for the installation. The two disks together form a complete and very small implementation of Linux. Enough of a system is on the two floppy disks to play with Linux, although many of the utilities are missing.

In most cases, the boot and root floppy disks are copied from existing files called images. The image is a precompiled version of the system that you duplicate on the floppy disks, eliminating the need to start from scratch. CD-ROM and FTP distributions have directories for several boot and root images, depending on the hardware on your system. You must select the images that match your hardware as much as possible, copy them to the floppy disks, and start your system with the floppy disks. You can do most of these steps from DOS, although you can't use the DOS COPY command to create the boot and root floppy disks. You must create the floppy disks with a utility that ignores the DOS formatting. This utility, commonly called RAWRITE.EXE, is included with most Linux software distributions.

Selecting a Boot Kernel and Root Image

CD-ROMs usually have directories under the root directory called bootdsks.144 and rootdsks.144 (for 3.5-inch 1.44M floppy disks) and bootdsks.12 and rootdsks.12 (for 5.25-inch 1.2M floppy disks), which contain the boot and root images, respectively. To find these directories, run DOS either from a floppy disk or a partition on your hard disk to examine the CD-ROM. The boot and root directories for 1.44M floppy disks from a typical CD-ROM Linux distribution are shown in Figure 3.1. If you are copying your files from an FTP site, you can select the boot and root images you need while connected to the remote FTP machine and transfer only the images you need to your local machine.

Figure 3.1
The boot and root directory entries for 1.44M floppy disk images, which are used to create the boot and root floppy disks needed to install Linux.

The types of boot kernels usually available are described in a file in the kernel image directories (usually called README, READ.ME, or WHICH.ONE). The boot kernel images are named to reflect the hardware for which they have drivers installed into the kernel. For example, the scsi kernel image has drivers in the kernel for SCSI-based systems; if you are on a PC that has a SCSI controller, hard disk, and CD-ROM, this is the image you want to copy to your boot floppy disk. The number of boot images available is quite large. These are the primary images available from most CD-ROMs and FTP sites and the hardware they are designed to handle:

aztech IDE and SCSI hard disk drivers, and Aztech non-IDE CD-ROM support, including Aztech, Okana, Orchid, and Wearnes non-IDE CD-ROM drives
bare IDE hard disk drivers only (no CD-ROM support)
cdu31a IDE and SCSI hard disk drivers, with a Sony CDU31 or Sony CDU33a CD-ROM drive
cdu535 IDE and SCSI hard disk drivers, with a Sony 535 or Sony 531 CD-ROM drive
idecd IDE and SCSI hard disk drivers, with IDE or ATAPI CD-ROM drive
mitsumi IDE and SCSI hard disk drivers, with a Mitsumi CD-ROM drive
net IDE hard disk drivers and Ethernet network card drivers
sbpcd IDE and SCSI hard disk drivers with Sound Blaster Pro or Panasonic CD-ROM drivers. This image is for CD-ROM drives run off a Sound Blaster card (as supplied in many Sound Blaster multimedia kits).
scsi IDE and SCSI hard drivers with SCSI peripherals (CD-ROM drives)
scsinet1 IDE and SCSI hard disk drivers, SCSI CD-ROM driver, and Ethernet drivers for networking. The SCSI drivers support Adaptec 152X, 1542, 1740, 274x, and 284x adapters, Buslogic adapters, EATA-DMA adapters (such as DPT, NEC, and AT&T cards), Seagate ST-02 adapters, and Future Domain TCC-8xx and 16xx adapters. SCSI adapters compatible with any of these cards will also work.
scsinet2 IDE and SCSI hard disk drivers, SCSI CD-ROM driver, and Ethernet drivers for networking. The SCSI drivers support NCR5380-based adapters, NCR 53C7 and 8xx adapters, Always IN2000 adapter, Pro Audio Spectrum 16 adapter, Qlogic adapter, Trantor T128, T128F, and T228 adapters, Ultrastor adapters, and the 7000 FASST adapters. Compatibles of any of these cards should also work.
xt IDE and IBM PC-XT-compatible hard disk drivers

With some distributions, an extension is added to the kernel image name to indicate the floppy disk type. For example, if the kernel image is for a 1.44M floppy disk, it will have the filetype .144 as part of the name. Similarly, a filetype of .12 indicates a 1.2M image. You cannot interchange these images, or the diskette will be useless (in other words you cannot load a .12 image onto a 1.44M diskette). Most distributions don't bother with this convention, since the files are in the appropriate directories for the floppy disk size.

You have fewer choices for the root floppy image. Most distributions include four basic images, although a few more esoteric images also appear from time to time. Each of the root images has the disk size as part of its name (color144 and color12, for example). The basic root floppy images are the following:

  • The color image offers a full-screen color-based installation script for installing Linux.

  • The tape image is designed to support Linux installation from a cartridge tape. This kernel has limited functionality and depends on the type of tape drive used. Typically, QIC drives are supported, but users of some models have reported problems.

  • The tty image is a dumb terminal installation version with no color or graphics.

  • The umsdos image is used to install UMSDOS, which allows you to install Linux into an existing MS-DOS partition. The installation script creates the subdirectories it needs. UMSDOS is not as efficient or fast as a dedicated Linux partition, but you can retain your current disk partitions.

<NOTE>The color root image is a lot more attractive than the tty image and can make the Linux installation a bit friendlier. The color image is intolerant of typing errors and doesn't always proceed smoothly, however. It's worth a try, in most cases, unless you know exactly how you want to install Linux. The color process tends to require much more user interaction, including clicking OK buttons at many stages.<NOTE>

Once you have determined which of the boot and root images you will use (if you are not sure, pick the boot image that most closely matches your hardware configuration and the color or tty root image), you can create the boot and root floppy disks. If you choose the boot and root images incorrectly, don't worry. All that will happen is that you won't be able to install Linux, and you'll have to start the process again.

Creating the Boot and Root Floppy Disks

You can create the boot and root floppy disks either from DOS or from UNIX (or Linux). If you don't run DOS yet, and don't have a DOS boot disk, you will have to use another machine to create the two floppy disks. Because creating the floppy disk from DOS is the most common method, this section deals with this method first.

To create the boot and root floppy disks, you must use a utility program to write the image to floppy disk. If you obtained your boot and root images from an FTP or BBS site, the files may be compressed and archived. If they are, they will end with the filetype .gz. Before you can install the images to a floppy disk, you must decompress them with the gzip utility. If you are working from CD-ROM, you will have to copy the files to a DOS hard disk because you can't write the decompressed image to the CD-ROM. Even if you start with decompressed files, it may be easier to copy the images to a temporary DOS directory as it will save you the hassle of worrying about directory pathnames.

To decompress a .gz file, issue the command

gzip -d <filename>

where filename is the name of the compressed file (including the .gz extension). The -d option tells gzip to decompress the file. After the file is decompressed, the .gz file is erased and only the decompressed file remains (with the same filename, without the .gz extension). To decompress the scsi.144 and color144 images, for example, you would issue the following commands:

gzip -d scsi.gz

gzip -d color144.gz

To write the images to the two floppy disks you need two high-density floppy disks and the RAWRITE utility. The two floppy disks don't have to be blank, as the RAWRITE utility doesn't respect DOS file formats (although the disk must be formatted). The two floppy disks must be high density, though. You can mix disk types (in other words, you can use a 1.2M boot floppy disk and 1.44M root floppy disk) with some distributions of Linux, although it's not recommended for most systems. Keeping everything the same disk size is a lot easier. The disks must be formatted using DOS' FORMAT program. The boot floppy disk must be the correct size for your system's boot floppy disk drive (A: in DOS terms).

RAWRITE is a DOS program that writes the images, block-by-block, to the floppy disk. To use the RAWRITE program, just enter its name. RAWRITE prompts you for the name of the file to copy, and the destination drive letter. RAWRITE will then copy the images. Once the process is completed, DOS cannot read the floppy disk. Label the disks as the boot and root floppy disks, for convenience.

If you have access to a UNIX or Linux system, you can create the boot disks from within that operating system. You will need to put the two image files on the UNIX or Linux system, and use the dd utility to copy them to the floppy disks. This is also the procedure to follow if you are upgrading your existing Linux system to a newer release. First, make sure the images are decompressed (no .gz extension). If they are not, decompress them with the UNIX gunzip utility (a GNU utility that you may have to obtain from another source, if it's not included with your distribution). To decompress files in UNIX or Linux, issue the command

gunzip <filename>

where filename is the name of the image file with a .gz extension. The gunzip utility erases the compressed file and leaves an decompressed version in its place.

To copy the images to a floppy disk, you need to know the device name of the floppy drive within the operating system. For most systems, the first floppy drive is /dev/fd0, and the second floppy drive is /dev/fd1. (Some systems treat the floppy drives as raw devices, which have the names /dev/rfd0 and /dev/rfd1.) Copy the image files to the floppy disks with the command

dd if=<filename> of=/dev/fd0 obs=18k

where filename is the name of the decompressed image. The dd command converts file formats. The if and of parts of the command indicate the input and output filenames of devices. The obs portion of the command indicates the output block size (in this case, 18K).

For example, to copy the scsi and color144 images to the first floppy drive (3.5-inch 1.44M), issue the following two commands:

dd if=scsi of=/dev/fd0 obs=18k

dd if=color144 of=/dev/fd0 obs=18k

Linux is particularly stubborn about telling you your progress, so you won't see many messages. When dd starts the copy, it tells you how many blocks it will move. When it finishes, it returns the shell prompt to you without any message (unless the procedure failed). Figure 3.2 shows the command for copying the root kernel scsi to a floppy disk. After you copy both the root and boot kernels, you have completed this stage of the installation. The two floppy disks are now ready to boot a minimum Linux system for you.

Figure 3.2.
You can use the dd command to copy the boot and root images to floppy disk from any Linux or UNIX system.

Partitioning the Hard Disk

Hard disks are divided into partitions, which are areas dedicated to an operating system. A hard disk can have up to four primary partitions, with some partitions being divided into more logical drives by the operating system software. A more complete discussion of partitions is in Chapter 4, "LILO."

If you are running Linux from a DOS partition using the UMSDOS root image, you don't have to worry about repartitioning your drives. Your existing drive's partitions will be used. However, because UMSDOS is a poor filesystem compared to Linux's, you will probably want to create your own Linux partitions. Check the later section "Using UMSDOS" for information on setting up UMSDOS.

Linux prefers two partitions: one for the Linux swap space and one for the Linux software filesystem itself. The swap space is used as an extension of your machine's physical RAM and can be quite small. Technically, you don't need a swap partition, especially if you have lots of RAM, but it is a very good idea to create one anyway as your system can grind to a halt suddenly if RAM is exhausted. The Linux filesystem partition tends to be quite large, as it must hold all the Linux software. You can have several Linux filesystem partitions to hold utilities, applications, and user files, although one partition must be designated as the boot partition (where the kernel and primary utilities are located).

If you are using a hard disk that has an operating system already installed on it, you will have to repartition your hard disk to make room for Linux. This process will destroy anything already on your hard disk, so make backups of any existing data you want to keep!

You use the fdisk utility to partition a hard disk. The Linux version of fdisk does the same task as FDISK in DOS, although the menus are completely different (and much more complicated). Many PC-based UNIX systems also use fdisk to partition hard drives.

<NOTE>A DOS utility called FIPS sometimes allows non-destructive changes to your partitions, assuming no data is on the areas that will be repartitioned. FIPS is available from many sources, including most of the Linux FTP sites and on some Linux CD-ROMs. However, you should make backups, just in case.<NOTE>

You must decide how much space to allocate to the different partitions before you start, as changing your mind later will mean destroying all the data you have saved to disk. The Linux swap space partition size depends on the amount of RAM in your system, the number of users you expect, and the type of development you will do.

If you are going to maintain a DOS partition on the same disk, you will have to balance the disk space requirements of both operating systems against your total disk capacity. A minimum Linux filesystem partition will be about 20M, although closer to 100M is needed for a full X-based installation.

Determining the Size of the Linux Swap Space Partition

How big should the swap space partition be? No single number works for all installations, unfortunately. Generally, because the swap space is used as an extension of physical RAM, the more RAM you have, the less swap space is required. Add the amount of swap space and the amount of RAM together to get the amount of RAM Linux will use. For example, if you have 8M of RAM on your machine's motherboard and a 16M swap space partition, Linux will behave as though you had 24M RAM.

Linux uses the swap space by moving pages of physical RAM to the swap space when it doesn't need them, and moving them back again when it needs the memory pages. Why not make a very large swap space and let Linux think it's in heaven? The swap space is much slower in access time than RAM, and there is a point at which the size of the swap space starts to act against your Linux system's efficiency instead of for it. In addition, most versions of Linux have an upper limit of 16M for each swap partition. Those versions of Linux will, however, let you partition more than 16M to a swap space, but it will only use the first 16M. If needed, though, you can create multiple swap partitions. Up to eight swap partitions can exist, each up to 16M in size. The latest versions of Linux allow swap partitions larger than 16M, but it is wise to keep that size as a guide.

You may not even need swap space if you have lots of RAM. For example, if you have 16M of physical RAM and don't intend to do any application development or run X, you probably won't make much use of the swap space because Linux can fit everything it needs in the 16M. (You still should have a small swap space, just in case.) If you are running X, developing applications, or running memory-hog applications like databases, swap space is crucial even if you have lots of physical RAM. Even 16M RAM is not enough for X, so you need swap space.

A good rule is to create a swap space with the maximum size limit of 16M. Unless you have a very small capacity hard disk, a swap space of this size won't be a major drain on your resources, and it gives Linux plenty of space with which to work. If you don't want to allocate this much space, a good rule is to have a total of 16M RAM (swap space plus physical RAM). Don't eliminate the swap space completely, though, even if you have a lot of RAM. At a minimum, set up a 4M swap space. Running out of RAM can cause Linux to lock up or crash.

Once a swap space partition has been created, it is just like any other partition on the hard drive. If you want to change its size, you have to remove the existing partition and create a new one, although the space must be contiguous on the hard drive (which can be difficult to do if you have used all the space the drive offers for other partitions).

Setting up Partitions

You use the fdisk utility to set up the partitions on your hard disk. Remember that fdisk will destroy existing data on your disk! You can set up your Linux disk partitions either from DOS, or from within Linux. It really doesn't matter which approach you use, although the DOS FDISK program is a little easier to use than Linux's. If you are using DOS FDISK to repartition a DOS area on your drives, use it to set up the Linux swap space and filesystem partitions, too.

To set up partitions for Linux, remove any existing partitions first (unless you want to keep them as they are). If you intend to use DOS on the same system as Linux, DOS should be the first partition on the disk so it can boot. (You can use LILO to get by this restriction, but it is still a good rule to leave DOS as the first partition.) If you are keeping an existing DOS partition on your hard drive, leave the first partition as DOS if you can.

Create a DOS boot disk that can reformat and transfer the DOS kernel to the hard drive, regardless of whether you are leaving an existing DOS partition or creating a new one. To create the boot disk, use the DOS

format a: /s

command (assuming A: is the drive the disk is in). The /s option transfers the operating system kernel. Next, copy the utilities FDISK, FORMAT, SYS, and CHKDSK to the boot disk. You should also copy an editor such as EDIT(which requires the QBASIC files as well), and your existing CONFIG.SYS and AUTOEXEC.BAT files (although you could rename them). This disk will let you format any new DOS partitions. Alternatively, if you are starting from scratch with a new DOS partition, you can reload DOS from the original floppy disks when ready to format the DOS partition.

If you are removing an existing DOS partition and recreating a smaller one (as you would if your entire disk was DOS before Linux came into your life), follow these steps (after making a backup of your DOS data):

  1. Remove the existing DOS partition.

  2. Create a new primary DOS partition as the first partition.

  3. Make the DOS partition active.

  4. Reboot the system from your boot disk (or DOS disks).

  5. Format the DOS partition and transfer the DOS kernel (COMMAND.COM).

  6. Restore your backup files to the DOS partition. (You can do this step at anytime).

Next, set up the Linux swap space partition by creating a partition of the proper size. You can do this step either from DOS or when you have booted Linux from the boot and root floppy disks. The rest of this section assumes that you are setting up the partitions from DOS, although the process is the same either way.

Most versions of FDISK allow you to enter the size of the partition in megabytes, with the utility calculating the sector numbers that apply to it. Set the size of the Linux swap space to whatever size you decided, up to a maximum of 16M. Don't make the partition active or format it! You can set up the swap space partition in an extended disk partition, but a primary partition is a better choice if your disk can support it.

Finally, create the Linux filesystem partition to be whatever size you want; you can even make it the size of the rest of the disk if that's the only partition missing. Again, don't activate or format the partition. When you are running the Linux installation routine, you will identify and format the swap space and filesystem partitions properly.


UMSDOS allows you to use an existing DOS partition to house your Linux system. However, since you will be forcing Linux to use the DOS disk layout, you will suffer some performance limitations compared to creating a dedicated Linux partition. On the other hand, using UMSDOS lets you keep your disk drive the way it is, preventing the hassle of repartitioning and reformatting your drive. It is also a fast and easy way to install Linux if you only want to experiment for a while before installing a full system.

Note that UMSDOS does not let you run DOS and Linux at the same time. UMSDOS (UNIX in MS-DOS) only creates the Linux filesystem under the DOS formatted partition, although the partition is modified to allow long filenames, Linux file permissions, and more. When you start the system, you still have to choose between booting Linux or DOS as the operating system. If you start DOS, you can't use the extended Linux filenames, although you will be able to snoop around the directories. Filenames may not make much sense because of the contraction from long Linux filenames to DOS-compatible filenames, though.

The only limitation about UMSDOS is that the DOS filesystem is not designed as well as the Linux filesystem, so you get some performance degradation. This problem isn't major as most people don't notice the difference unless they are running a file-intensive application like X or compiling programs. You can always start with UMSDOS; then if you decide you like Linux enough, back up the Linux data and repartition the drive to create a true Linux filesystem.

If you want to use UMSDOS, you have to perform a few extra steps when setting up the disk. You must still create the boot and root disks, although you will need a root image that supports UMSDOS. (Most distributions have the root images umsds144 and umsds12 for this purpose.) When you boot Linux and it asks which partition to use for the filesystem, you specify the DOS partition. UMSDOS then initializes the filesystem for you. After that, the procedure for installing the rest of Linux is the same as it is for a dedicated Linux partition.

Installing the Linux Partitions

The Linux installation process starts when you boot your system from the boot floppy disk. After the kernel has loaded, you will be prompted to remove the boot floppy disk and insert your root floppy disk. When the root filesystem has been read, you will either be sent directly to an installation script, or presented with the login prompt. Log in as root. No password is required, because you haven't yet added one to the system.

The first step is to set up the disk partitions, if you haven't already done so, using fdisk. If you have more than one hard drive, you can place your Linux partitions on either drive. If you are planning on keeping a DOS partition, though, make sure that partition is the first partition on the first drive. Linux isn't so picky. If you want to boot Linux cleanly, place a Linux filesystem on the first drive. You can also create Linux filesystems on the second drive. A Linux swap partition can be on either drive, although keeping it on the first drive with the first filesystem is a good idea.

Linux's fdisk

Linux's fdisk program is different than the one in DOS, so check the menus frequently to determine the proper commands. You invoke Linux's fdisk in the same manner as DOS'. If you don't specify a drive, fdisk assumes the first one in the system. Otherwise, you can specifically indicate which disk drive to partition by giving the device name on the command line, as in

fdisk /dev/hdb

which invokes fdisk for the second drive. If your system has IDE, ESDI, or RLL drives, the first drive is /dev/hda and the second is /dev/hdb. SCSI drives are /dev/sda, /dev/sdb, and so on. Because a single controller can support seven SCSI drives, you could have up to /dev/hdg. (You can go even higher with another controller card, but few Linux systems will require that many drives!)

<NOTE>You should not use Linux's fdisk utility to create partitions for operating systems other than Linux. If, for example, you want a DOS partition on your disk, create it with DOS' FDISK. Linux does not write the partition table properly for other operating systems.<NOTE>

As mentioned earlier, Linux's fdisk commands are different than the FDISK commands for DOS. The following list explains the commands you need to run Linux's fdisk utility:

Command Action
d Deletes an existing partition
l Lists all known partition types
n Creates a new partition
p Displays the current partition table
q Quits fdisk without saving changes
t Changes a partition's type code
v Verifies the partition table
w Writes current partition table to disk and exits

Linux's fdisk utility offers quite a few more commands, as Figure 3.3 shows. This screen is the output from the Linux fdisk help (m) command. Note the warning at the top of the screen. This warning is issued whenever your hard drive has more than 1024 cylinders, which early versions of Linux (pre 1.0 kernels mostly) couldn't support. Later versions of Linux, including the version provided on this book's CD-ROM, all support much larger hard drives. The warning is a holdover from the earlier system and should really be taken out.

Figure 3.3.
Linux's fdisk utility offers these commands.

The process for setting up a partition is to first examine the partition table to make sure any existing partitions are correct. If you have a DOS partition on your drive, it should show in the partition table. If you created Linux swap and filesystem partitions when you were in DOS' fdisk, they should appear in the partition table too, although the partitions' types will be incorrect.

Setting Up Linux Partitions

To create the Linux swap space partition, use the n command and give the starting sector number. Usually, this number will be immediately after any existing DOS partition (or other operating systems you have installed). Linux's fdisk lets you specify the size of the partition either by supplying an end sector number or by giving a size in megabytes (remember the swap space size has a practical maximum of 16M). If you give the size in megabytes, the format is usually +XXM, where XX is the number of megabytes (such as +16M). You can also specify kilobytes, but you don't want to create a swap partition that is less than 1M.

<NOTE>Most PC BIOSs cannot handle more than 1024 cylinders on a disk drive. You may not be able to create DOS or Linux partitions or filesystems that go beyond the 1,023th cylinder (numbering starts at zero). Some other operating systems, such as SCO UNIX, allow you to use anything beyond the 1,024 limit. Linux can use partitions beyond the 1,024 limit, but it can't boot from them. If you have a disk drive that has more than 1023 cylinders, make sure your primary Linux partition ends before 1023. You can create extra partitions following that cylinder and mount them as second filesystems. Alternatively, you can create a single large Linux filesystem that extends or starts beyond the 1,023rd cylinder and use a LILO boot floppy disk.<NOTE>

The fdisk program asks you whether you want to create a primary or an extended partition. If you are creating a primary partition, the program wants the number (one to four≈remember a DOS partition has to be number one to boot). In most cases, you should create only primary partitions, unless you have a large disk drive. You can use extended partitions to add logical drives inside primary partitions, which is similar to the way DOS creates logical drives. In Linux, extended partitions are not the same as extended filesystems!

<NOTE>Some distributions of Linux issue the message Warning: Linux can't currently use X sectors of this partition. This warning was in early versions of Linux that couldn't handle filesystems larger than 64K and can be ignored.<NOTE>

After you have created the Linux partition, assign it a type. Some versions of fdisk prompt for this information right away, and others let you select the option to assign filesystem types from the fdisk menu. In either case, the letter l will display all known filesystem types. Choose the one that designates a Linux swap space (number 82), and check the partition table. Figure 3.4 shows the filesystem types supported by the version of Linux included with this book. As you can see, many filesystem types are allowed, although most users will only use the DOS, Linux swap, and Linux data types. The other filesystem types were included in earlier versions of Linux for compatibility with other operating systems.

Figure 3.4.
The filesystem types supported by Linux, identified by type number and description.

Your Linux swap space partition should have the correct size and partition type when you display the partition table with the p command. Although Linux doesn't care about the partition type numbers, some other operating systems do note them, so it's a good practice to label them correctly in order to prevent future problems. This practice also helps you keep the partition table organized.

Next, create your primary Linux filesystem partition in the same manner. If you want to use the rest of the disk drive for that partition, you can enter the end sector number of your drive (Linux's fdisk will tell you the range you can use). This number would be the usual default if your hard drive has a DOS, Linux swap space, and Linux filesystem partition on it. After you have created the Linux filesystem partition, identify its filetype as 82, which is a Linux native type. You can display the partition table at any time with the p command (inside fdisk only). Figure 3.5 shows a partition table set up on a 2.4G SCSI hard drive (/dev/sda), which has 500M for DOS (/dev/sda1), a 16M Linux swap space partition (/dev/sda2), and the rest of the drive for Linux data (/dev/sda3).

Figure 3.5.
A completed partition table with DOS and Linux sharing a large (2.4G) drive.

Make a note of the size of the swap space and filesystem partitions, in blocks, as you will need this information later. You can read this information straight from the partition table. After you create the Linux partitions and are satisfied with the partition table layout, save and exit fdisk. Make sure you write the table to disk with the w command. If you don't save the information, you will have to repeat the process again.

Enabling the Swap Space for Installation

Linux's installation routine requires a good chunk of RAM to proceed. If you have 4M of RAM or less, you will have problems installing Linux unless you have the kernel use the swap space partition. (If you have only 4M or less of RAM in your system, you should have a swap space of at least 8M, preferably 16M.) If you try to install Linux and get memory error messages, you system doesn't have enough RAM and the kernel needs to use the swap space. Even if you have lots of RAM, there's no reason not to enable the swap space now. To enable the swap space, issue the command

mkswap -c partition size

where partition is the name of the partition and size is the size of the partition in blocks. If you didn't make a note of this number earlier when setting up the partition table, you can start fdisk again and read the size in blocks from the partition table display.

For example, if you have set up the Linux swap space on partition /dev/hda2 (the second primary partition on the first non-SCSI drive) and it has a size of 13,565 blocks you would issue the command

mkswap -c /dev/hda2 13565

The -c option in the command line tells the mkswap utility to format the partition and check it for bad blocks. This option slows down the creation of the swap partition a little, but a bad block in the swap partition can cause your entire system to crash. If mkswap finds any errors in the swap space, it will generate an error message and mark the block as unusable by the operating system (the block is removed from the total available for swap space). Because mkswap flags bad blocks to be left alone, you can ignore the bad block messages unless there is a considerable number of them (ten or more is a good limit in a 16M partition), in which case your hard drive has too many bad blocks and you should consider either low-level formatting it or replacing it with a new drive.

After you set up the swap partition, you enable the Linux swap space partition with the swapon command. Usually, you have to specify the partition, although some versions use the partition table to figure out the partition automatically. It never hurts to be explicit, though. To enable the swap partition set up in the preceding example, you would enter the command

swapon /dev/hda2

You have to repeat the mkswap and swapon commands for each swap partition, if you created more than one. As soon as you execute the swapon command, the Linux kernel starts to use the new swap space as an extension of the physical RAM. Figure 3.6 shows a swap partition called /dev/sda2 (second partition on the first SCSI drive) being set up and activated. Note that you need to know the size of the partition in blocks. You get this number from the fdisk utility.

Figure 3.6.
Setting up and activating a swap partition on /dev/sda2.

<NOTE>If you've turned on the swap space and still get error messages when you try to install Linux, you need either more physical RAM or a larger swap space. Increasing the swap space now and then installing Linux is better than having to redo it later. To increase the size of a swap space partition, you may have to remove the existing Linux partitions and recreate them with fdisk.<NOTE>

Creating the Linux Filesystem Partition

Once you have a swap space configured and working, you can set up the Linux filesystem. Some Linux installation scripts automate this step, or you may have to execute it yourself. Either way, this section explains what is going on.

You have already allocated the partition table to support a Linux filesystem. Now you can create the filesystem with the mkfs (make filesystem) command. The exact format of the command depends on the type of filesystem you are setting up. The most popular filesystem (for reasons of speed and flexibility) is called the Second Extended filesystem (which has nothing to do with extended partitions on a hard disk). To create a Second Extended filesystem, issue the command

mke2fs -c <partition> <size>

where partition is the device name and size is the size of the partition in blocks (taken from the partition display in fdisk). For example, to create a filesystem in /dev/hda3 that is 162,344 blocks in size, the command would be

mke2fs -c /dev/hda3 162344

<NOTE>When specifying the size of a partition, make sure you use blocks and not sectors or cylinders. Using the wrong value will result in errors or only a fraction of your partition being used.<NOTE>

The mke2fs utility checks the partition for bad blocks (the -c option), and then sets the filesystem up properly in that partition. If you are setting up a large partition, the disk check can take a few minutes, but you should not skip it unless you know your disk is good.

The other filesystems available to Linux are the Xia filesystem, the Extended filesystem, and the Minix filesystem. The Xia filesystem is good, but not as popular as the Second Extended filesystem. The Extended filesystem is an older version of Second Extended, and the Minix filesystem is compatible with the old Minix operating system (which Linux was written to replace). You can create these filesystems with the following commands:

Extended mkefs
Minix mkfs
Xia mkxfs

All three commands take the same arguments as the Second Extended filesystem command. The Minix filesystem is limited to 64M. None of the mkfs commands format the filesystem; they just set it up. You are prompted for a filesystem format during the installation process.

Installing the Linux Software

After you create and format the partitions and create the filesystems, you can install the Linux software. This step may be automated, depending on the installation procedure included with your Linux distribution. Most versions of Linux include a utility called setup that installs the software for you. From the Linux prompt, type the command


If you are running the color root image, you get graphic, full-screen windows for the installation process. Other root images use character-based installation messages instead. Many users who install Linux frequently avoid the color root image because it can take a little longer to answer all the questions the script poses and some typing errors are difficult to correct. Whichever root image you choose, carefully read each screen.

The setup utility supplied with the Linux system on this book's CD-ROM is shown in Figure 3.7. Some minor variations in menu choices exist between versions of Linux, but the primary options are much the same.

Figure 3.7.
The most common setup utility menu.

Linux presents you with many choices during the installation. Although the default choices are correct for most people, check that the default is what you want. You have the option of letting Linux install everything without your prompting, except when disk sets change, but you should use this option only if you know exactly what is going on your disk. If you are installing Linux for the first time or want to choose the software to be installed by examining descriptions of each package, use the verbose options to show all messages and let you control the process.

Selecting the Source and Disk Sets

The setup installation script either asks you or lets you set several pieces of information. First, you need to specify the source of the software. You can usually accomplish this step by by selecting Source from the setup menu when setup starts its automatic installation process. If you have a CD-ROM, it should have been activated during the boot process if the drivers were correct for your hardware. Select the CD-ROM option. You may be asked to further narrow down the type of CD-ROM you have on your system. Choose the exact type(or the one closest to it) and hope for the best. If you are installing from another disk drive partition (such as another Linux partition or a DOS partition), provide the full device and path names. Figure 3.8 shows the Source option choices presented from the setup menu. From here, you can select CD-ROM. If Linux didn't identify your CD-ROM drive when it booted, you may be presented with another screen and asked to choose the type of CD-ROM drive your system has.

Figure 3.8.
The Source option on the setup menu lets you select where the Linux software will be read from.

The installation program then asks for the target of the installation. The target is where you want the software to be installed. The newly created Linux partition is probably the location you want, so enter the partition's name. You will probably be asked whether you want to format that partition; answer yes. (Running mkfs or its variants does not format the partition for you.)

Next, Linux displays a list of the disk sets you can install. You may get to this screen through the normal installation process, or you can select Disk Sets from the setup menu. Choose the ones you want. The list of disk sets is usually a scrolling window, as shown in Figure 3.9. Make sure you scroll through the entire list and mark the disk sets you want to install.

Figure 3.9.
The scrolling list holds the names of each major package Linux offers.

Some setup versions let you further refine the list of utilities when the disk set is installed. As a last step, verify the information, and then let Linux install itself. If this process doesn't start automatically, choose the Install option from the setup menu. Linux may double-check with you that you want to install the disk sets you've selected. This screen message looks similar to the one shown in Figure 3.10. This is your last chance to change your mind before Linux starts copying files to your hard drive. After you tell Linux to go ahead and install the software, watch for messages and prompts, and follow any on-screen instructions. If you are installing from a floppy disk, you will be prompted at intervals to change to the next disk in the disk set.

Figure 3.10.
The Linux installation routine usually stops and prompts you before it starts installing software.

As Linux installs software, it displays status screens like the one shown in Figure 3.11 whenever the disk set is changed. As each piece of software in a disk set is installed, its name, size, and a brief description is often displayed, as shown in Figure 3.12. Occasionally, you will be asked to choose whether to install a particular component, as shown in Figure 3.13. Choosing yes installs the package described on the screen; choosing no (use the scroll key to display the no option) skips that package and moves to the next.

Figure 3.11.
As Linux installs each selected disk set, setup displays the letter of the set. The e set being installed here is the GNU Emacs editor.

Figure 3.12.
Each package in a disk set that is installed by default is displayed in a status message, along with the size and brief description of the package.

Figure 3.13.
Some disk sets contain optional components. When one is encountered, you are presented with a screen like this one that describes the package and asks whether you want to install it.

Creating a Boot Disk

At the end of the installation routine, you may be prompted whether you want to create a boot disk. Figure 3.14 shows this screen from the Linux CD-ROM included with this book. The boot disk enables you to access the system at any time, especially if the normal boot process fails. You should always make a boot disk for emergency purposes. This disk is not the same as the boot floppy disk you made to start the installation (which is only useful when you reinstall from scratch).

Figure 3.14.
During the installation process, setup may ask you whether you want to create a boot disk.

When you choose to create a boot disk, Linux prompts you for a floppy disk, as shown in Figure 3.15. Insert a floppy disk in the drive and choose Yes. (Choosing No abandons the creation of the boot disk.) Linux then proceeds to copy the the kernel image and some extra information to the floppy disk. While Linux is creating the boot disk, it shows you a message like the one in Figure 3.16.

Figure 3.15.
When you choose to create a boot disk, Linux prompts you to insert a floppy disk in the drive and choose Yes.

Figure 3.16.
This screen shows the progress of the creation of the boot disk.

Configuration Details

After installing disk sets and creating a boot disk, the setup routine may give you a choice to continue with the installation process by configuring your system or to leave the configuration until later. It's a good idea to continue with the process because back-tracking can be difficult sometimes. Although the order of prompts and the options presented to you are different depending on the version of the Linux system you are installing, usually you are asked to set up your modem first, as shown in Figure 3.17.

Figure 3.17.
The first configuration information you are asked about is your modem.

If you have a modem installed on your system already, choose the Yes option to configure the port and modem speed now. Alternatively, if you are not sure which port you want to use or want to add the modem later, choose No. If you choose Yes to install a modem, you are asked for the device it is attached to, as shown in Figure 3.18. The devices are named in Linux format, with /dev/cua0 equivalent to COM1, /dev/cua1 equivalent to COM2, and so on. Choose the proper device. If your modem is used by DOS' COM2 port, for example, scroll to /dev/cua1 and choose OK. If you are not sure which port to use, try /dev/cua1, as most mouse ports are COM1 (/dev/cua0). You can always reconfigure the system later.

Figure 3.18.
Choose the device your modem is attached to by using the Linux /dev/cua conventions.

Next you will be asked whether you want to set up your mouse, as shown in Figure 3.19. You can set the mouse up later, but it's easier to do it when you first load the Linux software. If you choose to configure the mouse at this time, you have to choose the type of mouse you are using. Figure 3.20 shows the list of currently supported mouse types. Most mouse peripherals are serial, so select the serial mouse that matches your unit. If in doubt, choose Microsoft compatible serial mouse.

Figure 3.19.
Linux ask you whether you want to set up your mouse.

Figure 3.20.
Choose the type of mouse your system uses.

After you choose the mouse, you may be asked for more information about it. If the mouse is a serial mouse, you must choose the port it is attached to, as shown in Figure 3.21. The port numbering is similar to the modem port (although the device name is different), with /dev/S0 corresponding to COM1, /dev/S1 to COM2, and so on. Don't select the same port as the modem! If you are installing a bus mouse, you may be asked for the DMA the mouse uses.

Figure 3.21.
For serial mouse units, you must select the port the mouse is attached to.

Finally, you may be asked whether you want to try out some screen fonts. This step is time-consuming and generally unproductive. It is much better to go with the default fonts for now and modify them later if you really don't like them. These fonts are used for all character-based messages.

Setting the Boot Process

The last step in the Linux installation process is setting the boot device. A utility called LILO (Linux Loader) usually boots Linux. LILO can boot your system in several different ways, depending on whether you want to use your system with another operating system. Most of the time, you will want LILO to boot your system into Linux with the option to load DOS (if you have it on your system).

The LILO screens explain most of the choices quite well, but LILO has a few quirks to it. Chapter 4 is devoted to explaining what LILO does and how to make it behave properly. For now, if you are impatient, follow the defaults, but don't let LILO overwrite your hard disk's Master Boot Record. Doing so can cause a bit of a hassle when you want to boot DOS. You can, though, let LILO write a boot sector to your Linux partition, and then use fdisk to make either DOS or Linux active. If you're not too sure what to do with LILO, ignore it for now. You have a boot floppy disk that lets you start your machine. When you better understand LILO, you can set it up the way you want.

As a last step in the installation process, reboot your machine and let Linux boot from the boot floppy disk or from LILO, if you installed it. If everything boots properly, you can use Linux as you normally would. If you experienced problems booting, watch error messages and check the installation process to see which part went screwy. As long as you have your boot disk, you should be able to get into Linux without a problem.

Viewing Installed Software Files

When Linux is up and running, you may want to install or remove disk sets and other software. You can also check that components of a disk set have been properly installed. A few different utilities are available for this task, but the most common is called pkgtool. When you enter the pkgtool command name at the shell prompt, a menu that enables you to install new software, remove existing software, or view installed files in a package appears on-screen. Figure 3.22 shows the pkgtool menu. You can also use the setup utility for these tasks.

Figure 3.22.
The pkgtool utility is one way to install, remove, or examine software on your Linux system.

To view the contents of a package, select View from the main pkgtool menu, and then choose the name of the package from the list presented. Figure 3.23 shows the list of packages. The list should include all the disk set tools you have installed, as well as any additional software installed after the first installation. Selecting a tool name sends pkgtool to check all the files that should be in the software and report its success. Sometimes the list of software in a package can take a while to appear. Be patient! The list pkgtool presents usually has a brief description of the tool and a list of all the files in the installation. Figure 3.24 shows the entry for the base software package.

Figure 3.23
When you select View from the pkgtool utility, you must choose which package to view.

Figure 3.24
The pkgtool utility shows the components installed for each package on your system.

When the list of files is displayed, you can move through them with the space bar. To leave the list of files, select the Exit option at the bottom of the screen.


Many different problems can occur while setting up and installing a Linux system, although most of them are self-explanatory from error messages. The following sections look at a few of the most commonly encountered problems.

Software Installation Problems

You may encounter a few errors when installing Linux. If you get the message device full, you have run out of disk space and need to either break up the installation into several partitions or install fewer components. If you haven't yet installed the basic system, you need more disk space. You have to delete your partitions and start the installation process again, allocating more space to Linux.

Errors such as read error, file not found and tar: read error are indicative of a problem with either the disk medium you are installing from, or an incomplete disk set. These problems usually occur with floppy disks and may indicate that you have a bad floppy disk. All you can do in most cases is replace the floppy disk with a new one.

Hard Disk and Disk Controller Problems

When Linux boots, it displays a few messages, one of the most important being a partition check. You see messages like the following:

Partition check:

hda: hda1 hda2 hda3

hdb: hdb1 hdb2

In this example, the first non-SCSI disk has three partitions and the second disk has two. Your system's output is probably different, of course. If you don't see any partition information, either the hard disk controller is not recognized properly or the disk drives are not accessible. Check the following potential causes for these problems:

  • Check the cables inside the computer. The hard disk cable should run from the adapter card to each drive's connector. Make sure the cables are connected in the proper manner (the red strip on the cable is at pin 1 on the connector).

  • Check that the power connector is attached to each disk drive. Without power, your drive doesn't spin up and Linux can't touch it.

  • Check the partition table to make sure you created a Linux partition properly.

If the drive is still not working properly with Linux but works OK when you boot DOS, a kernel driver for the hard disk is likely at fault. Some IDE drives, for example, are not as well-behaved (not conforming to the IDE standards) as others, and your IDE kernel driver may not be able to talk to your drives. Try using a different kernel image and see if the problem solves itself. If you are using a SCSI kernel and adapter and the drives are not recognized, use the utilities that came with the SCSI adapter card to force a check of the hard drives. They may have a SCSI ID set incorrectly.

Device Conflicts

One of the most commonly encountered problems is hardware that is not recognized properly. This problem can happen to a CD-ROM, a network card, and even a hard disk. Most of the time, a conflict in the IRQ (interrupt), DMA (Direct Memory Address), or I/O address settings causes this problem. When two devices have the same settings on any one of these three characteristics, Linux and the BIOS may not be able to communicate with the device properly.

A symptom of this problem may be Linux hanging when it tries to find a specific device, as explained in the boot messages. When Linux boots up, it generates messages that explain what it is doing. If you see a message that it is trying to connect to the network card, for example, and it never gets past that point, chances are that the network card has a conflict with another device. (Totally failed cards are very rare and don't usually stop the boot process, as Linux ignores devices it can't access. The problem with a working card with conflicting settings is that Linux is getting messages from two devices that don't act the same.)

To check for conflicts, run a diagnostic utility under DOS, such as MSD or Norton Info. These utilities can show you the current IRQ, DMA, and I/O addresses and pinpoint any conflicts. you can also use them to find available settings. Alternatively, you can check the settings of every device in your system for conflicts. Usually, network cards conflict with sound boards, non-SCSI tape driver cards, video cards, and similar add-on cards. Most cards use DIPs or jumpers to set these parameters, so check them against the documentation. To help isolate the problem, remove cards that are not necessary, such as a sound card, and see whether the boot process moves past the device that caused the hangup.

Another problem that can occur is with SCSI devices (and a few others, although much rarer) that must have specific settings in the kernel image. Some kernels, especially special-purpose kernels that have been developed for non-mainstream adapters, were compiled with settings that are default values for adapters or disk drives, and if the settings have been changed, the kernel hangs up. To check for this type of problem, investigate any documentation that came with the kernel image.

The most common devices in a PC (COM ports, parallel ports, and floppy disks) and their IRQ, DMA, and I/O addresses are shown in in the following list. These are the default values for a PC, but they may be changed by users. Because only two COM ports (serial ports) are usually supported by DOS, they share IRQ values. The I/O addresses are different, though. Both floppy disks share the same I/O addresses, IRQ, and DMA.

Device IRQ DMA I/O Address (Hex)
COM 1 (/dev/ttyS0) 4 N/A 3F8
COM 2 (/dev/ttyS1) 3 N/A 2F8
COM 3 (/dev/ttyS2) 4 N/A 3E8
COM 4 (/dev/ttys3) 3 N/A 2E8
LPT 1 (/dev/lp0) 7 N/A 378-37F
LPT 2 (/dev/lp1) 5 N/A 278-27F
Floppy A (/dev/fd0) 6 2 3F0-3F7
Floppy B (/dev/fd1) 6 2 3F0-3F7

<NOTE>You may have noticed that the serial ports are called /dev/ttyS0, /dev/ttyS1, and so on in the list of devices. Yet they were called /dev/cua0, /dev/cua1, and so on when you configured the modem. The ports are the same (/dev/ttyS0 is the same as /dev/cua0); Linux just handles the devices differently. Don't get too confused about these device driver names yet. Just remember that /dev/cua refers to a modem port.<NOTE>

Network cards, SCSI adapters, sound boards, video cards, and other peripherals all must have unique IRQ, DMA, and I/O addresses, which can be difficult to arrange with a fully loaded system. For more information on available values, check your device or card installation manual for recommended values and potential conflicts.

SCSI Problems

SCSI is one of the most versatile interfaces, and it pays for that versatility in potential problems. Linux is usually good about reporting problems with SCSI devices, although the error messages may leave you wondering about the real cause of the problem.

The following list explains many of the common SCSI errors and their probable causes. Find the message that closely matches the error message Linux displays to determine your corrective steps.

SCSI device at all possible IDs One or more devices is at the same SCSI ID as the controller. Check and change device IDs. Controllers should be ID 7.
Sense errors This error is probably caused by bad termination. Check that both ends of the SCSI chain are terminated. If that is not the problem, the cable is likely at fault.
Timeout errors This error is usually caused by a DMA, IRQ, or I/O address conflict. See the preceding section for more information.
SCSI adapter not detected The BIOS is disabled or the kernel doesn't recognize the SCSI adapter. Check the drivers.
Cylinders Beyond 1024 Your disk has more than 1,024 cylinders, which the PC BIOS can't handle. Linux can use more than 1,024 cylinders, but it can't boot from a partition that extends across that cylinder boundary.
CD-ROM drive not recognized Some CD-ROM drives require a CD in the drive to be recognized properly. Insert a CD and reboot.

Problems Booting Linux

If you have installed Linux and the system doesn't boot properly from your hard disk, it may be a problem with LILO or with the partitions. If you created a boot floppy disk, boot from that. If that boots without a problem, check the partition table by executing fdisk. Make sure the Linux partition is active. If it is and you still can't boot from the hard disk, boot from the floppy disk and run LILO again to configure the boot sector. See Chapter 4 for more information on LILO.

A problem will sometimes occur when Linux can't find the main Linux partition. Boot from the floppy disk and hold down the Shift or Ctrl key. This will produce a menu that enables you to specify the boot device explicitly. This problem can usually be corrected with LILO.


Much of this chapter may have been familiar to you if you have installed Linux before, although some users really don't know what goes on during the automated installation script. Knowing the process, and staying on top of it, helps prevent problems with the Linux installation. The next step is using LILO to configure the boot system properly, a commonly misunderstood process. The next chapter looks at LILO.

Previous Page Page Top TOC Next Page