
Linux Kernel Upgrades: Make Automatic Reboots Safe
Automatic Linux kernel upgrades are worth setting up, but only once you can see what ran, confirm it worked, and boot back to a known-good kernel. On Debian and Ubuntu the tool is unattended-upgrades. On RHEL, Rocky, AlmaLinux, and Fedora it's dnf-automatic, and live patching is an optional layer on top. Enable any of them blind and you trade a planned maintenance window for an unplanned outage at 3 a.m. Use your distribution's own update tool for security fixes, then own the three jobs it skips: the reboot, the boot check, and the log review.
Last updated: 2026-10-19
The tooling is solid. The failure is almost always that nobody checked the kernel's role in the stack before turning the automation loose. Live patching is worth paying for only when a reboot has a measurable cost, such as drained traffic or a breached service agreement.
The plan is simple. Learn the upgrade path and keep manual updating as your baseline. Then let automation handle the routine while you keep the rollback path armed.
Are automatic Linux kernel upgrades safe to turn on?
Yes, once you treat them as four separate jobs. The default tools finish only the first one, so the other three are on you.
- Install. The package manager pulls the new kernel from your distribution's security repository. unattended-upgrades and dnf-automatic do this well.
- Reboot. The new kernel runs only after a boot. Neither tool reboots by default.
- Validate. Something has to confirm the box came back on the new kernel, with its modules loaded and its services up.
- Roll back. An older kernel stays installed and listed in GRUB, so you can boot it when the new one misbehaves.
Here is the version that fits in a runbook. Turn on your distribution's automatic security updates, schedule the reboot yourself, and keep at least one older kernel installed. Then alert on any host where the running kernel is older than the newest installed one.
What actually happens when the kernel upgrades?
A kernel upgrade is four actions, and automation usually handles only the first three. First the package manager downloads a new kernel package and installs it beside the old one. Your running kernel stays put, and nothing has switched yet.
Next the system rebuilds the initramfs, the small early-boot filesystem that loads the drivers needed to mount your real root. Then the bootloader gets updated, so GRUB knows a new kernel exists and which one to boot by default. Only a reboot swaps the running kernel for the new one.
That last step is why kernel updates differ from every other package. apt upgrade on a library takes effect on the next process start. A kernel takes effect on the next boot, and not before.
Run uname -r after an upgrade and you'll still see the old version until you reboot. That gap is where automation trips people up: the install succeeded, and the machine is still running the vulnerable kernel.
Update by hand before you automate

