Updated: 22 October 2026 · Applies to: Ubuntu 24.04, Debian 12, AlmaLinux 9 and Rocky Linux 9
Sometimes an application needs a specific kernel or package version, so it must not be updated. RHEL/CentOS 7 used the yum versionlock plugin; AlmaLinux 9 / Rocky Linux 9 use the dnf version.
AlmaLinux / Rocky Linux 9
dnf install python3-dnf-plugin-versionlock dnf versionlock add kernel kernel-core kernel-modules dnf versionlock list dnf versionlock delete kernel kernel-core kernel-modules # allow updates again
A simpler but broader option is an exclude line in /etc/dnf/dnf.conf: exclude=kernel*. Use dnf upgrade --disableexcludes=main when you do want to update.
Ubuntu / Debian
apt-mark hold linux-image-generic linux-headers-generic apt-mark showhold apt-mark unhold linux-image-generic linux-headers-generic
Note: Locked packages do not get security updates. Lock only what you must, and unlock it as soon as possible. Check pending kernel updates with dnf check-update kernel*.
Related settings
- See installed kernels:
rpm -q kernel-core(AlmaLinux/Rocky) ordpkg -l "linux-image*"(Ubuntu/Debian). - dnf keeps the last three kernels by default (
installonly_limit=3in/etc/dnf/dnf.conf), so an older one is always available in the GRUB menu if a new kernel causes problems. - Choose the kernel that boots by default with
grubby --set-default /boot/vmlinuz-<version>instead of locking updates.