The Red Hat Linux kernel is custom built by the Red Hat kernel team to ensure its integrity and compatibility with supported hardware. Before Red Hat releases a kernel, it must first pass a rigorous set of quality assurance tests.
Red Hat Linux kernels are packaged in RPM format so that they are easy to upgrade and verify. For example, when the kernel RPM package distributed by Red Hat, Inc. is installed, an initrd image is created; thus, it is not necessary to use the mkinitrd command after installing a different kernel. It also modifies the boot loader configuration file to include the new kernel if either GRUB or LILO is installed.
This chapter discusses the steps necessary to upgrade the kernel on an x86 system only.
Warning: Building a custom kernel is not supported by the Red Hat Linux Installation Support Team.
The 2.4 Kernel
Red Hat Linux ships with a custom 2.4 kernel, which offers the following features:
The directory for the kernel source is /usr/src/linux-2.4/ instead of /usr/src/linux/.
Support for the ext3 file system.
Multi-processor (SMP) support.
Preliminary support for IEEE 1394, also referred to as FireWire™, devices.
Before upgrading the kernel, take a few precautionary steps. The first step is to make sure a working boot diskette exists for the system in case a problem occurs. If the boot loader is not configured properly to boot the new kernel, the system cannot be booted into Red Hat Linux without a working boot diskette.
To create the boot diskette, login as root at a shell prompt, and type the following command:
/sbin/mkbootdisk `uname -r`
Reboot the machine with the boot diskette and verify that it works before continuing.
Hopefully, the diskette will not be needed, but store it in a safe place just in case.
To determine which kernel packages are installed, execute the following command at a shell prompt:
rpm -qa | grep kernel
The output contains some or all of the following packages, depending on what type of installation was performed (the version numbers and packages may differ):
From the output, determine which packages need to be download for the kernel upgrade. For a single processor system, the only required package is the kernel package.
If the computer has more than one processor, the kernel-smp package that contains support for multiple processors must be installed for the system to use more than one processor. It is highly recommended that the kernel package also be installed in case the multi-processor kernel does not work properly for the system.
If the computer has more than four gigabytes of memory, the kernel-bigmem package must be installed for the system to use more than four gigabytes of memory. Again, it is highly recommended that the kernel package is installed for debugging purposes. The kernel-bigmem package is only built for the i686 architecture.
If PCMCIA support is needed (such as on a laptop), the kernel-pcmcia-cs package is necessary. The kernel-source package is not needed unless a recompile of the kernel is desired or the system is used for kernel development.
The kernel-doc package contains kernel development documentation and is not required. It is recommended if the system is used for kernel development.
The kernel-util package includes utilities that can be used to control the kernel or the system's hardware. It is not required.
Red Hat builds kernels that are optimized for different x86 versions. The options are athlon for AMD Athlon™ and AMD Duron™ systems, i686 for Intel® Pentium® II, Intel® Pentium® III, and Intel® Pentium® 4 systems, and i586 for Intel® Pentium® and AMD K6™ systems. If the version of the x86 system is unknown, use the kernel built for the i386 version; it is built for all x86-based systems.
The x86 version of the RPM package is included in the file name. For example, kernel-2.4.20-2.47.1.athlon.rpm is optimized for AMD Athlon™ and AMD Duron™ systems and kernel-2.4.20-2.47.1.i686.rpm is optimized for Intel® Pentium® II, Intel® Pentium® III, and Intel® Pentium® 4 systems. After determining which packages are needed to upgrade the kernel, select the proper architecture for the kernel, kernel-smp, and kernel-bigmem packages. Use the i386 versions of the other packages.
There are several ways to determine if there is an updated kernel available for the system.
Go to http://www.redhat.com/apps/support/errata/, choose the appropriate version of Red Hat Linux, and view the errata for it. Kernel errata are usually under the Security Advisories section. From the list of errata, click on the kernel errata to view the detailed errata report for it. In the errata report, there is a list of required RPM packages and a link to download from the Red Hat FTP site. They can also be downloaded them from a Red Hat FTP mirror site. A list of mirror sites is available at http://www.redhat.com/download/mirror.html.
Use Red Hat Network to download the kernel RPM packages and install the packages. Red Hat Network can download the latest kernel, upgrade the kernel on the system, create an initial RAM disk image if needed, and configure the boot loader to boot the new kernel. For more information, refer to the Red Hat Network User Reference Guide available at http://www.redhat.com/docs/manuals/RHNetwork/.
Performing the Upgrade
After retrieving all the necessary packages, it is time to upgrade the existing kernel. At a shell prompt as root, change to the directory that contains the kernel RPM packages and follow these steps.
Important: It is strongly recommended that the old kernel is kept in case there are problems with the new kernel.
Use the -i argument with the rpm command to keep the old kernel. If the -U option is used to upgrade the kernel package, it will overwrite the currently installed kernel. The kernel version and x86 version might vary):
rpm -ivh kernel-2.4.20-2.47.1.i386.rpm
If the system is a multi-processor system, install the kernel-smp packages as well (the kernel version and x86 version might vary):
rpm -ivh kernel-smp-2.4.20-2.47.1.i386.rpm
If the system is i686-based and contains more than 4 gigabytes of RAM, install the kernel-bigmem package built for the i686 architecture as well (the kernel version might vary):
rpm -ivh kernel-bigmem-2.4.20-2.47.1.i686.rpm
If the kernel-source, kernel-docs, or kernel-utils packages are to be upgraded, the older versions are probably not needed. Use the following commands to upgrade these packages (the versions might vary):
rpm -Uvh kernel-source-2.4.20-2.47.1.i386.rpm
rpm -Uvh kernel-docs-2.4.20-2.47.1.i386.rpm
rpm -Uvh kernel-utils-2.4.20-2.47.1.i386.rpm
If the system requires PCMCIA support (for example, a laptop), install the kernel-pcmcia-cs and keep the old version. If the -i switch is used, it usually returns a conflict because the older kernel needs this package to boot with PCMCIA support. To work around this, use the --force switch as follows (the version might vary):
rpm -ivh --force kernel-pcmcia-cs-3.1.24-2.i386.rpm
The next step is to verify that the initial RAM disk image has been created.
Verifying the Initial RAM Disk Image
If the system uses the ext3 file system or a SCSI controller, an initial RAM disk is needed. The purpose of the initial RAM disk is to allow a modular kernel to have access to modules that it might need to boot from before the kernel has access to the device where the modules normally reside.
The initial RAM disk can be created with the mkinitrd command. However, this step is performed automatically if the kernel and its associated packages are installed or upgraded from the RPM packages distributed by Red Hat, Inc.; thus, it does not need to be executed manually. To verify that it was created, use the command ls -l /boot to make sure the initrd-2.4.20-2.47.1.img file was created (the version should match the version of the kernel just installed).
The next step is to verify that the boot loader has been configured to boot the new kernel.
Verifying the Boot Loader
The kernel RPM package configures the GRUB or LILO boot loader to boot the newly installed kernel if either boot loader is installed. However, it does not configure the boot loader to boot the new kernel by default.
It is always a good idea to confirm that the boot loader has been configured correctly. This is a crucial step. If the boot loader is configured incorrectly, the system will not boot into Red Hat Linux properly. If this happens, boot the system with the boot diskette created earlier and try configuring the boot loader again.
If GRUB is used as the boot loader, confirm that the file /boot/grub/grub.conf contains a title section with the same version as the kernel package just installed (if the kernel-smp or kernel-bigmem package was installed as well, a section will exist for it as well):
# Note that you do not have to rerun grub after making changes to this file
# NOTICE: You have a /boot partition. This means that
# all kernel and initrd paths are relative to /boot/, eg.
# root (hd0,0)
# kernel /vmlinuz-version ro root=/dev/hda2
# initrd /initrd-version.img
title Red Hat Linux (2.4.20-2.47.1)
kernel /vmlinuz-2.4.20-2.47.1 ro root=LABEL=/
title Red Hat Linux (2.4.20-2.30)
kernel /vmlinuz-2.4.20-2.30 ro root=LABEL=/
If a separate /boot partition was created, the paths to the kernel and initrd image are relative to the /boot partition.
Notice that the default is not set to the new kernel. To configure GRUB to boot the new kernel by default, change the value of the default variable to the title section number for the title section that contains the new kernel. The count starts with 0. For example, if the new kernel is the second title section, set default to 1.
Begin testing the new kernel by rebooting the computer and watching the messages to ensure that the hardware is detected properly.
If LILO is used as the boot loader, confirm that the file /etc/lilo.conf contains an image section with the same version as the kernel package just installed (if the kernel-smp or kernel-bigmem package was installed, a section will exist for it as well):
Notice that the default is not set to the new kernel. To configure LILO to boot the new kernel by default, set the default variable to the value of label in the image section for the new kernel. Run the /sbin/lilo command as root to enable the changes. After running it, the output will be similar to the following:
Added 2.4.20-2.47.1 *
The * after 2.4.20-2.47.1 means the kernel in that section is the default kernel that LILO will boot.
Begin testing the new kernel by rebooting the computer and watching the messages to ensure the hardware is detected properly.
The Linux kernel has a modular design. At boot time, only a minimal resident kernel is loaded into memory. Thereafter, whenever a user requests a feature that is not present in the resident kernel, a kernel module, sometimes referred to as a driver, is dynamically loaded into memory.
During installation, the hardware on the system is probed. Based on this probing and the information provided by the user, the installation program decides which modules need to be loaded at boot time. The installation program sets up the dynamic loading mechanism to work transparently.
If new hardware is added after installation and the hardware requires a kernel module, the system must be configured to load the proper kernel module for the new hardware. When the system is booted with the new hardware, the Kudzu program runs, detects the new hardware if it is supported, and configures the module for it. The module can also be specified manually by editing the module configuration file, /etc/modules.conf.
Note: Video card modules used to display the X Window System interface are part of the XFree86 package, not the kernel; thus, this chapter does not apply to them.
For example, if a system included an SMC EtherPower 10 PCI network adapter, the module configuration file contains the following line:
alias eth0 tulip
If a second network card is added to the system and is identical to the first card, add the following line to /etc/modules.conf:
alias eth1 tulip
Kernel Module Utilities
A group of commands for managing kernel modules is available if the modutils package is installed. Use these commands to determine if a module has been loaded successfully or when trying different modules for a piece of new hardware.
The command /sbin/lsmod displays a list of currently loaded modules. For example:
Module Size Used by Not tainted
iptable_filter 2412 0 (autoclean) (unused)
ip_tables 15864 1 [iptable_filter]
nfs 84632 1 (autoclean)
lockd 59536 1 (autoclean) [nfs]
sunrpc 87452 1 (autoclean) [nfs lockd]
soundcore 7044 0 (autoclean)
ide-cd 35836 0 (autoclean)
cdrom 34144 0 (autoclean) [ide-cd]
parport_pc 19204 1 (autoclean)
lp 9188 0 (autoclean)
parport 39072 1 (autoclean) [parport_pc lp]
autofs 13692 0 (autoclean) (unused)
e100 62148 1
microcode 5184 0 (autoclean)
keybdev 2976 0 (unused)
mousedev 5656 1
hid 22308 0 (unused)
input 6208 0 [keybdev mousedev hid]
usb-uhci 27468 0 (unused)
usbcore 82752 1 [hid usb-uhci]
ext3 91464 2
jbd 56336 2 [ext3]
For each line, the first column is the name of the module, the second column is the size of the module, and the third column is the use count.
The information after the use count varies slightly per module. If (unused) is listed on the line for the module, the module is currently not being used. If (autoclean) is on the line for the module, the module can be autocleaned by the rmmod -a command. When this command is executed, any modules that are tagged with autoclean, that have not been used since the previous autoclean action, are unloaded. Red Hat Linux does not perform this autoclean action by default.
If a module name is listed at the end of the line in brackets, the module in the brackets is dependent on the module listed in the first column of the line. For example, in the line
usbcore 82752 1 [hid usb-uhci]
the hid and usb-uhci kernel modules depend on the usbcore module.
The /sbin/lsmod output is the same as the output from viewing /proc/modules.
To load a kernel module, use the /sbin/modprobe command followed by the kernel module name. By default, modprobe attempts to load the module from the /lib/modules//kernel/drivers/ subdirectories. There is a subdirectory for each type of module, such as the net/ subdirectory for network interface drivers. Some kernel modules have module dependencies, meaning that other modules must be loaded first for it to load. The /sbin/modprobe command checks for these dependencies and loads the module dependencies before loading the specified module.
For example, the command
loads any module dependencies and then the hid module.
To print to the screen all commands as /sbin/modprobe executes them, use the -v option. For example:
/sbin/modprobe -v hid
Output similar to the following is displayed:
Symbol version prefix 'smp_'
The /sbin/insmod command also exists to load kernel modules; however, it does not resolve dependencies. Thus, it is recommended that the /sbin/modprobe command be used.
To unload kernel modules, use the /sbin/rmmod command followed by the module name. The rmmod utility only unloads modules that are not in use and that are not a dependency of other modules in use.
For example, the command
unloads the hid kernel module.
Another useful kernel module utility is modinfo. Use the command /sbin/modinfo to display information about a kernel module. The general syntax is:
Options include -d which displays a brief description of the module and -p which lists the parameters the module supports. For a complete list of options, refer to the modinfo man page (man modinfo).
lsmod man page — description and explanation of its output.
insmod man page — description and list of command line options.
modprobe man page — description and list of command line options.
rmmod man page — description and list of command line options.
modinfo man page — description and list of command line options.
/usr/src/linux-2.4/Documentation/modules.txt — how to compile and use kernel modules.