The following post shows the procedure to boot CentOS/RHEL/OEL 5 and 6 systems into different kernel installed.
CentOS/RHEL/OEL 5 and 6 operating system uses GRUB as the default boot loader. When you install a kernel using either rpm, up2date or yum application, the kernel package creates an entry in the boot loader configuration file for that new kernel. However, rpm does not configure the new kernel to boot as the default kernel, up2date and yum does. You must do this manually when installing a new kernel with rpm, and double-check the boot loader configuration file after installing a new kernel with u2date or yum to ensure that the configuration is correct.
When you already have different kernels previously installed and desire to boot with different to what is set on the default in the GRUB configuration file you have to change the default kernel to boot with.
In order to change the default boot kernel in CentOS/RHEL/OEL 5 & 6 proceed to perform the following steps:
1. Edit the file /boot/grub/grub.conf using a text editor.
The GRUB configuration file starts with the default, timeout, splashimage, and hiddenmenu directives, it should looks like the one in the following example:
# vi /boot/grub/grub.conf
# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE: You have a /boot partition. This means that
# all kernel and initrd paths are relative to /boot/, eg.
# root (hd0,0)
# kernel /vmlinuz-version ro root=/dev/mapper/vg_luisol6-lv_root
# initrd /initrd-[generic-]version.img
#boot=/dev/xvda
default=0
timeout=50
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
title Oracle Linux Server Unbreakable Enterprise Kernel (2.6.39-400.294.6.el6uek.x86_64)
root (hd0,0)
kernel /vmlinuz-2.6.39-400.294.6.el6uek.x86_64 ro root=/dev/mapper/vg_luisol6-lv_root rd_NO_LUKS LANG=en_US.UTF-8 rd_NO_MD SYSFONT=latarcyrheb-sun16 KEYBOARDTYPE=pc KEYTABLE=la-latin1 rd_LVM_LV=vg_luisol6/lv_root rd_LVM_LV=vg_luisol6/lv_swap rd_NO_DM rhgb quiet
initrd /initramfs-2.6.39-400.294.6.el6uek.x86_64.img
title Oracle Linux Server Unbreakable Enterprise Kernel (3.8.13-118.19.2.el6uek.x86_64)
root (hd0,0)
kernel /vmlinuz-3.8.13-118.19.2.el6uek.x86_64 ro root=/dev/mapper/vg_luisol6-lv_root rd_NO_LUKS LANG=en_US.UTF-8 rd_NO_MD SYSFONT=latarcyrheb-sun16 crashkernel=auto KEYBOARDTYPE=pc KEYTABLE=la-latin1 rd_LVM_LV=vg_luisol6/lv_root rd_LVM_LV=vg_luisol6/lv_swap rd_NO_DM rhgb quiet
initrd /initramfs-3.8.13-118.19.2.el6uek.x86_64.img
title Oracle Linux Server Unbreakable Enterprise Kernel (4.1.12-61.1.14.el6uek.x86_64)
root (hd0,0)
kernel /vmlinuz-4.1.12-61.1.14.el6uek.x86_64 ro root=/dev/mapper/vg_luisol6-lv_root rd_NO_LUKS LANG=en_US.UTF-8 rd_NO_MD SYSFONT=latarcyrheb-sun16 crashkernel=auto KEYBOARDTYPE=pc KEYTABLE=la-latin1 rd_LVM_LV=vg_luisol6/lv_root rd_LVM_LV=vg_luisol6/lv_swap rd_NO_DM rhgb quiet
initrd /initramfs-4.1.12-61.1.14.el6uek.x86_64.img
title Oracle Linux Server Red Hat Compatible Kernel (2.6.32-642.6.1.el6.x86_64)
root (hd0,0)
kernel /vmlinuz-2.6.32-642.6.1.el6.x86_64 ro root=/dev/mapper/vg_luisol6-lv_root rd_NO_LUKS LANG=en_US.UTF-8 rd_NO_MD SYSFONT=latarcyrheb-sun16 crashkernel=auto KEYBOARDTYPE=pc KEYTABLE=la-latin1 rd_LVM_LV=vg_luisol6/lv_root rd_LVM_LV=vg_luisol6/lv_swap rd_NO_DM rhgb quiet
initrd /initramfs-2.6.32-642.6.1.el6.x86_64.img
The directive “default” (marked red in the example) specifies the kernel entry that GRUB should boot by default.
GRUB counts the kernel entries in the configuration file starting at 0. The directive “default=0” means that GRUB boots the first kernel entry by default, unless you override this action.
2. Change the value of “default” to the value of the desired kernel to boot by default, that correspond to any of the installed kernels. Set the value from “0” to the desired one corresponding to the default kernel you need to boot with.
In the above example there are 3/5-line stanzas that each refer to an installed kernel. These stanzas always start with a title entry, after which the associated root, kernel and initrd directives should always be indented. Ensure that each stanza starts with a title that contains a version number (in parentheses) that matches the version number in the kernel /vmlinuz-[version_number] line of the same stanza.
The example contains 4 different kernels installed (Example is from OEL 6 system):
title Oracle Linux Server Unbreakable Enterprise Kernel (2.6.39-400.294.6.el6uek.x86_64) = 0 title Oracle Linux Server Unbreakable Enterprise Kernel (3.8.13-118.19.2.el6uek.x86_64) = 1 title Oracle Linux Server Unbreakable Enterprise Kernel (4.1.12-61.1.14.el6uek.x86_64) = 2 title Oracle Linux Server Red Hat Compatible Kernel (2.6.32-642.6.1.el6.x86_64) = 3
Change to:
default=1" to boot with UEK3 kernel version "3.8.13-118.19.2.el6uek.x86_64" "default=2" to boot with UEK4 kernel version "4.1.12-61.1.14.el6uek.x86_64" "default=3" to boot with RHCK (Red Hat Compatible Kernel) version "2.6.32-642.6.1.el6.x86_64"
3. Reboot the system.
# shutdown -r now
4. Once the server is back up and running make sure the default kernel booted is the correct by running “uname” command:
# vi /boot/grub/grub.conf ... default=2 timeout=50 splashimage=(hd0,0)/grub/splash.xpm.gz hiddenmenu title Oracle Linux Server Unbreakable Enterprise Kernel (2.6.39-400.294.6.el6uek.x86_64) root (hd0,0) kernel /vmlinuz-2.6.39-400.294.6.el6uek.x86_64 ro root=/dev/mapper/vg_luisol6-lv_root rd_NO_LUKS LANG=en_US.UTF-8 rd_NO_MD SYSFONT=latarcyrheb-sun16 KEYBOARDTYPE=pc KEYTABLE=la-latin1 rd_LVM_LV=vg_luisol6/lv_root rd_LVM_LV=vg_luisol6/lv_swap rd_NO_DM rhgb quiet initrd /initramfs-2.6.39-400.294.6.el6uek.x86_64.img title Oracle Linux Server Unbreakable Enterprise Kernel (3.8.13-118.19.2.el6uek.x86_64) root (hd0,0) kernel /vmlinuz-3.8.13-118.19.2.el6uek.x86_64 ro root=/dev/mapper/vg_luisol6-lv_root rd_NO_LUKS LANG=en_US.UTF-8 rd_NO_MD SYSFONT=latarcyrheb-sun16 crashkernel=auto KEYBOARDTYPE=pc KEYTABLE=la-latin1 rd_LVM_LV=vg_luisol6/lv_root rd_LVM_LV=vg_luisol6/lv_swap rd_NO_DM rhgb quiet initrd /initramfs-3.8.13-118.19.2.el6uek.x86_64.img title Oracle Linux Server Unbreakable Enterprise Kernel (4.1.12-61.1.14.el6uek.x86_64) root (hd0,0) kernel /vmlinuz-4.1.12-61.1.14.el6uek.x86_64 ro root=/dev/mapper/vg_luisol6-lv_root rd_NO_LUKS LANG=en_US.UTF-8 rd_NO_MD SYSFONT=latarcyrheb-sun16 crashkernel=auto KEYBOARDTYPE=pc KEYTABLE=la-latin1 rd_LVM_LV=vg_luisol6/lv_root rd_LVM_LV=vg_luisol6/lv_swap rd_NO_DM rhgb quiet initrd /initramfs-4.1.12-61.1.14.el6uek.x86_64.img title Oracle Linux Server Red Hat Compatible Kernel (2.6.32-642.6.1.el6.x86_64) root (hd0,0) kernel /vmlinuz-2.6.32-642.6.1.el6.x86_64 ro root=/dev/mapper/vg_luisol6-lv_root rd_NO_LUKS LANG=en_US.UTF-8 rd_NO_MD SYSFONT=latarcyrheb-sun16 crashkernel=auto KEYBOARDTYPE=pc KEYTABLE=la-latin1 rd_LVM_LV=vg_luisol6/lv_root rd_LVM_LV=vg_luisol6/lv_swap rd_NO_DM rhgb quiet initrd /initramfs-2.6.32-642.6.1.el6.x86_64.img
# uname -r 4.1.12-61.1.14.el6uek.x86_64