HomeLinuxHow to Prevent Kernel Updates in Ubuntu

How to Prevent Kernel Updates in Ubuntu

How to Prevent Kernel Updates in Ubuntu

In Linux server, the kernel is a critical part of the operating system that directly interacts with the hardware and manages system resources. While regular kernel updates help ensure better security, performance, and compatibility, some administrators may prefer to prevent automatic kernel updates, especially in production environments, to avoid potential issues with new kernel versions. This article will guide you through the process of preventing kernel updates in Ubuntu.

Why Prevent Kernel Updates?

There are several reasons why you might want to stop kernel updates:

  1. Stability: New kernel versions might introduce changes that could potentially break compatibility with existing software or hardware.
  2. Customization: If you have customized your kernel or have specific modules, you might not want updates to overwrite your changes.
  3. Testing: In testing environments, you might want to control which kernel version is used to ensure the accuracy of your testing results.
  4. Production Systems: For production systems, maintaining the same kernel version helps avoid unexpected disruptions caused by kernel changes.

Prerequisites

  1. A running Ubuntu system.
  2. Root or sudo privileges.

How to prevent kernel update?

In previous article, we have discussed about how to update linux kernel in Ubuntu. Now we can check how to prevent the kernel update.

Check the current kernel version

Before stopping the kernel update, you have to check the current kernel version.

uname -r

Identify the Installed Kernel Package

First, you need to identify the exact name of the kernel package that you want to hold. You can list all installed kernel packages using the following command.

dpkg --list | grep linux-image

This will show a list of installed kernel packages, such as linux-image-5.4.0-91-generic

Hold the Kernel Package

Use the apt-mark command to prevent the specific kernel package from being updated. Replace <kernel-package> with the name of the kernel package you want to hold.

apt-mark hold <kernel-package name>

For example, if you want to hold the linux-image-5.4.0-91-generic package:

apt-mark hold linux-image-5.4.0-91-generic

Verify the Hold Status

You can verify that the kernel package is held by using the apt-mark command:

apt-mark showhold

This will list all packages that are held, including the kernel package.

How to Release the hold of Kernel packages?

If you later decide to allow updates to the kernel package, you can remove the hold by running the given command.

apt-mark unhold <kernel-package name>

You can verify the unhold using the above command .

Conclusion

By following the methods outlined in this article, you can prevent kernel updates in Ubuntu. These techniques allow you to maintain control over the kernel version in your environment. However, it’s important to regularly check for security patches for the kernel, as neglecting updates can expose your system to vulnerabilities.

How to Update Linux Kernel in Ubuntu?
How to Tune Linux Kernel without Reboot
Scroll to Top