Skip to content

Kernel Management

Enterprise Linux kernel management encompasses installing new kernels, selecting the default boot kernel, cleaning up old versions, and optionally installing newer kernels from ELRepo.

View the current kernel version
uname -r
View full kernel details
uname -a
List installed kernel packages
rpm -qa kernel-core | sort -V
List kernels through dnf
dnf list installed kernel-core
Check for kernel updates
dnf check-update kernel

grubby is the standard command-line tool for managing GRUB boot entries.

List all available kernel boot entries
grubby --info=ALL
View the default boot kernel
grubby --default-kernel
View the default kernel index number
grubby --default-index
Set default kernel by path
grubby --set-default /boot/vmlinuz-5.14.0-362.8.1.el9_3.x86_64
Set default kernel by index (0 is newest)
grubby --set-default-index 1
Add a boot parameter to a specific kernel
grubby --update-kernel /boot/vmlinuz-$(uname -r) --args="nouveau.modeset=0"
Remove a boot parameter from a specific kernel
grubby --update-kernel /boot/vmlinuz-$(uname -r) --remove-args="quiet"
Add a boot parameter to all kernels
grubby --update-kernel ALL --args="crashkernel=auto"

When a new kernel causes system issues, you can quickly switch to a previous version.

At boot time, select an older kernel from the GRUB menu. If the GRUB menu is not displayed, hold Shift or press Esc during boot.

Switch the default to an older kernel
# List available kernels
grubby --info=ALL | grep -E "^kernel|^index"
# Set the old version as default
grubby --set-default /boot/vmlinuz-<old-version>
# Reboot to apply
reboot
Roll back a kernel update via dnf history
# Find the transaction ID for the kernel installation
dnf history list | grep kernel
# Undo that transaction
dnf history undo <transaction-ID> -y

installonly_limit controls how many kernel versions are retained.

View the current installonly_limit
grep installonly_limit /etc/dnf/dnf.conf

The default is usually 3, meaning up to 3 kernel versions are kept.

Set the number of kernels to retain
# Change to keep 2 kernels (minimum recommended is 2)
echo "installonly_limit=2" >> /etc/dnf/dnf.conf
Remove a specific old kernel
dnf remove kernel-core-<version> -y
Keep only the 2 most recent kernels
dnf install -y dnf-plugins-core
package-cleanup --oldkernels --count=2

Regenerate GRUB Configuration After Cleanup

Section titled “Regenerate GRUB Configuration After Cleanup”
Regenerate the GRUB configuration
grub2-mkconfig -o /boot/grub2/grub.cfg

For UEFI systems:

Regenerate GRUB configuration for UEFI
grub2-mkconfig -o /boot/efi/EFI/almalinux/grub.cfg

ELRepo provides two kernel tracking branches:

  • kernel-ml — Mainline stable (latest features)
  • kernel-lt — Long Term support (more conservative)
Import ELRepo GPG key and install the repository
rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org
dnf install -y https://www.elrepo.org/elrepo-release-9.el9.elrepo.noarch.rpm

For EL 8 systems:

Install ELRepo on EL 8
rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org
dnf install -y https://www.elrepo.org/elrepo-release-8.el8.elrepo.noarch.rpm
List available kernels from ELRepo
dnf --enablerepo=elrepo-kernel list available | grep kernel
Install kernel-ml
dnf --enablerepo=elrepo-kernel install -y kernel-ml
Install kernel-lt
dnf --enablerepo=elrepo-kernel install -y kernel-lt
Set the newly installed ELRepo kernel as default
grubby --default-kernel
# If it is not the new kernel, set it manually
grubby --set-default /boot/vmlinuz-<elrepo-kernel-version>
Install kernel-ml development packages
dnf --enablerepo=elrepo-kernel install -y kernel-ml-devel kernel-ml-headers
Install kernel-lt development packages
dnf --enablerepo=elrepo-kernel install -y kernel-lt-devel kernel-lt-headers
View all sysctl parameters
sysctl -a
Temporarily adjust a parameter (lost on reboot)
sysctl -w net.core.somaxconn=65535
Create a persistent kernel parameter configuration
cat > /etc/sysctl.d/99-custom.conf << 'EOF'
# Network tuning
net.core.somaxconn = 65535
net.ipv4.tcp_max_syn_backlog = 65535
# Memory management
vm.swappiness = 10
vm.dirty_ratio = 40
vm.dirty_background_ratio = 10
EOF
# Apply immediately
sysctl --system
View loaded kernel modules
lsmod
View details about a specific module
modinfo <module-name>
Load a kernel module
modprobe <module-name>
Unload a kernel module
modprobe -r <module-name>
Configure a module to load at boot
echo "<module-name>" > /etc/modules-load.d/<module-name>.conf
Prevent a module from loading
echo "blacklist <module-name>" > /etc/modprobe.d/blacklist-<module-name>.conf