A reboot is needed
- Check
host.reboot_required- Severity
- medium
- Runs
- on the server, in the daily run of the agent
- Looks at
- A newer kernel is installed than the one running, or /var/run/reboot-required exists
What the check looks at
The agent compares the running kernel (uname -r) with the newest installed kernel, and on Debian and Ubuntu
it also checks whether /var/run/reboot-required exists. The packages that asked for the reboot are listed in
/var/run/reboot-required.pkgs.
Why it matters
A kernel update only takes effect after a reboot. Until then the server runs the old kernel with the vulnerabilities the update fixed, even though the package manager reports everything as current. The same applies to CPU microcode, and in practice to glibc and systemd, which almost every process uses.
How to fix it
Reboot at a time that suits the service. Before that, make sure everything comes back on its own: services
enabled (systemctl is-enabled <service>), containers with a restart policy (--restart unless-stopped).
Debian and Ubuntu
cat /var/run/reboot-required.pkgs
sudo reboot
unattended-upgrades can reboot for you at a fixed time:
Unattended-Upgrade::Automatic-Reboot "true";
Unattended-Upgrade::Automatic-Reboot-Time "04:00";
RHEL, Rocky Linux and AlmaLinux
sudo dnf needs-restarting -r
sudo reboot
needs-restarting -r exits with code 1 when a reboot is needed. dnf-automatic reboots after such updates
with reboot = when-needed in /etc/dnf/automatic.conf.
Alpine
uname -r
ls /lib/modules
sudo reboot
Alpine keeps one kernel version. When the directory in /lib/modules differs from uname -r, the modules of
the running kernel are already gone, and loading a new module fails until the reboot.
How to check the fix
After the reboot, uname -r shows the newest installed kernel, /var/run/reboot-required is gone on Debian and
Ubuntu, and dnf needs-restarting -r exits with 0 on the RHEL family.
When a warning is fine
For a few days, until your planned maintenance window. With Ubuntu Livepatch or RHEL kpatch, the most severe kernel fixes are applied without a reboot, but the check still warns: live patches cover a subset of the fixes, and Canonical states that Livepatch does not replace reboots.
Sources
- dnf needs-restarting —
-rand exit codes - unattended-upgrades README —
Automatic-Reboot,Automatic-Reboot-Time - Ubuntu Livepatch — not a replacement for rebooting