Run the whole thing manually once, so you know what a clean run looks like. This sequence works on any distribution:
- Run
uname -rto record the running kernel.uname -raprints all the major kernel attributes if you also need the build date and architecture. - List what's installed:
dpkg --list 'linux-image*' | grep ^iion Debian and Ubuntu,rpm -q kernelon the RHEL family,zypper se -si kernel-defaulton SUSE. - Check what's pending and why.
apt list --upgradable,dnf updateinfo list --security, andzypper list-patches --category securitytell you whether the new kernel carries security fixes. - Install the distribution's kernel package with the commands below. Watch the output for the new kernel image and the initramfs rebuild lines.
- Confirm the old kernel is still installed. That's your fallback, so it stays until the new one has proven itself.
- Reboot while you're watching, ideally with console access in case the box doesn't come back.
- Verify each stage yourself. The done message only means the package manager finished.
After the reboot, uname -r should print the new version. Run dmesg | grep -i error to check nothing failed to load during early boot. Then confirm your out-of-tree modules came back with lsmod. For anything built by DKMS (Dynamic Kernel Module Support, which rebuilds third-party modules for each kernel), run dkms status.
The commands for APT, DNF, and Zypper
sudo apt update
sudo apt full-upgrade
sudo dnf upgrade --refresh
sudo zypper refresh
sudo zypper up
sudo zypper dup # openSUSE Tumbleweed uses dup instead of up
Each block belongs to its own family. Copying a dnf line onto a Debian box fails outright, which is the harmless outcome. The harmful one is mixing repositories: a mainline kernel build on Ubuntu, a Debian testing repo on a stable server, or a third-party kernel repo on Rocky Linux. Each one quietly moves kernel security support off your distribution's team and onto you.
Compiling from source is a different animal and rarely what you want. Distribution kernels ship with security backports and tested configs. Build your own only when you need a feature or patch the packaged kernel doesn't carry, and expect to own every rebuild after that. For distro-specific detail, see the guide to updating the Linux kernel safely by distro.
Why apt-get upgrade can leave a new kernel behind
On Debian and Ubuntu, each kernel version arrives as a new package name, pulled in by a metapackage like linux-image-generic. That collides with how apt-get upgrade works. According to the apt-get manual, it upgrades installed packages but never removes anything and never installs a package that isn't already there. As a result, the new kernel shows up as "kept back."
The same manual says apt-get dist-upgrade also handles changing dependencies with new package versions, which is exactly what a new kernel needs. However, it warns that dist-upgrade may remove some packages, so read the list before you answer yes. apt full-upgrade gives you the same behavior through the newer front end.
When a new kernel is actually worth installing
Upgrade when there's a reason, not on a calendar reflex. This applies to moving to a new kernel line. Security updates inside your distribution's supported kernel are a different matter, and those are exactly what you automate.
The clear triggers for a bigger move are these:
- An actively exploited security flaw. A kernel CVE (Common Vulnerabilities and Exposures, the public ID for a known flaw) with a working exploit in the wild is a patch-now event, automation or not.
- Hardware or driver support. A new NIC, GPU, or storage controller that the running kernel doesn't recognize. This is the usual reason to move to Ubuntu's hardware enablement (HWE) kernel.
- End of life. A kernel past its support window stops getting fixes. Stay on it and you collect known holes with every advisory you skip.
- A traced regression. A real performance or stability problem you've traced to the kernel and confirmed is fixed in a newer package. A hunch from a forum thread doesn't count until you can reproduce it.
- An abandoned custom kernel. If you built it yourself and stopped rebuilding, it's the oldest code on the box. Go back to the distribution kernel or start owning the rebuilds again.
Absent one of those, a kernel that's been stable under your workload for months is an asset. Newer kernels often carry hardening and mitigations. They also carry new bugs that haven't met your hardware yet.
What a kernel update carries, and why distro kernels win
Most Linux kernel updates are a bundle of security fixes, bug fixes, and driver changes. The advisory tells you which of those you're getting. So read the severity against your own exposure. A local privilege escalation matters on a shared host with untrusted users, while a remotely reachable network-stack bug matters everywhere.
Release cadence sets your options. New mainline kernels ship every nine to ten weeks, which is too fast for most production. Long-term support (LTS) kernels are the sane default. Still, the kernel team announced it was cutting LTS support from six years to two. Check the published end-of-life date for your branch before you plan around it. The Linux kernel version history shows how those branches have moved.
Distribution kernels are usually the best option. Enterprise vendors backport fixes into a stable base kernel, so the version string barely moves while the security content keeps changing underneath it. CentOS releases ran on that model, and most were supported for roughly ten years. That's why a RHEL-family box reporting an "old" kernel can be fully patched, and why comparing version numbers across distros tells you nothing.
How do the automatic update tools work?
Three mechanisms cover almost everyone. On Debian and Ubuntu it's unattended-upgrades. On RHEL and Fedora it's dnf-automatic. Underneath both sit systemd timers that fire the job on a schedule, replacing the old cron approach.
Each tool downloads and installs the new kernel package on your schedule. What people miss is the next part: by default it does not reboot. The new kernel sits installed and inactive while you keep running the old one. You have to opt into the reboot separately, and you have to mean it.
Confirm the job ran by reading its log. For unattended-upgrades, check /var/log/unattended-upgrades/unattended-upgrades.log and journalctl -u unattended-upgrades. On the DNF side, journalctl -u dnf-automatic.timer shows when it last fired, and the matching service unit shows what it did.
If the log shows a kernel installed but uname -r still shows the old version, that's expected until reboot. It's also the single most common "did it work?" question.
The table maps each family to its tool. The column that matters is the config file, because that's where the tool decides whether anything installs at all.
| Distribution | Tool | Key config file | Best use |
|---|---|---|---|
| Debian / Ubuntu | unattended-upgrades | /etc/apt/apt.conf.d/50unattended-upgrades | Automated security kernel patches |
| RHEL / Rocky / AlmaLinux | dnf-automatic (yum-cron on older releases) | /etc/dnf/automatic.conf | Predictable package apply cadence |
| Fedora | dnf-automatic | /etc/dnf/automatic.conf (moves under DNF5) | Scheduled download and apply timers |
Does your distro already install kernels for you?
Often you get the package automatically. You almost never get the reboot, which means you also don't get the fix until someone boots the new kernel.
- Ubuntu ships unattended-upgrades enabled on standard installs, scoped to security updates, and kernel packages are included. The new kernel installs on its own and then waits.
- Debian depends on how the system was installed, so don't guess. Run
apt-config dump APT::Periodic::Unattended-Upgradeto see whether the periodic upgrade job is configured. - Fedora Workstation stages updates through the desktop software tool and applies them during an offline reboot. Fedora Server installs nothing on its own until you set up dnf-automatic.
- RHEL, Rocky Linux, and AlmaLinux install nothing by default. dnf-automatic is a separate package, and even then it won't install anything until you change one setting, covered below.
- openSUSE Leap and SLES don't apply updates unattended out of the box. Transactional systems like openSUSE MicroOS are the exception, since they're built around automatic updates that take effect at the next boot.
- Cloud images inherit their base distribution's behavior, sometimes with changes from whoever built the image. Check the live config on the instance, because the image's documentation is often older than the image itself.
Configuring unattended upgrades without losing control

