-->
Previous Table of Contents Next


Compiling the New Kernel

After you answer the various questions to configure your new kernel, you must compile it. The following commands will build the new kernel:


make dep

make clean

make

The build process can take anywhere from a few minutes to many hours, depending on your hardware. So relax and order another pizza!

When the compilation is complete, you need to set up your system to use the new kernel on boot. The new kernel is /usr/src/linux/arch/i386/boot/zImage, and you need to copy this image into the boot directory. But before that you should create a copy of your current kernel image, just in case something goes wrong. To save the old kernel use the following command:


mv /boot/vmlinuz.old /boot/vmlinuz.old

Then you can copy over the new kernel with this command:


cp /usr/src/linux/arch/i386/boot/zImage /boot/vmlinuz


See “Configuring LILO,” p. 214

To change the default kernel that Linux boots into, you edit the /etc/lilo.conf file and add another entry for a new kernel. The example in Listing 13.1 shows the addition of the older kernel to the list of operating systems the machine can boot. To do this, you must rename /boot/vmlinuz to /boot/vmlinuz.old with the above commands and then change its label to “old” in lilo.conf as shown in Listing 13.1.

Listing 13.1 A Sample /etc/lilo.conf File


boot=/dev/hda

     map=/boot/map

     install=/boot/boot.b

     prompt

     timeout=50

     image=/boot/vmlinuz

             label=linux

             initrd=/boot/initrd

             root=/dev/hda1

             read-only

     image=/boot/vmlinuz.old

             label=old

             root=/dev/hda1

             read-only

After making the changes to /etc/lilo.conf, run the following command


/sbin/lilo -v

and the updated lilo will be written to the boot device. From then on when you reboot, the machine will boot into the new kernel (linux) as default instead of the older kernel, with a 50-second delay to give you time to choose the old kernel at the boot prompt if you want to boot that kernel.

Building a Modularized Kernel

With the introduction of modularization in the Linux 2.0.x kernel, there have been some significant changes in building customized kernels. In the past, you were required to compile support into your kernel if you wanted to access a particular hardware or filesystem component. For some hardware configurations, the size of the kernel could quickly reach a critical level, so to require ready support for items that were used only occasionally was an inefficient use of system resources. With the capabilities of the 2.0.x kernel, if certain hardware components or filesystems are used infrequently, driver modules for them can be loaded on demand. To see the current modules in use, use the following command:


lsmod

The output, shown below, lets you know what modules are loaded and how they loaded, as well as how many pages of memory they are using:


Module         Pages    Used by

isofs              5            1 (autoclean)

ne2k-pci           1            1 (autoclean)

8390               2    [ne2k-pci]      0 (autoclean)

BusLogic          20            4

Only Red Hat Linux/Intel and Red Hat Linux/SPARC support modular kernels; Red Hat Linux/Alpha users must build a monolithic kernel as described in the earlier section “Building a New Kernel.” These instructions provide you with the knowledge required to take advantage of the power and flexibility available through kernel modularization.


NOTE:  You need to have already installed the kernel-headers and kernel-source packages. Also, you must issue all commands from the /usr/src/linux directory.

To make the modules, go to /usr/src/linux and run the following command:


make modules

Then use this command to install the modules run:


make modules-install

Working with Kernel Modules

Now that you have compiled and installed the modules, you are ready to extend your kernel with loadable modules. Table 13.2 shows the basic commands that are available.

Table 13.2 Module Commands Available in Linux
Command Description

lsmod Lists the modules currently loaded in the kernel
insmod Inserts a specified module into the kernel
rmmod Removes the specified module from the kernel
depmod Creates a dependency file for use by modprobe
modprobe Loads modules from a list generated by depmod

If you are running X Windows, you can take advantage of the kerneld daemon from the Control Panel (shown in Figure 13.5) to work with modules from a GUI instead of from a command line. Clicking this button brings up the Kernel Configurator dialog box shown in Figure 13.6.


FIG. 13.5  The kerneld menu button. The Control Panel provides access to many administrative functions, including working with kerneld.


FIG. 13.6  The Kernel Configurator dialog box. Working with kernel modules is easy with the X interface to kerneld.

To list the currently loaded modules, use the lsmod command. To add a module you have compiled to the kernel, either you can use the following command


insmod module-name

or you can click the Add button on the kerneld dialog box and specify the module (see Figure 13.7).


FIG. 13.7  The Choose Module Type dialog box. Adding modules is a breeze using X Windows.

To delete a module from the kernel, either use this command


rmmod module-name

or select the module from the list displayed in Figure 13.6 and click the Remove button.

Restarting kerneld

The changes you make with the Kernel Daemon Configuration tool will be made in the /etc/conf.modules file, which kerneld reads whenever it is started. Listing 13.2 provides a sample listing.

Listing 13.2 A Sample /etc/conf.modules File


alias scsi_hostadapter BusLogic

alias eth0 ne2k-pci

To restart kerneld, you can use the tool shown in Figure 13.6 and click the Restart Kerneld button. You can also restart the daemon via the command line, as shown here:


/etc/rc.d/init.d/kerneld stop

/etc/rc.d/init.d/kerneld start

Restarting kerneld does not cause any modules that are currently in use to be reloaded, but kerneld will use the configuration when it loads modules in the future.


Previous Table of Contents Next