-->
Previous Table of Contents Next


Chapter 13
Configuring the Linux Kernel

by Jack Tackett

In this chapter
Preparing to Build a New Kernel
Configuring a New Kernel
Compiling the New Kernel
Building a Modularized Kernel

This chapter gives you the information you need to configure and install a new Linux kernel. The kernel is the core of the Linux operating system and provides the basic system services to the rest of Linux. Remember, Linux isn’t a commercial product, so you might find some problems after a new distribution is released. Or someone may discover a serious security hole in the kernel. This happens all the time with both commercial and “free” operating systems. The difference is that with Linux, because the source code is available, you can patch any problems immediately after they are discovered. You do not have to wait for your commercial vendor to release a new service pack to fix a hole in your system.

In addition, a new feature in the current releases of the Linux kernel enables you to load specific device and program support into the kernel without precompiling the support into a large kernel. This allows Linux to load into memory only those parts of the kernel it needs. Modules also provide a way to modify the kernel to solve a problem or to add a new feature without recompiling the entire system.

Preparing to Build a New Kernel

Sometimes a problem has only one solution—a new kernel. The kernel is the core operating system for Linux. Although not for the faint of heart, downloading a new kernel from the Net and building the kernel is sometimes necessary. If you have some programming experience and know your way around the C programming language, you should be able to build and install a new kernel. If not, you might want to skip this section.

You may have to install a new kernel for a few reasons:

  A patch is released to run new hardware.
  You want to remove features you don’t use from the kernel in order to lower the memory requirements for your system.

The starting point is to determine what kernel version you’re now running. You can find out the kernel version with the following command:


uname -a

The response indicates which version of the kernel is running and when it was created. The version numbers are in the form of

MajorVersionNumber.MinorVersionNumber.PatchLevel

Linus Torvalds is the official release point for new kernels, although anyone can modify Linux (due to the GPL). Because Linus is the official release point, the Linux development and user community has a common baseline from which to work and communicate.


NOTE:  Be sure to read the Kernel HOWTO for up-to-date information before actually trying to build and configure a new kernel. If you mess up, you could render your system useless. You should also make sure to keep an older, working copy of a kernel around just in case of problems. You can then boot that kernel instead of the worthless kernel.

Configuring a New Kernel

To build a new kernel, you first need to configure the source code files. The source files should be located in the /usr/src/Linux directory. You also must have the C compiler package loaded. If you didn’t install that package during installation, use RPM to do so now with the following commands:


rpm –i kernel-source-2.0.34-0.6.i386.rpm

rpm –i gcc-2.7.2.3-11.i386.rpm

You may also have to install the kernel headers and various compiler libraries.


See “Installing Packages with RPM,” p. 150

First, you must get the new kernel sources or patches. The new sources are usually found on the Internet; check sunsite.unc.edu for the latest and greatest kernels. (If you’re modifying your current kernel, this step is, of course, unnecessary.) The source files are usually in a tar file and will need to be unarchived.


TIP:  Making a backup copy of your current kernel with the following commands is a very good idea:

cd /usr/src

cp Linux linux.sav

These commands copy the entire Linux source directory to another directory called linux.sav.


Next, you should use the patch command to apply any patch files. After preparing the source files, you can configure and build your new system. Depending on your personal preferences and hardware available, three methods are available for configuring the kernel: a text-based program, a text-based menu program, and if you have installed X Windows, an X-based program.


TIP:  In order to use kernel modules, you must answer Yes to kerneld support and module version (CONFIG_MODVERSIONS) support during your kernel configuration.


Previous Table of Contents Next