To build a custom kernel (perform all these steps as root):
Note | |
---|---|
This example uses 2.4.21-1.1931.2.399.ent as the kernel version (the kernel version might differ). To determine the kernel version, type the command uname -r and replace 2.4.21-1.1931.2.399.ent with the kernel version that is returned. |
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.
It is important that kernel build starts with the source tree in a known condition. Therefore, it is recommended that the command make mrproper is issued first to remove any configuration files along with the remains of any previous builds that may be scattered around the source tree. If an existing configuration file already exists as the file /usr/src/linux-2.4/.config, back it up to a different directory before running this command and copy it back afterward.
It is recommended that the configuration of the default Red Hat Enterprise Linux kernel be used as a starting point. To do this, copy the configuration file for the system's architecture from the /usr/src/linux-2.4/configs/ directory to /usr/src/linux-2.4/.config. If the system has more than one processor, copy the file that contains the keyword smp. However, if the system has more than four gigabytes of memory, copy the file that contains the keyword hugemem.
Next, customize the settings. The recommended method is to use the command make menuconfig to run the Linux Kernel Configuration program. The X Window System is not required.
After finishing the configuration, select Exit and select Yes to save the new kernel configuration file (/usr/src/linux-2.4/.config).
Even if no changes were made to any of the settings, running the make menuconfig command (or one of the other methods for kernel configuration) is required before continuing.
Other available methods for kernel configuration include:
make config — An interactive text program. Components are presented in a linear format and answered one at a time. This method does not require the X Window System and does not allow answers to be changed for previous questions.
make xconfig — The method requires the X Window System and the tk package. This method is not recommended because it does not parse the configuration files reliably.
make oldconfig — This is a non-interactive script that reads the existing configuration file (.config) and only prompts for answers to any new questions that did not previously exist.
Note | |
---|---|
To use kmod and kernel modules answer Yes to kmod support and module version (CONFIG_MODVERSIONS) support during the configuration. |
After creating a /usr/src/linux-2.4/.config file, use the command make dep to set up the dependencies correctly.
Use the command make clean to prepare the source tree for the build.
It is recommended that the custom kernel have a modified version number so that the existing kernel is not overwritten. The method described here is the easiest to recover from in the event of a mishap. For other possibilities, details can be found at http://www.redhat.com/mirrors/LDP/HOWTO/Kernel-HOWTO.html or in the Makefile in /usr/src/linux-2.4/.
By default, /usr/src/linux-2.4/Makefile includes the word custom at the end of the line beginning with EXTRAVERSION. Appending the string allows the system to have the old working kernel and the new kernel (version 2.4.21-1.1931.2.399.entcustom) on the system at the same time.
If the system contains more than one custom kernel, a good method is to append the date at the end (or another identifier).
For x86, AMD64, and Intel® EM64T, build the kernel with make bzImage. For the Itanium architecture, build the kernel with make compressed. For the S/390 and zSeries architectures, build the kernel with make image. For the iSeries and pSeries architectures, build the kernel with make boot.
Build any modules configured with make modules.
Use the command make modules_install to install the kernel modules (even if nothing was actually built). Notice the underscore (_) in the command. This installs the kernel modules into the directory path /lib/modules/<KERNELVERSION>/kernel/drivers (where KERNELVERSION is the version specified in the Makefile). In this example it would be /lib/modules/2.4.21-1.1931.2.399.entcustom/kernel/drivers/.
Use make install to copy the new kernel and its associated files to the proper directories.
In addition to installing the kernel files in the /boot directory, this command also executes the /sbin/new-kernel-pkg script that builds a new initrd image and adds new entries to the boot loader configuration file.
If the system has a SCSI adapter and the SCSI driver was compiled as a module or if the kernel was built with ext3 support as a module (the default in Red Hat Enterprise Linux), the initrd image is required.
Even though the initrd image and boot loader modifications are made, verify that they were done correctly and be sure to use the custom kernel version instead of 2.4.21-1.1931.2.399.ent. Refer to Section 39.5 Verifying the Initial RAM Disk Image and Section 39.6 Verifying the Boot Loader for instructions on verifying these modifications.