Today, continue on your path to RHCE certification. Learn about creating a new kernel the easy way, kernel sources, recompiling a kernel, and the cron and at systems. Take notes, because there's a test at the end. This comes from chapter five of Red Hat Certified Engineer Linux Study Guide (Exam RH302), fourth edition, by Michael Jang. (McGraw-Hill/Osborne, 2004, ISBN: 0-07-225365-7).
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 notwork 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.
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.
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.
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.
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:
# 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.
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.
Here is another example of the mkbootdisk command:
Normally, mkbootdisk has no output. This option turns the output on.
This command creates a boot disk on the secondfloppy 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 nondisclosure 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.
This is part one from the fifth chapter of Red Hat Certified Engineer Linux Study Guide (Exam RH302), fourth edition, by Michael Jang. (McGraw-Hill/Osborne, 2004, ISBN: 0-07-225365-7). Check it out at your favorite bookstore today. Buy this book now.