Certification Objective 8.02-New Kernels, the Easy Way

On the Red Hat exams, you may expected to upgrade your kernel by installing the latest Red Hat kernel RPM. You may be able to patch an existing kernel.

Before we begin, it's important to understand the way kernels are numbered.

Understanding Kernel Version Numbers

The version number associated with the RHEL kernel may look a little confusing, but it tells you a lot about the history of the kernel. The standard RHEL kernel is a version with a number like 2.6.18-8.el5, formatted in a majorversion.majorrevision .patch-build format.

The first number (2) is the major version number. These versions provide drastic changes to the kernel. Typically, older version software will not work in the newer version when this number changes. Kernel major version numbers are reserved for completely new kernel designs.

The second number (6) actually has two meanings. First, it indicates this is the sixth major revision of major version 2 of the kernel. Second, since it is an even number, it indicates that the kernel release is a stable release. Before version 2.6, an odd second number would indicate a developmental kernel, not suitable for production computers. Now, kernel version 2.7 will also be a production kernel.

On the Job 

To promote stability, Red Hat usually works from a slightly older, and presumably more stable, version of the Linux kernel. This is consistent with the demands of the Red Hat customer base; most business customers want to stay away from the "bleeding edge."

The third number (18) is the patch version number for the kernel. These changes are typically small changes, bug fixes, security fixes, and enhancements. Generally, you can use the zcat command to increment one patch at a time. For example, if your current kernel is version 2.6.18, you can use the patch-2.6.19.gz file to upgrade your kernel to version 2.6.19.

The fourth number (-8) is a number added by Red Hat. This is the eighth Red Hat version of Linux kernel 2.6.18, which incorporates features customized for Red Hat Enterprise Linux. In some cases, there will be a fifth and even a sixth number that indicates the build number as created by Red Hat. The final bit may be something like el5 or el5xen.

On the Job 

Stock kernels use a slightly different four-number system. The first two numbers are identical to the Red Hat system. The third number specifies a major patch; the fourth number specifies a bugfix or security update. If you use a stock kernel, it may overwrite Enterprise-level custom features developed for RHEL 5.

Upgrading Kernels

During the lifetime of any version of RHEL, you may run across a security advisory that strongly suggests that you upgrade your Linux kernel. In this case, a Red Hat kernel RPM will be available through the Red Hat Network.

image from book
Exam Watch

You won't have access to the Internet during the Red Hat exams, and therefore, you may not be able to get to the Red Hat Network for updates. However, the Exam Prep guide suggests that you may be required to install an upgraded kernel.

image from book

Upgrading a kernel from a Red Hat RPM is fairly easy. Basically, all you need to do is install the new kernel with the appropriate rpm or yum command. When properly configured, the RPM automatically upgrades your default boot loader as well. For example, say you've just downloaded the newest kernel RPM from the Red Hat Network to the /tmp directory.

image from book
Exam Watch

If you're told to upgrade a new kernel, you'll probably use the rpm -i kernel.rpm command, and not rpm -U kernel.rpm. Installing (and not upgrading) newer kernels allows you to boot into the older kernel-in case the new kernel does not work for you.

image from book

Be careful. Install (-i), don't upgrade (-U) your new kernel. Otherwise, if you have a problem, you won't be able to go back to the old working kernel. Installing (-i) a new kernel with a command such as

 # rpm -i /tmp/kernel-2.6.18-2.2.1.i686.rpm 

installs the kernel, initial RAM disk, System.map, and config files automatically in the /boot directory. In addition, the RPM automatically adds a new stanza to your boot loader configuration file. For GRUB, the file is /boot/grub/grub.conf.

If you're properly connected to an update repository such as the RHN, you may be able to download the new kernel and make updates directly with an even simpler command:

 # yum install kernel 

image from book
Exam Watch

