This is a quick step-by-step guide that shows how to reduce (the same process can be leveraged to increase too) the number of installed kernels for an Oracle Linux system.
By default, Oracle Linux is configured to keep, at least, 3 different kernels installed on the filesystem where, usually, the latest one boots.
This process reduces the number of kernel(s) installed from “3” to “2” and could be interesting while the “/boot” partition has a reduced size (due to possible upgrades managed by leapp, from Oracle Linux 7 to Oracle Linux 8 or even from Oracle Linux 8 to Oracle Linux 9); the option that defines the number of installed kernels is there on “yum” or “dnf” configuration (based on which Oracle Linux release you’re running):
Oracle Linux 7
- Available in “/etc/yum.conf”:
[root@ol7 ~]# cat /etc/yum.conf |grep limit installonly_limit=3
Oracle Linux 8 and Oracle Linux 9
- By default, on Oracle Linux 8 and Oracle Linux 9 “/etc/yum.conf” is linked to “/etc/dnf/dnf.conf”:
[root@ol8: ~]# ls -l /etc/yum.conf lrwxrwxrwx. 1 root root 12 May 11 12:03 /etc/yum.conf -> dnf/dnf.conf [root@ol8 ~]# cat /etc/yum.conf |grep limit installonly_limit=3
Be aware that if you increase the number too high then you run the risk of filling up the /boot partition.
Example: reducing number of installed kernels to 2
- Check the number of kernels installed on Oracle Linux; below the output for a system with “installonly_limit=3” where there are:
- 3 Unbreakable Enterprise Kernels installed (UEK)
- 3 Red Hat Compatible Kernels installed (RHCK)
[root@ol8 ~]# grubby --info=ALL | grep ^kernel kernel="/boot/vmlinuz-5.4.17-2136.309.4.el8uek.x86_64" kernel="/boot/vmlinuz-5.4.17-2136.308.9.el8uek.x86_64" kernel="/boot/vmlinuz-5.4.17-2136.308.7.el8uek.x86_64" kernel="/boot/vmlinuz-4.18.0-372.16.1.0.1.el8_6.x86_64" kernel="/boot/vmlinuz-4.18.0-372.13.1.0.1.el8_6.x86_64" kernel="/boot/vmlinuz-4.18.0-372.9.1.el8.x86_64"
- Edit “/etc/yum.conf” or “/etc/dnf/dnf.conf” and reduce the value for “installonly_limit” to “2”:
[root@ol8 ~]# cat /etc/yum.conf |grep limit installonly_limit=2
- Update your system to get updated kernel(s) – both UEK and RHCK – installed, while yum/dnf will preserve two copies installed for each kernel-type; with this parameter configured to “2” you will obtain two kernels installed for each type (2 UEKs and 2 RHCKs) where for each of them you will keep the latest two releases.
[root@ol8 ~]# dnf update -y Last metadata expiration check: 0:07:07 ago on Tue 09 Aug 2022 02:48:02 PM UTC. Dependencies resolved. ======================================================================================================= Package Architecture Version Repository Size ======================================================================================================= Installing: kernel x86_64 4.18.0-372.19.1.0.1.el8_6 ol8_baseos_latest 8.1 M kernel-core x86_64 4.18.0-372.19.1.0.1.el8_6 ol8_baseos_latest 39 M kernel-modules x86_64 4.18.0-372.19.1.0.1.el8_6 ol8_baseos_latest 32 M kernel-uek x86_64 5.4.17-2136.309.5.el8uek ol8_UEKR6 110 M kernel-uek-devel x86_64 5.4.17-2136.309.5.el8uek ol8_UEKR6 19 M Upgrading: kernel-headers x86_64 4.18.0-372.19.1.0.1.el8_6 ol8_baseos_latest 9.4 M kernel-tools x86_64 4.18.0-372.19.1.0.1.el8_6 ol8_baseos_latest 8.3 M kernel-tools-libs x86_64 4.18.0-372.19.1.0.1.el8_6 ol8_baseos_latest 8.1 M Removing: kernel x86_64 4.18.0-372.9.1.el8 @ol8_baseos_latest 0 kernel x86_64 4.18.0-372.13.1.0.1.el8_6 @ol8_baseos_latest 0 kernel-core x86_64 4.18.0-372.9.1.el8 @ol8_baseos_latest 69 M kernel-core x86_64 4.18.0-372.13.1.0.1.el8_6 @ol8_baseos_latest 69 M kernel-modules x86_64 4.18.0-372.9.1.el8 @ol8_baseos_latest 23 M kernel-modules x86_64 4.18.0-372.13.1.0.1.el8_6 @ol8_baseos_latest 23 M kernel-uek x86_64 5.4.17-2136.308.7.el8uek @ol8_UEKR6 133 M kernel-uek x86_64 5.4.17-2136.308.9.el8uek @ol8_UEKR6 132 M Transaction Summary ======================================================================================================= Install 5 Packages Upgrade 3 Packages Remove 8 Packages
Once the process is completed it’s also suggested to reboot your system to leverage the updated installed kernel.
- Chek, again, the number of kernels available on your system
[root@ol8 ~]# grubby --info=ALL | grep ^kernel kernel="/boot/vmlinuz-5.4.17-2136.309.4.el8uek.x86_64" kernel="/boot/vmlinuz-5.4.17-2136.309.5.el8uek.x86_64" kernel="/boot/vmlinuz-4.18.0-372.19.1.0.1.el8_6.x86_64" kernel="/boot/vmlinuz-4.18.0-372.16.1.0.1.el8_6.x86_64"
