-->

Previous | Table of Contents | Next

Page 53

CHAPTE 5

Configuring and Building Kernels

by Steve Shah

IN THIS CHAPTER

Page 54

The kernel is the program that is loaded at boot time which provides an interface between the user-level programs and the hardware. Its functionality includes performing the actual task switching that occurs in multitasking systems, handling requests to read and write to disks, dealing with the network interface, and managing memory. It is these functions that give Linux its underlying behavior seen throughout the system.

Technically, Linux is only the kernel. The programs that surround it, such as the compilers, editors, windowing managers, and so on, make up the distribution. (For example, Red Hat Linux is considered a distribution of Linux.) Therefore, several different distributions of Linux exist, but the kernel remains common among them.

The kernel is important because it is the glue that holds everything together. Working as a central command post for the system, it manages all the programs running, their memory allocation, their means of accessing the disk, and so on. Without the kernel, there is no Linux.

The default kernel that comes on the CD-ROM is the 2.0.30 kernel. This kernel, which is automatically installed, contains support for a large number of devices, thereby making it flexible. Unless you have a particularly unusual configuration, the standard issue kernel with Red Hat should work on your machine without any changes.

Although the standard issue kernel will work, you might need to add support for a new device or simply pare down the list of devices the kernel supports so that it takes less memory. Either way, you will need to step through the kernel configuration process.

WARNING
Recompiling a new kernel can be potentially dangerous. By doing so, you can easily deny yourself access to the system, so be sure to follow all the safety tips in this chapter. Being locked out of your own machine because of a silly mistake is one of the most frustrating results than can occur.
At the very least, you should have a boot disk ready. Test it and verify that it comes up as you expect it to. Be familiar with the commands necessary to mount the root partition, make changes to key files (for example, /etc/lilo.conf), and rerun LILO.

An Introduction to the Linux Kernel

Now that you have an understanding of what the kernel does, you might find a need to reconfigure and build it. In this section, I discuss the preamble to the process: acquiring the source code and installing it in the correct place.

Page 55

Acquiring the Source Tree

The CD-ROM that comes with this book contains an RPM for the kernel source tree. To use it, simply install it using the rpm package. You can find updated versions of the kernel source at www.redhat.com or from one of the following:

The source tree comes in one large file titled linux-X.X.XX.tar.gz, where X.X.XX is the version number of the kernel. For this example, you will use version 2.0.30.

NOTE
Version numbers in Linux have more significance than what may appear to you at first glance. To understand what I mean, look at the kernel used in this chapter—2.0.30.

The version number is broken up into three parts: the major number, the minor number, and the revision number. The major version number—2 in this kernel—rarely changes. Every time the number increases, major improvements have been made in the kernel, and upgrades are definitely warranted.

The minor number—0 in this kernel—indicates the kernel's stability. Even-numbered kernels (for example, 0, 2, 4, and so on) are considered stable production-quality kernels, whereas odd-numbered kernels (for example, 1, 3, 5, and so on) are development kernels. When a kernel reaches a production version, no more features are added, and the only changes made to it are to fix any last-minute bugs.

In contrast, odd-numbered kernels are actively being worked on. They contain experimental code and feature the latest developments. The side effect of these added features is the instability that may exist in them. Sometimes they are stable; other times they have critical flaws. Odd-numbered kernels should be used only on systems on which users are comfortable trying out new features and can accept downtime incurred by frequent kernel upgrades.

The last number, which is the revision number, indicates the current patch level for this version of the release. During the development phase, new versions can be released as often as twice a week.

If you decide to download a more recent source tree instead of using the version on the
CD-ROM, you need to decompress and untar it. You should do so in the /usr/src directory because symbolic links from /usr/include have already been set up. By manipulating the

Page 56

/usr/src directory so that /usr/src/linux always points to the most recent kernel, you don't have to fix the /usr/include directories every time you compile a new kernel. (See the following tip.)

To unpack the kernel, simply run


tar xzf linux-2.0.30.tar.gz

where linux-2.0.30.tar.gz is the name of the kernel you downloaded. This line decompresses and untars the kernel into the /usr/src/linux directory.

TIP
If you have an older kernel in place, you might not want to remove the previous source tree. After all, if you need to revert back to it, not having to download it again would be nice! Instead, create a new directory titled linux-2.0.30, where 2.0.30 is the version number of the new kernel. Then create a symbolic link from /usr/src/linux to /usr/src/linux-2.0.30. By doing so, you can easily repoint the symbolic link to new kernels as they are released. As a side benefit, your /usr/include directories can always remain pointed to /usr/src/linux.

If this is the first kernel you've compiled, be sure to take a few minutes to read the /usr/src/linux/README file. It contains up-to-the-minute details about the exact kernel you are working with as well as problem reporting information.

TIP
Due to the amount of concurrent development done in the Linux community, you might find that not all the drivers provided with the Linux kernel are the latest. If you have problems with a particular device, searching on the Internet to see whether a more recent version of the driver is available is often worthwhile.
For example, if you are having problems with the 3Com 3C59x driver, a quick peek at the source code shows that you can reach the author of the driver, Donald Becker, at linux-vortex@cesdis.gsfc.nasa.gov. Searching on the keywords linux vortex on the AltaVista search engine (www.altavista.digital.com) turns up the primary Web site for the development of this driver (http://cesdis.gsfc.nasa.gov/pub/linux/drivers/vortex.html ) from which you can download the latest version and include it into your source tree.

Previous | Table of Contents | Next