Skip to Main Content

Infrastructure Software

Announcement

For appeals, questions and feedback, please email oracle-forums_moderators_us@oracle.com

Oracle Linux - How to Change Default Kernel

Honglin Su-OracleSep 23 2018 — edited Aug 18 2022

Oracle Linux comes with a choice of two kernels, the Unbreakable Enterprise Kernel (UEK), which is installed and enabled by default, and the Red Hat Compatible Kernel (RHCK).

In this tutorial, we use Oracle Linux instances in Oracle Cloud Infrastructure to illustrate how you change the default kernel (UEK) and boot into an old kernel such as RHCK. To launch an Oracle Linux instance in Oracle Cloud Infrastructure, please follow Getting Started Guide.

Change Default Kernel in Oracle Linux 7, 8, and 9

Beginning in Oracle Linux 7, you can use the grubby command to manage your boot requirements.

Read the blog for detailed instructions.

Change Default Kernel in Oracle Linux 6 and 5

Oracle Linux 6 and 5 use the GRUB boot loader. To change the default boot kernel, you modify the GRUB configuration file, /etc/grub.conf.

The default directive 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. The UEK is configured as the first entry, and the RHCK is configured as the second entry. Changing the value of default to 1 (other value) would cause GRUB to boot the RHCK (or another kernel) by default.

Here's an Oracle Linux 6.10 instance in Oracle Cloud Infrastructure. It has the UEK and RHCK installed. The UEK is the default running kernel.

[root@honsu-ol6-vm2 opc]# rpm -qa kernel-uekkernel-uek-4.1.12-124.18.5.el6uek.x86_64[root@honsu-ol6-vm2 opc]# rpm -qa kernelkernel-2.6.32-754.el6.x86_64kernel-2.6.32-754.2.1.el6.x86_64[root@honsu-ol6-vm2 opc]# uname -aLinux honsu-ol6-vm2 4.1.12-124.18.5.el6uek.x86_64 #2 SMP Mon Aug 13 16:18:59 PDT 2018 x86_64 x86_64 x86_64 GNU/Linux

Next you modify the default directive of the GRUB configuration file, /etc/grub.conf.

# grub.conf generated by anaconda

# Note that you do not have to rerun grub after making changes to this file

# NOTICE:  You do not have a /boot partition.  This means that

#          all kernel and initrd paths are relative to /, eg.

#          root (hd0,2)

#          kernel /boot/vmlinuz-version ro root=/dev/sda3

#          initrd /boot/initrd-[generic-]version.img

#boot=/dev/sda1

device (hd0) HD(1,800,64000,d2fcf22a-4d03-4e56-a262-8974772642e2)

default=1

timeout=5

serial --unit=0 --speed=9600

terminal --timeout=5 serial console

title Oracle Linux Server Unbreakable Enterprise Kernel (4.1.12-124.18.5.el6uek.x86_64)

        root (hd0,2)

        kernel /boot/vmlinuz-4.1.12-124.18.5.el6uek.x86_64 ro root=UUID=974abb96-e711-42fa-b371-388abd421ff0 rd_NO_LUKS LANG=en_US.UTF-8 rd_NO_MD  KEYTABLE=us SYSFONT=latarcyrheb-sun16 crashkernel=auto ip=dhcp netroot=iscsi:169.254.0.2:::1:iqn.2015-02.oracle.boot:uefi iscsi_param=node.session.timeo.replacement_timeout=6000 biosdevname=1 nvme_core.shutdown_timeout=10 libiscsi.debug_libiscsi_eh=1 ipmi_si.tryacpi=0 ipmi_si.trydmi=0 ipmi_si.trydefaults=0 rd_NO_LVM rd_NO_DM irqpoll console=tty0 console=ttyS0,9600

        initrd /boot/initramfs-4.1.12-124.18.5.el6uek.x86_64.img

title Oracle Linux Server Red Hat Compatible Kernel (2.6.32-754.2.1.el6.x86_64)

        root (hd0,2)

        kernel /boot/vmlinuz-2.6.32-754.2.1.el6.x86_64 ro root=UUID=974abb96-e711-42fa-b371-388abd421ff0 rd_NO_LUKS LANG=en_US.UTF-8 rd_NO_MD  KEYTABLE=us SYSFONT=latarcyrheb-sun16 crashkernel=auto ip=dhcp netroot=iscsi:169.254.0.2:::1:iqn.2015-02.oracle.boot:uefi iscsi_param=node.session.timeo.replacement_timeout=6000 biosdevname=1 nvme_core.shutdown_timeout=10 libiscsi.debug_libiscsi_eh=1 ipmi_si.tryacpi=0 ipmi_si.trydmi=0 ipmi_si.trydefaults=0 rd_NO_LVM rd_NO_DM irqpoll console=tty0 console=ttyS0,9600

        initrd /boot/initramfs-2.6.32-754.2.1.el6.x86_64.img

title Oracle Linux Server Red Hat Compatible Kernel (2.6.32-754.el6.x86_64)

        root (hd0,2)

        kernel /boot/vmlinuz-2.6.32-754.el6.x86_64 ro root=UUID=974abb96-e711-42fa-b371-388abd421ff0 rd_NO_LUKS LANG=en_US.UTF-8 rd_NO_MD  KEYTABLE=us SYSFONT=latarcyrheb-sun16 crashkernel=auto ip=dhcp netroot=iscsi:169.254.0.2:::1:iqn.2015-02.oracle.boot:uefi iscsi_param=node.session.timeo.replacement_timeout=6000 biosdevname=1 nvme_core.shutdown_timeout=10 libiscsi.debug_libiscsi_eh=1 ipmi_si.tryacpi=0 ipmi_si.trydmi=0 ipmi_si.trydefaults=0 rd_NO_LVM rd_NO_DM irqpoll console=tty0 console=ttyS0,9600

        initrd /boot/initramfs-2.6.32-754.el6.x86_64.img

Then you reboot the instance.

[root@honsu-ol6-vm2 opc]# reboot

After the instance is up and running, you verify the running kernel which is RHCK.

[opc@honsu-ol6-vm2 ~]$ uname -a

Linux honsu-ol6-vm2 2.6.32-754.2.1.el6.x86_64 #1 SMP Tue Jul 10 12:24:15 PDT 2018 x86_64 x86_64 x86_64 GNU/Linux

The same instructions apply to Oracle Linux 5. Or if you are running Red Hat Enterprise Linux / CentOS 6 or 5, you can follow the same method of changing the default kernel by modifying the default directive of the GRUB configuration file, /etc/grub.conf.

References

Comments
Post Details
Added on Sep 23 2018
6 comments
47,023 views