Since upgrading your kernel can be tricky, you should probably only do so when you absolutely have to. Typical reasons for this include:
You have installed newer hardware that wasn't previously supported.
Drivers for the hardware you do have are updated and you need to use them.
Most Important: Security holes have been found in earlier kernels and are fixed in the latest kernel.
Check to make sure that you have enough space for your kernel in /boot before you install the new kernel!
The usual steps on upgrading your kernel are to find out what you have installed already on your machine, and then compare it with what you need to have on your machine. You can find out what you have installed on the system with the rpm command. You need to make sure that you have the latest RPMs that are required from ftp://updates.redhat.com or the upgrade will fail.
An important first step is to find out what version of the kernel RPMs you currently have installed on the system. Be sure to write down what versions you have installed. On a Red Hat Linux 5.2 system, you should get back information similar to this:
$ rpm -q kernel kernel-headers kernel-ibcs kernel-pcmcia-cs kernel-source kernel-2.0.36-0.7 kernel-headers-2.0.36-0.7 kernel-ibcs-2.0.36-0.7 kernel-pcmcia-cs-2.0.36-0.7 kernel-source-2.0.36-0.7 $ rpm -q mkinitrd SysVinit initscripts mkinitrd-1.8-3 SysVinit-2.74-5 initscripts-3.78-1
If you have Red Hat Linux 4.2 on your machine, you will need to change the query slightly to reflect name changes in packages that occurred in the Red Hat Linux 5.x series of releases.
$ rpm -q kernel kernel-headers kernel-source iBCS pcmcia-cs kernel-2.0.35-0 kernel-headers-2.0.35-0 kernel-modules-2.0.35-0 kernel-source-2.0.35-0 iBCS-2.0-8 pcmcia-cs-2.9.12-0 $ rpm -q mkinitrd SysVinit initscripts mkinitrd-1.7-1 initscripts-2.96-1 SysVinit-2.64-8
Alternatively, you can also find all kernel RPM packages with the following command. This is the recommended way to find any installed RPM packages that share a common name.
$ rpm -qa | grep 'kernel' kernel-headers-2.4.0-0.26 kernel-ibcs-2.2.16-22 kernel-doc-2.2.16-22 kernel-utils-2.2.16-22 kernel-source-2.2.16-22 kernel-2.2.16-22 kernel-pcmcia-cs-2.2.16-22
The next step in this upgrade is to get the latest updates for your system. You can normally use ftp://updates.redhat.com to find the most recent RPM updates, but if you find it busy, you may want to try http://www.redhat.com/download/mirror.html to discover a mirror site near to you.
Compare the list of RPMs you see on the FTP site with the ones you have installed on your machine. If the RPMs on the FTP site have larger revision numbers, download those RPMs. If an RPM package on your system is not listed on the FTP site, then you do not need to worry about it.
It can be difficult to download multiple files using a web browser, especially over a slower connection. An FTP client program, such as ncftp can be much easier to use for this purpose.
The following example demonstrates the use of ncftp to download the latest errata kernels for Red Hat Linux 5.2. However, the same method can be used with the most recent versions of Red Hat Linux. Just be sure to correct directory tree for your particular version.
$ ncftp -L updates.redhat.com NcFTP 2.4.3 (March 19, 1998), by Mike Gleason. Tip: Use the "more" command to view a remote file with your pager. Trying to connect to updates.redhat.com... ProFTPD 1.2.0pre1 Server (ProFTPD) [updates.redhat.com] Anonymous access granted, restrictions apply. ncftp /pub > cd 5.2/en/os/i386 ncftp /5.2/en/os/i386 > ls kern* mkinit* iBCS* pcmcia* init* SysV* kernel-2.0.36-3.i386.rpm kernel-pcmcia-cs-2.0.36-3.i386.rpm kernel-headers-2.0.36-3.i386.rpm kernel-source-2.0.36-3.i386.rpm kernel-ibcs-2.0.36-3.i386.rpm ncftp /5.2/en/os/i386 > mget kernel-*rpm
If you have problems with the download, you may want to try the get -C versus the mget version. This will cause ncftp to keep trying to download the RPMs until you have a complete version. Newer versions of ncftp attempt to resume downloads by default if the connection is lost. Type man ncftp for full list of commands for the version installed on your system.
If you have not gotten any updates from the FTP site for your system before, you will most likely need to upgrade the rpm package before you will be able to confirm or install the new RPMs.
The methodology for this upgrade is pretty simple. Check what version of RPM you have installed. Compare that version number against any updates on the FTP site. If the FTP site has a later version, you will need to download it and upgrade the package. Or in a nutshell:
$ rpm -q rpm rpm-devel rpm-4.0.2-5x.i386.rpm rpm-build-4.0.2-5x.i386.rpm rpm-devel-4.0.2-5x.i386.rpm $ ncftp updates.redhat.com > cd 5.2/en/os/i386 > get rpm* > quit $ rpm -Uvh rpm*rpm
If the versions are very very different (upgrading 2.3 to 4.0.2 or something like that), you should also run the following command after the upgrade.
$ rpm --rebuilddb
This last step should fix any problems between database layouts of the different versions (or in case one of the databases had become corrupt). It will usually take a while to complete this rewrite as it is doing a very low level RPM task.
One of the most annoying things that occurs when downloading RPM packages has to do with a file corruption during the download process. If you install a corrupted RPM and run into problems after the install, the fix is usually as simple as downloading the RPM again, uninstalling the current RPM, and installing the newly downloaded version. However, in the case of a kernel upgrade, this problem is more than annoying as you could find yourself with an unbootable machine.
In order to make a system administrator's life easier, RPM has ways to check the self-consistency of any RPM package. To do this, we use the -K --nopgp options. On the example Red Hat Linux 5.2 system, we downloaded the packages and got the following response from RPM.
$ rpm -K --nopgp *rpm kernel-2.0.36-1.i386.rpm: size md5 OK kernel-headers-2.0.36-1.i386.rpm: size md5 OK kernel-ibcs-2.0.36-1.i386.rpm: size md5 OK kernel-pcmcia-cs-2.0.36-1.i386.rpm: size md5 OK kernel-source-2.0.36-1.i386.rpm: size md5 OK
For Red Hat Linux 7.0, you must use a slightly different command to check the RPM packages.
$ rpm -K --nogpg *rpm kernel-2.2.17-14.i386.rpm: size md5 OK kernel-BOOT-2.2.17-14.i386.rpm: size md5 OK kernel-doc-2.2.17-14.i386.rpm: size md5 OK kernel-ibcs-2.2.17-14.i386.rpm: size md5 OK kernel-pcmcia-cs-2.2.17-14.i386.rpm: size md5 OK kernel-smp-2.2.17-14.i386.rpm: size md5 OK kernel-source-2.2.17-14.i386.rpm: size md5 OK kernel-utils-2.2.17-14.i386.rpm: size md5 OK
If all the RPMs have correct md5sums, then you should be able to continue on. If not, try downloading again. If you are getting repeated failures, try a different mirror, as the problem may be with the network connection to that site or some sort of transparent caching device that is keeping the corrupted RPM file resident at that FTP location.
The final pre-install step is to make an emergency boot floppy (if you haven't made one already). On Red Hat Linux 5.x, 6.x, and 7.x machines you can accomplish this with the mkbootdisk command.
First, find out what kernel you are currently using. Check out your /etc/lilo.conf file and see which image was booted from. On a sample 5.2 system, you might see the following information:
$ cat /etc/lilo.conf boot=/dev/hda map=/boot/map install=/boot/boot.b prompt timeout=50 image=/boot/vmlinuz-2.0.36-0.7 label=linux root=/dev/hda9 initrd=/boot/initrd-2.0.36-0.7.img read-only other=/dev/hda1 label=dos table=/dev/hda
For Red Hat Linux 7.0 systems, the contents of the /etc/lilo.conf file may look a little different:
$ cat /etc/lilo.conf boot=/dev/hda map=/boot/map install=/boot/boot.b prompt timeout=50 message=/boot/message linear default=linux image=/boot/vmlinuz-2.2.16-22 label=linux initrd=/boot/initrd-2.2.16-22.img read-only root=/dev/hda9 other=/dev/hda1 label=dos table=/dev/hda
Now you will need to find the image that you booted from. On a standard installation of Red Hat Linux 5.2, it will be the one labeled linux. Later versions of LILO support the use of one default= line and label= lines in each boot options to specify which of the images to load by default.
The 5.2 example above shows that the machine booted using the /boot/vmlinuz-2.0.36-0.7 kernel. Now simply put a formatted 1.44 floppy in your system, and make sure you have logged in as root.
# whoami root # mkbootdisk --device /dev/fd0 2.0.36-0.7 Insert a disk in /dev/fd0. Any information on the disk will be lost. Press
Following these guidelines, you will now have a boot floppy with a known working kernel in case of problems with the upgrade. You should reboot the system with the floppy before installing any kernel RPMs to make sure that the floppy works correctly.