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.
Viewing Kernel Information
Section titled “Viewing Kernel Information”Check the Currently Running Kernel
Section titled “Check the Currently Running Kernel”uname -rView Detailed Kernel Information
Section titled “View Detailed Kernel Information”uname -aList All Installed Kernels
Section titled “List All Installed Kernels”rpm -qa kernel-core | sort -VList Kernels via dnf
Section titled “List Kernels via dnf”dnf list installed kernel-coreCheck for Available Kernel Updates
Section titled “Check for Available Kernel Updates”dnf check-update kernelManaging Boot Entries with grubby
Section titled “Managing Boot Entries with grubby”grubby is the standard command-line tool for managing GRUB boot entries.
List All Boot Entries
Section titled “List All Boot Entries”grubby --info=ALLView the Current Default Kernel
Section titled “View the Current Default Kernel”grubby --default-kernelView the Default Kernel Index
Section titled “View the Default Kernel Index”grubby --default-indexSet the Default Kernel
Section titled “Set the Default Kernel”grubby --set-default /boot/vmlinuz-5.14.0-362.8.1.el9_3.x86_64grubby --set-default-index 1Add Boot Parameters to a Specific Kernel
Section titled “Add Boot Parameters to a Specific Kernel”grubby --update-kernel /boot/vmlinuz-$(uname -r) --args="nouveau.modeset=0"Remove Kernel Boot Parameters
Section titled “Remove Kernel Boot Parameters”grubby --update-kernel /boot/vmlinuz-$(uname -r) --remove-args="quiet"Add Parameters to All Kernels
Section titled “Add Parameters to All Kernels”grubby --update-kernel ALL --args="crashkernel=auto"Kernel Rollback
Section titled “Kernel Rollback”When a new kernel causes system issues, you can quickly switch to a previous version.
Method 1: GRUB Menu Selection
Section titled “Method 1: GRUB Menu Selection”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.
Method 2: Using grubby
Section titled “Method 2: Using grubby”# List available kernelsgrubby --info=ALL | grep -E "^kernel|^index"
# Set the old version as defaultgrubby --set-default /boot/vmlinuz-<old-version>
# Reboot to applyrebootMethod 3: Using dnf History
Section titled “Method 3: Using dnf History”# Find the transaction ID for the kernel installationdnf history list | grep kernel
# Undo that transactiondnf history undo <transaction-ID> -yCleaning Up Old Kernels
Section titled “Cleaning Up Old Kernels”Check the installonly_limit Setting
Section titled “Check the installonly_limit Setting”installonly_limit controls how many kernel versions are retained.
grep installonly_limit /etc/dnf/dnf.confThe default is usually 3, meaning up to 3 kernel versions are kept.
Modify installonly_limit
Section titled “Modify installonly_limit”# Change to keep 2 kernels (minimum recommended is 2)echo "installonly_limit=2" >> /etc/dnf/dnf.confManually Remove an Old Kernel
Section titled “Manually Remove an Old Kernel”dnf remove kernel-core-<version> -yUse package-cleanup to Remove Old Kernels
Section titled “Use package-cleanup to Remove Old Kernels”dnf install -y dnf-plugins-corepackage-cleanup --oldkernels --count=2Regenerate GRUB Configuration After Cleanup
Section titled “Regenerate GRUB Configuration After Cleanup”grub2-mkconfig -o /boot/grub2/grub.cfgFor UEFI systems:
grub2-mkconfig -o /boot/efi/EFI/almalinux/grub.cfgInstalling Newer Kernels from ELRepo
Section titled “Installing Newer Kernels from ELRepo”ELRepo provides two kernel tracking branches:
- kernel-ml — Mainline stable (latest features)
- kernel-lt — Long Term support (more conservative)
Install the ELRepo Repository
Section titled “Install the ELRepo Repository”rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.orgdnf install -y https://www.elrepo.org/elrepo-release-9.el9.elrepo.noarch.rpmFor EL 8 systems:
rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.orgdnf install -y https://www.elrepo.org/elrepo-release-8.el8.elrepo.noarch.rpmView Available ELRepo Kernels
Section titled “View Available ELRepo Kernels”dnf --enablerepo=elrepo-kernel list available | grep kernelInstall the Mainline Kernel
Section titled “Install the Mainline Kernel”dnf --enablerepo=elrepo-kernel install -y kernel-mlInstall the Long Term Kernel
Section titled “Install the Long Term Kernel”dnf --enablerepo=elrepo-kernel install -y kernel-ltSet the ELRepo Kernel as Default
Section titled “Set the ELRepo Kernel as Default”grubby --default-kernel# If it is not the new kernel, set it manuallygrubby --set-default /boot/vmlinuz-<elrepo-kernel-version>Install Matching Kernel Development Tools
Section titled “Install Matching Kernel Development Tools”dnf --enablerepo=elrepo-kernel install -y kernel-ml-devel kernel-ml-headersdnf --enablerepo=elrepo-kernel install -y kernel-lt-devel kernel-lt-headersKernel Parameter Tuning
Section titled “Kernel Parameter Tuning”View Current Kernel Parameters
Section titled “View Current Kernel Parameters”sysctl -aTemporarily Modify a Kernel Parameter
Section titled “Temporarily Modify a Kernel Parameter”sysctl -w net.core.somaxconn=65535Permanently Modify Kernel Parameters
Section titled “Permanently Modify Kernel Parameters”cat > /etc/sysctl.d/99-custom.conf << 'EOF'# Network tuningnet.core.somaxconn = 65535net.ipv4.tcp_max_syn_backlog = 65535
# Memory managementvm.swappiness = 10vm.dirty_ratio = 40vm.dirty_background_ratio = 10EOF
# Apply immediatelysysctl --systemKernel Module Management
Section titled “Kernel Module Management”List Loaded Modules
Section titled “List Loaded Modules”lsmodView Module Information
Section titled “View Module Information”modinfo <module-name>Load and Unload Modules
Section titled “Load and Unload Modules”modprobe <module-name>modprobe -r <module-name>Auto-Load a Module at Boot
Section titled “Auto-Load a Module at Boot”echo "<module-name>" > /etc/modules-load.d/<module-name>.confBlacklist a Module
Section titled “Blacklist a Module”echo "blacklist <module-name>" > /etc/modprobe.d/blacklist-<module-name>.conf