next up previous contents index
Next: 5.2.2 Making an initrd Up: 5.2 Building a Custom Previous: 5.2 Building a Custom

5.2.1 Building a modularized kernel

These instructions provide you with the knowledge required to take advantage of the power and flexibility available through kernel modularization. If you do not wish to take advantage of modularization see section 5.2.3 for an explaination of the different aspects of building and installing a monolithic kernel. It is assumed that the kernel-source rpm has been previously installed and all commands are issued in the directory usr/src/linux. It is important to 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 will remove any configuration files along with the remains of any previous builds that may be scattered around the source tree. Now you must create a configuration file that will determine which components to include in your new kernel. Depending upon your hardware and personal preferences there are three methods available to configure the kernel.

In order to use kerneld (See section 8.6 for details) and kernel modules you must answer ``Yes'' to kerneld support and module version (CONFIGMODVERSIONS) support in the configuration. If you want to build a kernel with a configuration file ( /usr/src/linux/.config) that you have already created with one of the above methods, you can omit the make mrproper and make config commands and use the command make dep followed by make clean to prepare the source tree for the build.

The next step consists of the actual compilation of the source code components into a working program that your machine can use to boot. The method described here is the easiest to recover from in the event of a mishap. If you are interested in other possibilities details can be found in the Kernel-HOWTO or the Makefile in /usr/src/linux on your Linux system.

If you have a SCSI adapter and made your SCSI driver modular, build a new initrd image, see section 5.2.2 for details. Note that there is no practical reason to make the SCSI driver modular in a custom kernel.

In order to provide a redundant boot source to protect from a possible error in a new kernel you should keep the original kernel available. Adding a kernel to the LILO menu is as simple as renaming the original kernel in /boot, copying the new kernel to /boot, adding a few lines in /etc/lilo.conf and running /sbin/lilo. Here is an example of the default /etc/lilo.conf file shipped with Red Hat Linux:

boot=/dev/hda
map=/boot/map
install=/boot/boot.b
prompt
timeout=100
image=/boot/vmlinuz
        label=linux
        root=/dev/hda1
        read-only

Now you must update /etc/lilo.conf. If you built a new initrd image you must tell LILO to use it. In this example of /etc/lilo.conf we have added four lines at the bottom of the file to indicate another kernel to boot from. We have renamed /boot/vmlinuz to /boot/vmlinuz.old and changed its label to ``old''. We have also added an initrd line for the new kernel:

boot=/dev/hda
map=/boot/map
install=/boot/boot.b
prompt
timeout=100
image=/boot/vmlinuz
        label=linux
	initrd=/boot/initrd
        root=/dev/hda1
        read-only
image=/boot/vmlinuz.old
        label=old
        root=/dev/hda1
        read-only
  Now when the system boots and you press at the LILO boot: prompt two choices will be shown;

LILO boot:
linux    old

To boot the new (``linux'') kernel simply press Enter or wait for LILO to timeout. If you want to boot the old kernel (``old'') all you have to do is type ``old'' and then press Enter.

Here is a summary of the steps;

To test your new kernel reboot your computer and observe the screen messages as they scroll by.


next up previous contents index
Next: 5.2.2 Making an initrd Up: 5.2 Building a Custom Previous: 5.2 Building a Custom

Red Hat Software