Pay-As-You-Go VPS – Only pay for what you use, with flexible billing and no long-term commitment

Safely Upgrade Kernel in Rocky Linux: A Step-by-Step Guide

August 16, 2025

 

 

Upgrading the kernel in Rocky Linux can significantly enhance system performance, security, and compatibility with the latest hardware. However, kernel upgrades must be performed carefully to avoid potential system stability issues. This guide will walk you through the essential steps to safely upgrade the kernel, ensuring a smooth transition.

Understanding the Kernel

The kernel is the core component of a Linux operating system, acting as a bridge between applications and hardware. It manages system resources and allows for multitasking. Regularly updating the kernel is crucial, as it provides patches for security vulnerabilities and improvements in system performance.

Preparing for the Upgrade

Before initiating any upgrades, a bit of preparation can go a long way toward ensuring a successful process.

Backup Your System

Always start by backing up your important files and system configurations. Using tools like rsync or backup software ensures that a copy exists in case any issues arise during the upgrade.

rsync -avh --exclude={"/dev/","/proc/","/sys/*"} / /path/to/backup/

This command creates a backup of your root filesystem while excluding unnecessary virtual file systems.

Check Your Current Kernel Version

Knowing your current kernel version helps you assess the need for an upgrade. You can check the kernel version using:

uname -r

Selecting the Right Kernel Version

Rocky Linux offers different kernel versions through official repositories, including long-term support (LTS) versions and the latest stable releases. Selecting the appropriate kernel version depends on your system’s needs and hardware compatibility.

Listing Available Kernels

To view all available kernels in the repository:

dnf --showduplicates list kernel

Installing the New Kernel

Once you’ve chosen the kernel version you wish to install, proceed with the upgrade process.

Using dnf to Upgrade

dnf is the package manager used in Rocky Linux and simplifies the upgrade process. To install the new kernel, run:

sudo dnf install kernel-<version>

Replace <version> with the desired kernel version you identified earlier.

Cleaning Up Old Kernels

After the new kernel installation, your system might retain old kernels, which can occupy unnecessary disk space. You can remove old kernel versions using:

sudo dnf remove kernel-<old-version>

Be cautious to leave at least one previous stable kernel installed in case you need to revert.

Updating GRUB Configuration

Once the new kernel is installed, it’s essential to update your GRUB configuration to ensure the system boots with the new kernel. This can usually be done automatically, but it’s a good practice to double-check.

sudo grub2-mkconfig -o /boot/grub2/grub.cfg

Rebooting Your System

After completing the upgrade, it’s time to reboot your system. Ensure you save your work before performing the reboot.

sudo reboot

Upon reboot, verify that the new kernel is in use by running:

uname -r

Troubleshooting Potential Issues

In some cases, you might encounter issues after upgrading the kernel. If your system fails to boot properly, the GRUB menu allows you to select the previous kernel.

Booting into Recovery Mode

You can access older kernels directly from the GRUB menu during system startup by pressing the Esc or Shift key, depending on your configuration. From there, you can select a different kernel version.

Conclusion

Regularly upgrading the kernel in Rocky Linux is essential for maintaining a secure and efficient system. By following these steps, you can ensure a safe upgrade process that minimizes risks while maximizing the benefits of the latest kernel features. Always remember to backup your system, test the new kernel, and have a plan for rollback if necessary. With proper care, kernel upgrades can lead to a robust and well-performing Rocky Linux environment.

VirtVPS