Installation guide
Appendix A.
Building a Custom Kernel
Many people new to Linux often ask, "Why should I build my own kernel?" Given the ad-
vances that have been made in the use of kernel modules, the most accurate response to
that question is, "Unless you already know why you need to build your own kernel, you
probably do not need to."
In the past, you had to recompile the kernel if you added new hardware on your system.
In other words, the kernel was static. Improvements in the Linux 2.0.x kernels allowed for
many hardware drivers to be modularized into components that are loaded on demand. How-
ever, major problems existed when users had multiple kernels that had been compiled for
different configuration options on their system; for example, SMP versus UP kernels. Fur-
ther Linux 2.4.x kernel modularization advancements allow for multiple kernels to co-exist
more easily, but they can not share modules.
For information on handling kernel modules see Chapter 24. Unless you are recompiling a
customized kernel for your system, you will not see many changes in how kernel modules
are handled.
A.1. Building a Modularized Kernel
The instructions in this section apply to building a modularized kernel. If you are interested
in building a monolithic kernel instead, see Section A.4 for an explanation of the different
aspects of building and installing a monolithic kernel.
The following steps will guide you through building a custom kernel for the x86 architecture:
Note
This example uses 2.4.18-0.12 as the kernel version. Your kernel version might differ. To determine
your kernel version, type the command uname -r. Replace 2.4.18-0.12 with your kernel version.
1. The most important step is to make sure that you have a working emergency boot disk
in case you make a mistake. If you did not make a boot disk during the installation,
use the mkbootdisk command to make one now. The standard command is similar to
mkbootdisk --device /dev/fd0 2.4.x (where 2.4.x is the full version of your ker-
nel such as 2.4.18-0.12). Once done, test the boot disk to make sure that it will boot the
system.
2. You must have the kernel-source package installed. Issue the command
rpm -q kernel-source to determine the package version, if it is installed.
If it is not installed, install them from the Red Hat Linux CD #1 or the Red
Hat FTP site available at ftp://ftp.redhat.com (a list of mirrors is available at
http://www.redhat.com/mirrors.html). Refer to Chapter 25 for information on
installing RPM packages.
3. Open a shell prompt and change to the directory /usr/src/linux-2.4. All commands
from this point forward must be executed from this directory.
4. It is important that you begin a kernel build with the source tree in a known condition.
Therefore, it is recommended that you begin with the command make mrproper. This