Certification Objective 5.04: New Kernels, the Easy Way

 < Day Day Up > 



On the Red Hat exams, you may be expected to upgrade your kernel by installing the latest Red Hat kernel RPM. You may be able to patch an existing kernel. Whatever you do, you should make a boot disk associated with your new or upgraded kernel with the mkbootdisk command.

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

Understanding Kernel Version Numbers

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

The first number (2) is the major version number. These are 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 (4) actually has two meanings. First, it indicates this is the fourth 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. If it were an odd number, it would be a developmental kernel, not suitable for production computers.

On The Job 

While Linux kernel 2.6 has been officially released, Red Hat has already incorporated a number of associated features in the RHEL 3 kernel. To promote stability, Red Hat has no plans as of this writing to incorporate or offer a version of Linux kernel 2.6 for RHEL 3. This is consistent with the demands of the RHEL 3 customer base; most business customers want to stay away from the 'bleeding edge.'

The third number (21) 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.4.21, you can use the patch-2.4.22.gz file to upgrade your kernel to version 2.4.22.

The fourth number (-4.EL) is a number added by Red Hat. This is the fourth Red Hat build of Linux kernel 2.4.21, which incorporates features customized for Red Hat Enterprise Linux.

Some Linux software, such as firewalls, are associated with a specific Linux kernel. The requirements are associated only with the first two major numbers. For example, the older ipchains firewall command works only with version 2.2 and later kernels. In contrast, the iptables firewall commands require version 2.4 and later kernels.

Upgrading Kernels

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

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, you may still be required to install an upgraded kernel.

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 command. When properly configured, the RPM automatically upgrades your default boot loader as well. For example, say you've just downloaded the 2.4.21-4.1.EL kernel RPM from one of the FTP servers with Red Hat RPMs to the /tmp directory.

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 use the older kernel, in case the new kernel does not work for you.

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.4.21-4.1.EL.i386.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 /etc/grub.conf.

Exam Watch 

The /etc/grub.conf configuration file is linked to the actual GRUB configuration file, /boot/grub/grub.conf. You can open either filename in the text editor of your choice.

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.4.21 to 2.4.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.4.21 to kernel version 2.4.22, download the patch-2.4.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:

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.

# zcat patch-2.4.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 in the next section.

On The Job 

Generally, it may not be advisable to patch a Red Hat built kernel on your Red Hat systems. Different build versions of Red Hat Enterprise Linux kernels often incorporate changes that are part of generic Linux kernel patches.

mkbootdisk

The mkbootdisk utility creates a boot disk customized for your configuration. This is basically a rescue disk. After creating this disk, you can use it to simply boot your system, or you can type rescue at the boot prompt. Whenever you upgrade or install a new kernel, you should upgrade your boot disk. It's a simple command; in most cases, all you need to do is specify the version number associated with the desired kernel as follows:

# mkbootdisk 2.4.21-4.1EL

This command automatically takes the kernel with the specified version number from the /boot directory and writes it with appropriate configuration information to the first floppy drive, /dev/fd0. Table 5-2 lists several other options that may come in handy when using mkbootdisk.

Table 5-2: mkbootdisk Command Switches

Command

Description

--device device file

Specifies where to put the image.

--mkinitrdargs args

Passes arguments to mkinitrd.

--noprompt

Won't prompt to insert a disk.

--verbose

Normally, mkbootdisk has no output. This option turns the output on.

Here is another example of the mkbootdisk command:

# mkbootdisk --device /dev/fd1 --verbose --noprompt 2.4.21-4.1.EL

This command creates a boot disk on the second floppy drive. It does not suppress output, nor does it prompt for a disk to be inserted. It uses kernel version 2.4.21-4.1.EL. When you boot Linux with this disk, you can use it as a rescue disk. Just type linux rescue at the boot prompt.

On The Job 

By default, the first floppy drive on a PC is associated with /dev/fd0; the second floppy drive is associated with /dev/fd1.

Exam Watch 

