Unexpected system crashes, boot failures, or hardware issues often trace back to a recent Linux kernel update. Rolling back to a previous kernel using GRUB not only restores system functionality but also allows you to troubleshoot and resolve compatibility problems without waiting for upstream fixes. This process is crucial for administrators and users who need to keep systems operational, especially when newer kernels disrupt critical drivers or introduce regressions.
Booting Into a Previous Kernel Using GRUB
Step 1: Restart your computer and access the GRUB boot menu. On many distributions, holding the Shift
key (for BIOS systems) or repeatedly pressing Esc
(for UEFI systems) during boot displays the GRUB menu. Some distributions may hide this menu by default, requiring these keys to reveal it.
Step 2: Use the arrow keys to navigate to Advanced options for [Your Distro]
and press Enter
. This submenu lists all installed kernel versions alongside their respective recovery modes.
Step 3: Select the previous (older) kernel version that you know is stable. Avoid the recovery mode unless you specifically need it for troubleshooting. Press Enter
to boot into the selected kernel.
Step 4: Confirm that your system boots successfully and verify that previous issues—such as driver incompatibility or system instability—are resolved with the older kernel.
Setting the Default Kernel in GRUB
If manually selecting the kernel at each boot is inconvenient, you can configure GRUB to automatically boot into your preferred kernel version by default. This ensures system stability across reboots without user intervention.
Step 1: Identify the menu entry number or name for your desired kernel. You can list them using:
sudo awk -F\' '$1=="menuentry " {print i++ " : " $2}' /boot/grub2/grub.cfg
This command outputs a numbered list of available boot entries. Note the index number corresponding to your preferred kernel.
Step 2: Set the default kernel by its index using:
sudo grub2-set-default
Replace <index-number>
with the appropriate number from the previous step.
Step 3: Update the GRUB environment to confirm the default setting:
sudo grub2-editenv list
Step 4: Reboot your system. GRUB should now automatically boot into the selected kernel unless you manually choose another option.
Removing a Problematic Kernel
To prevent accidental booting into a faulty kernel, you may want to remove it from your system. This also helps free up space in the /boot
partition, which is often limited.
On Debian, Ubuntu, and Derivatives
Step 1: List installed kernel images:
dpkg --list | grep linux-image
Step 2: Remove the unwanted kernel using:
sudo apt remove linux-image-<version>
Replace <version>
with the exact version string from the previous list.
Step 3: Update GRUB to reflect the removal:
sudo update-grub
On Fedora, CentOS, and RHEL
Step 1: List installed kernels:
dnf list installed kernel
Step 2: Remove the problematic kernel:
sudo dnf remove kernel-<version>
Step 3: If residual files remain in /boot
, remove them manually. For example:
sudo rm /boot/vmlinuz-<version> /boot/initramfs-<version>.img
Step 4: Rebuild the GRUB configuration if necessary:
sudo grub2-mkconfig -o /boot/grub2/grub.cfg
Downgrading the Kernel Package
In cases where the desired kernel version is not currently installed, you may need to reinstall or downgrade the kernel package. This approach is especially useful if the previous kernel was removed or overwritten.
Debian/Ubuntu-Based Systems
Step 1: Search for available older kernel packages:
apt list --all-versions linux-image
Step 2: Install the specific older kernel package:
sudo apt install linux-image-<old-version>
Install matching headers if you use proprietary drivers:
sudo apt install linux-headers-<old-version>
Step 3: Update GRUB and reboot to select the restored kernel.
Fedora/CentOS/RHEL Systems
Step 1: Download the required kernel RPMs from the official archives or trusted sources. For Fedora, you can use the Koji build system to find older kernel packages.
Step 2: Install the downloaded RPMs:
sudo dnf install ./kernel-*.rpm
Step 3: Update GRUB as needed and reboot.
Arch Linux Systems
Step 1: Use the downgrade
AUR script or manually download the older kernel from the Arch Linux Archive.
Step 2: Install the desired kernel version:
sudo pacman -U linux-<old-version>.pkg.tar.zst
Step 3: Add IgnorePkg = linux linux-headers
to /etc/pacman.conf
to prevent automatic upgrades.
Preventing Automatic Kernel Upgrades
Once you've rolled back to a stable kernel, you may want to prevent your package manager from automatically updating the kernel until the upstream issue is resolved.
- On Debian/Ubuntu, use APT pinning by creating a file in
/etc/apt/preferences.d/
specifying your desired kernel version and a highPin-Priority
. - On Fedora/CentOS, add
exclude=kernel*
to your/etc/dnf/dnf.conf
or/etc/yum.conf
. - On Arch Linux, add
IgnorePkg = linux linux-headers
to/etc/pacman.conf
.
Remember to remove these restrictions when you are ready to test new kernel updates, as running outdated kernels for extended periods can expose your system to security vulnerabilities.
Troubleshooting and Best Practices
Boot failures after a kernel downgrade often result from mismatched kernel headers, missing drivers, or incorrect GRUB configurations. Always install matching kernel headers and modules when using proprietary drivers or virtualization tools. If your system becomes unbootable, use a live USB to mount your partitions, chroot
into your installation, and repair kernel or GRUB settings.
Maintain at least one additional working kernel on your system for fallback. Back up important data before making kernel changes, and document each step to simplify future troubleshooting or rollbacks. When possible, use only official repositories or distribution archives to source kernel packages, minimizing the risk of introducing security or compatibility issues.
Rolling back your Linux kernel through GRUB restores system reliability when updates cause problems. With careful management of kernels and GRUB settings, you can quickly recover from most kernel-related disruptions and keep your system running smoothly.
Member discussion