On Debian and Ubuntu, install the tool with sudo apt install unattended-upgrades. Two files matter. /etc/apt/apt.conf.d/20auto-upgrades decides when it runs, and 50unattended-upgrades decides what gets upgraded and how. Debian's UnattendedUpgrades documentation covers every option.
// /etc/apt/apt.conf.d/20auto-upgrades
APT::Periodic::Update-Package-Lists "1";
APT::Periodic::Unattended-Upgrade "1";
// /etc/apt/apt.conf.d/50unattended-upgrades
Unattended-Upgrade::Allowed-Origins {
"${distro_id}:${distro_codename}-security";
};
Unattended-Upgrade::Remove-Unused-Kernel-Packages "true";
Unattended-Upgrade::Automatic-Reboot "false";
Keep the allowed origins scoped to security. Pulling every update from every repo is how a routine night turns into a dependency surprise. Leave Automatic-Reboot off on servers and handle the reboot on your own schedule, for reasons covered further down.
Before trusting the config, run sudo unattended-upgrade --dry-run --debug. Check the output for the list of packages it would install and the origin each came from. If a kernel package is missing from that list, your allowed origins are wrong. You've found the problem before it costs you a patch cycle.
Move the run to a time you choose
The install job fires from apt-daily-upgrade.timer, and its default early-morning window may not match your maintenance window. Override it with sudo systemctl edit apt-daily-upgrade.timer and add:
[Timer]
OnCalendar=
OnCalendar=*-*-* 03:00
RandomizedDelaySec=0
The empty OnCalendar= line clears the shipped schedule first. Without it, systemd adds your time to the default instead of replacing it, a quirk that makes the timer fire twice for no visible reason. Confirm the change with systemctl list-timers apt-daily-upgrade.timer and check the output for the next trigger time.
Setting up dnf-automatic on the RHEL family
Install it with sudo dnf install dnf-automatic, then edit /etc/dnf/automatic.conf. The setting that trips people is apply_updates. DNF Automatic's documentation lists it as a boolean that defaults to False, and it controls whether the timer actually installs updates via RPM. Leave it alone and the tool politely does nothing useful.
[commands]
upgrade_type = security
download_updates = yes
apply_updates = yes
The same documentation notes that applying updates implies downloading them, so download_updates = yes is redundant and kept only for clarity. Enable the timer with sudo systemctl enable --now dnf-automatic.timer. Newer dnf-automatic builds also carry a reboot setting, so check man dnf-automatic on your release before relying on it.
Schedule the reboot yourself
The reboot is the step that actually delivers the fix, so it deserves a real schedule. A workable pattern is to install nightly and reboot in a fixed weekly window. Drain hosts behind a load balancer first, and reboot them one at a time.
To see which boxes are waiting, check the reboot flag. On Debian and Ubuntu, a pending kernel leaves /var/run/reboot-required behind. On the RHEL family, needs-restarting -r from dnf-utils returns a nonzero exit code when a reboot is due. Both are easy to feed into monitoring.
The most reliable alert compares the running kernel with the newest one on disk:
running=$(uname -r)
newest=$(ls /boot/vmlinuz-* | sed 's|/boot/vmlinuz-||' | sort -V | tail -1)
[ "$running" != "$newest" ] && echo "reboot pending: $running -> $newest"
A host that stays on that list for weeks is a host that's patched on paper only.
Prove the new kernel booted, then keep a way back
After each reboot, confirm three things. uname -r shows the new version. journalctl -b -p err shows errors from the current boot only, and systemctl --failed lists any systemd unit that didn't come up. If something broke, journalctl -b -1 reads the boot before this one for comparison.
For a cautious first boot, use a one-time default. With GRUB_DEFAULT=saved in /etc/default/grub, sudo grub-reboot <entry> boots the new kernel once and falls back to the old default on the next power cycle. If the box hangs, a hard reset from the console puts you back on the known-good kernel.
On the RHEL family, grubby --default-kernel shows what boots next, and grubby --set-default /boot/vmlinuz-<version> pins a specific kernel. Either way, don't delete the previous kernel until the new one has run your real workload for a while. Live patching can cut down how often you reboot, but you still reboot eventually; the live patch vs reboot comparison covers where it fits.
FAQ
How do I stop automation from ever touching the kernel?
On Debian and Ubuntu, add the kernel packages to Unattended-Upgrade::Package-Blacklist in the 50unattended-upgrades file, or pin them with apt-mark hold. On the RHEL family, add exclude=kernel* to /etc/dnf/dnf.conf. Use this for a frozen appliance or a box with a fragile driver, and put a calendar reminder next to it. A held kernel is easy to forget, and forgotten holds are how a server ends up years behind on fixes.
Will old kernels fill up /boot?
They can, especially on installs with a small separate /boot partition. A full /boot makes the next initramfs build fail halfway, which is a bad way to find out. On Debian and Ubuntu, apt autoremove clears old kernels while protecting the running one. On the RHEL family, installonly_limit in /etc/dnf/dnf.conf caps how many kernels stay installed. On any box with a separate boot partition, add df -h /boot to your monitoring so it warns you well before the partition fills.
Do containers need their own kernel updates?
No. Containers share the host's kernel, so updating packages inside an image never changes the kernel underneath it. Run uname -r inside a container and you'll see the host's version. Rebuilding images to chase a kernel CVE is wasted work. Patch and reboot the host, and every container on it gets the new kernel at once.
Can I get an email when updates install?
Yes. unattended-upgrades sends a report when you set Unattended-Upgrade::Mail to an address, provided the box has a working mail transfer agent. In dnf-automatic, set emit_via = email in the [emitters] section and fill in the [email] block. A short report beats reading logs across a fleet, but it only tells you what installed. It won't tell you whether anyone rebooted.