The /boot/grub/grub.conf configuration file includes a hard link to /etc/grub.conf as well as a soft link to /boot/grub/menu.lst. You can open any of these file names in the text editor of your choice.

image from book

image from book
Exam Watch

To change the default boot stanza in GRUB, change the default variable. For example, if default=0, the default kernel loaded is the first stanza in /boot/grub/grub.conf. Similarly, if default=1, the default kernel loaded is the second stanza in /boot/grub/grub.conf.

image from book

Kernel Patches

Sometimes, all you need is a simple patch to a kernel. Patches usually work fairly well if you're upgrading from one patch version to the next higher version, such as from 2.6.21 to 2.6.22.

Kernel patches are easily available from Internet sites such as ftp.kernel.org. For example, if you want to upgrade from kernel version 2.6.21 to kernel version 2.6.22, download the patch-2.6.22.gz file from the Internet. Copy the patch to the /usr/src directory. Move to that directory, and run a command similar to the following to make the upgrade:

 # zcat patch-2.6.22.gz | patch -p0 

If it doesn't work, you'll see files with a .rej extension somewhere in your kernel source tree. Use a command such as find to check for such files. If you don't find any of these files, you can proceed with the make clean, make menuconfig, and make dep commands as described later in this chapter.

On the Job 

Generally, it's a bad idea to use a generic patch on a Red Hat built kernel. Red Hat Enterprise Linux kernels often include "backports," which already includes features found in later kernels.

Updating GRUB

If properly configured, the Red Hat kernel that you install should automatically update your boot loader. But as an RHCT or RHCE, you need to know how to check. If the code described in this chapter has not been added, you'll need to know how to add it.

It is advisable to keep your old kernel in case something goes wrong. So you'll be adding a stanza to /boot/grub/grub.conf. In any case, the changes that you'll make will be as if you're setting up two different operating systems.

Now look at your /boot/grub/grub.conf file. If you have Linux on your system and use GRUB, you should already have a stanza that points to the appropriate locations for your original Linux kernel and initial RAM disk. For example, here is an excerpt from my RHEL 5 /boot/grub/grub.conf file (which includes a dual-boot configuration with Microsoft Windows):

 title Red Hat Enterprise Linux Server (2.6.18-8.el5)     root (hd0,0)     kernel /vmlinuz- 2.6.18-8.el5 ro root=LABEL=/     initrd /initrd-2.6.18-8.el5.img title Microsoft Windows     rootnoverify (hd0,1)     chainloader +1 

In Red Hat Enterprise Linux, the vmlinuz and initrd files are already in the /boot directory. Since you've copied the revised kernels to the same directory, all you need is a second stanza that points to your revised files. If I recompile my kernel, I might change the Makefile in my source code directory to show EXTRAVERSION=-8.el5custom.

 title Red Hat Enterprise Linux Server (2.6.18-8.el5custom)     root (hd0,0)     kernel /vmlinuz-2.6.18-8.el5custom ro root=LABEL=/     initrd /initrd-2.6.18-8.el5custom.img title Red Hat Enterprise Linux Server (2.6.18-8.el5)     root (hd0,0)     kernel /vmlinuz-2.6.18-8.el5 ro root=LABEL=/     initrd /initrd-2.6.18-8.el5.img title DOS     rootnoverify (hd0,1)     chainloader +1 

Since you don't need to load /boot/grub/grub.conf into the MBR, no further action is required. Note how the original kernel is set as the default. If you've watched closely, you'll note that in /boot/grub/grub.conf, the value of default was changed from 0 to 1. If you want to set the default to the new kernel, change the value of default back to 0, as shown in Figure 8-4.

image from book
Figure 8-4: GRUB menu with original and recompiled kernels

RHCE Red Hat Certified Engineer Linux Study Guide (Exam RH302)
Linux Patch Management: Keeping Linux Systems Up To Date
ISBN: 0132366754
EAN: 2147483647
Year: 2004
Pages: 227
Authors: Michael Jang

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net