Before you can start rebuilding the kernel, you must locate, install, and clean the source code. If you want to use code that has not been customized (patched) by Red Hat, visit kernel.org. Locating the Source CodeWhen you have the kernel source on the system, the /usr/src directory will look similar to the following: $ ls -l /usr/src total 20 lrwxrwxrwx 1 root root 17 Jan 27 18:25 linux -> linux-2.6.15.i686 drwxr-xr-x 21 root root 4096 Jan 27 22:12 linux-2.6.15.i686 drwxr-xr-x 8 root root 4096 Jan 27 18:20 redhat In the preceding example, the name linux-2.6.15.i686 means that the directory contains version 2.6 of the Linux kernel, release 15, and is set up for a Pentium Pro (P6 core) architecture. The /usr/src directory is the traditional location for the kernel source. Also check whether the kernel code appears in /usr/src/redhat, as that is where it is installed by default. If it is there, see step 4 on page 528. If the source code is present on the system, skip to "Cleaning the Source Tree" on page 529. Installing the Source CodeWhen the source is not present on the system, you need to install it.
FEDORA Before you start, install rpmbuild. You will need this program to unpack and apply patches to the source files. The rpmbuild utility is part of the fedora-rpmdevtools package. You can use pirut (page 483) to install this package (the package is an optional package in Developer Tools) or you can issue the following yum command.
Install rpmbuild # yum install fedora-rpmdevtools With rpmbuild installed, follow these steps to install the kernel source code:
After you give these commands, the patched kernel source is located in /usr/src/linux. The rest of this chapter assumes that the kernel source is in this location.
RHEL Installing the kernel source code on a RHEL system is similar to installing it on FEDORA. Review the preceding procedure as you read this section for a better understanding of what each step does. Before you start, use up2date (page 494) to install two packages that you will need to install the kernel: # up2date redhat-rpm-config rpm-build Download the kernel source code: # up2date --get-source kernel Use rpm to install the kernel source code: # rpm -ivh /var/spool/up2date/kernel*.src.rpm After you install the code, unpack it and apply the patches: # cd /usr/src/redhat/SPECS # rpmbuild -bp --target $(arch) kernel-2.6.spec Finally, move the source tree to its classic location. See step 4, substituting the names of the kernel directories on the RHEL system for those in the example. Tip: Now the working directory is /usr/src/linux All commands in this section on building a kernel are given relative to the top-level directory that holds the kernel source. Traditionally this directory is /usr/src/linux. Make sure that this directory is your working directory before proceeding. If necessary, link the directory holding the kernel source in /usr/src to /usr/src/linux as explained in step 4. |