Check installed kernel.
# rpm -q kernel
kernel-4.18.0-240.10.1.el8_3.x86_64
kernel-4.18.0-240.22.1.el8_3.x86_64
kernel-4.18.0-305.12.1.el8_4.x86_64
Check default load kernel
# uname -r
4.18.0-305.12.1.el8_4.x86_64
# grubby --default-kernel
/boot/vmlinuz-4.18.0-305.12.1.el8_4.x86_64
Set the Default Linux Kernel:
List down the available Linux kernels in /boot directory.
# ls /boot/vm*
/boot/vmlinuz-0-rescue-25d4accaa6754a5e97616dd5774f723b
/boot/vmlinuz-4.18.0-240.10.1.el8_3.x86_64
/boot/vmlinuz-4.18.0-240.22.1.el8_3.x86_64
/boot/vmlinuz-4.18.0-305.12.1.el8_4.x86_64
Execute the following command to set a default kernel for GRUB
# grubby --set-default /boot/vmlinuz-4.18.0-305.12.1.el8_4.x86_64
The default is /boot/loader/entries/25d4accaa6754a5e97616dd5774f723b-4.18.0-
305.12.1.el8_4.x86_64.conf with index 0 and kernel /boot/vmlinuz-4.18.0-305.12.1.el8_4.x86_64
Changes to /etc/default/grub
require rebuilding the grub.cfg
file as follows:
-On BIOS-based machines, issue the following command as root
:
# grub2-mkconfig -o /boot/grub2/grub.cfg
-On UEFI-based machines, issue the following command as root
:
# grub2-mkconfig -o /boot/efi/EFI/redhat/grub.cfg
#reboot
Remove Old Linux Kernels:
Check the current value of installonly_limit directive
# grep limit /etc/dnf/dnf.conf
installonly_limit=3
Execute following command on Linux Bash prompt to remove the old versions of Linux kernels.
# dnf -y remove --oldinstallonly --setopt installonly_limit=1 kernel
...
Removed:
kernel-4.18.0-240.10.1.el8_3.x86_64
kernel-4.18.0-240.22.1.el8_3.x86_64
kernel-core-4.18.0-240.10.1.el8_3.x86_64
kernel-core-4.18.0-240.22.1.el8_3.x86_64
kernel-modules-4.18.0-240.10.1.el8_3.x86_64
kernel-modules-4.18.0-240.22.1.el8_3.x86_64
Complete!
Reboot your Linux operating system now.
#reboot