Below are the steps to upgrade your kernel on Centos or Redhat linux operating systems. The guide also explains the important grub configurations that you should make to be certain your operating system boots after the upgrade.
Step 1: Upgrade the Kernel
From command line run:
up2date --force kernel-smp
or yum upgrade kernel
(Works on Redhat and Centos)
Step 2 – Edit the Grub configuration
Edit the grub.conf file using your favorite editor (nano, vi, etc.): nano /boot/grub/grub.conf
It should look something like:
default=0
timeout=5
#splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
title Red Hat Enterprise Linux ES (2.6.9-55.ELsmp)
root (hd0,0)
kernel /vmlinuz-2.6.9-55.ELsmp ro root=LABEL=/ console=tty0 console=ttyS1,19200n8 clock=pmtmr
initrd /initrd-2.6.9-55.ELsmp.img
title Red Hat Enterprise Linux ES (2.6.9-42.0.3.ELsmp)
root (hd0,0)
kernel /vmlinuz-2.6.9-42.0.3.ELsmp ro root=LABEL=/ console=tty0 console=ttyS1,19200n8 clock=pmtmr
initrd /initrd-2.6.9-42.0.3.ELsmp.img
title Red Hat Enterprise Linux ES (2.6.9-34.0.2.ELsmp)
root (hd0,0)
kernel /vmlinuz-2.6.9-34.0.2.ELsmp ro root=LABEL=/ console=tty0 console=ttyS1,19200n8 clock=pmtmr
initrd /initrd-2.6.9-34.0.2.ELsmp.img
title Red Hat Enterprise Linux ES (2.6.9-42.ELsmp)
root (hd0,0)
kernel /vmlinuz-2.6.9-42.ELsmp ro root=LABEL=/ console=tty0 console=ttyS1,19200n8 clock=pmtmr
initrd /initrd-2.6.9-42.ELsmp.img
title Red Hat Enterprise Linux ES (2.6.9-34.ELsmp)
root (hd0,0)
kernel /vmlinuz-2.6.9-34.ELsmp ro root=LABEL=/ console=tty0 console=ttyS1,19200n8 clock=pmtmr
initrd /initrd-2.6.9-34.ELsmp.img
title Red Hat Enterprise Linux ES-up (2.6.9-34.EL)
root (hd0,0)
kernel /vmlinuz-2.6.9-34.EL ro root=LABEL=/ console=tty0 console=ttyS1,19200n8 clock=pmtmr
initrd /initrd-2.6.9-34.EL.img
We want to change default=0
to default=1
This will boot your old kernel (not the upgraded one). Grub starts at 0, which will be your new kernel. We will switch to the new kernel later.
Save and exit.
Step 3: Configure server to boot once with the new kernel.
Now we will configure the server to boot the new kernel only once in case it fails. This is the most important step, if its not done and the new kernel fails your out of luck.
Type the following from command line (one at a time):
grub
savedefault --default=0 --once
quit
Step 4 – Reboot
Then reboot the server or computer. When it comes back up run uname -a to make sure it has the new kernel. (Note: if it does not come back up, reboot it again and it will load the old kernel.)
Then switch the grub.conf to boot the new kernel permanently.
nano /boot/grub/grub.conf
change default=1
to default=0
Save and exit. Thats it you have successfully updated your kernel.