A significant portion of the practical exam tests your ability to recover a system that has failed in some way. While I am prohibited by the Red Hat non-disclosure agreement from providing the exact nature of the problems, I can say that being able to use rescue disks is a very important Linux administration skill.

Updating Your Boot Loader

If properly configured, the Red Hat kernel that you install should automatically update your boot loader. But as a 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.

Whether you're using GRUB or LILO, it is advisable to keep your old kernel in case something goes wrong. So you'll be adding a stanza to either /etc/grub.conf or /etc/lilo.conf. In either case, the changes that you'll make will be as if you're setting up two different operating systems.

Updating GRUB

Look at your /etc/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 3 /etc/grub.conf file (which includes a dual-boot configuration with Microsoft Windows):

title Red Hat Enterprise Linux ES (2.4.21-4.EL)     root (hd0,0)     kernel /vmlinuz-2.4.21-4.EL ro root=LABEL=/     initrd /initrd-2.4.21-4.EL.img title DOS     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. When I revised my kernel earlier in this chapter, my EXTRAVERSION variable in /usr/src/linux-2.4/Makefile was -4.ELcustom. The changes are in bold:

title Red Hat Enterprise Linux ES (2.4.21-4.EL)     root (hd0,0)     kernel /vmlinuz-2.4.21-4.EL ro root=LABEL=/     initrd /initrd-2.4.21-4.EL.img title Red Hat Enterprise Linux ES (2.4.21-4.ELcustom)     root (hd0,0)     kernel /vmlinuz-2.4.21-4.ELcustom ro root=LABEL=/     initrd /initrd-2.4.21-4.ELcustom.img title DOS     rootnoverify (hd0,1)     chainloader +1

Since you don't need to load /etc/grub.conf into the MBR, no further action is required. The resulting GRUB menu looks like Figure 5-10. Note how the original kernel is set as the default. If you've watched closely, you'll note that in /etc/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.

click to expand
Figure 5-10: GRUB menu with original and recompiled kernels

Updating LILO

Alternatively, if you're using LILO as a boot loader, you'll need to revise /etc/lilo.conf. Add a stanza that points to the new kernel. Take a look at the following excerpt from /etc/lilo.conf:

image=/boot/vmlinuz-2.4.21-4.EL       label=linux       initrd=/boot/initrd-2.4.21-4.EL       read-only       append="root=LABEL=/" 

From this information, you can see that the original kernel is called vmlinuz-2.4.21-4.EL. Assume LILO resides on the MBR and controls the boot process.

Now add another stanza for the new kernel.

image=/boot/vmlinuz-2.4.21-4.EL       label=linux       initrd=/boot/initrd-2.4.21-4.EL       read-only       append="root=LABEL=/" image=/boot/vmlinuz-2.4.21-4.ELcustom       label=linux       initrd=/boot/initrd-2.4.21-4.ELcustom       read-only       append="root=LABEL=/" 

Save this file, then run the lilo -v command. The output should resemble the following:

LILO version 21.4-4, Copyright (C) 1992-1998 Werner Almesberger 'lba32' extensions Copyright (C) 1999,2000 John Coffman Reading boot sector from /dev/hda Merging with /boot/boot.b Mapping message file /boot/message Boot image: /boot/vmlinuz-2.4.21-4.EL Mapping RAM disk /boot/initrd-2.4.21-4.EL Added linux * Boot image: /boot/vmlinuz-2.4.21-4.ELcustom Added newLinux Backup copy of boot sector in /boot/boot.0300 Writing boot sector.

When you reboot, LILO will wait for you to enter a label, in this case, either linux or newLinux.

Exam Watch 

Although there are references to both GRUB and LILO in the RHCT and RHCE exam curricula, Red Hat is focusing on GRUB and has 'deprecated' LILO. Therefore, I believe you can expect to work with GRUB on the Red Hat exams.



 < Day Day Up > 



RCHE Red Hat Certified Engineer Linux Study Guide[c] Exam (Rh302)
RCHE Red Hat Certified Engineer Linux Study Guide[c] Exam (Rh302)
ISBN: 71765654
EAN: N/A
Year: 2003
Pages: 194

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