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 running kernel (uname -r) against the newest kernel in /lib/modules, and on Debian and Ubuntu the file
/var/run/reboot-required. The packages that asked for the reboot are in /var/run/reboot-required.pkgs, and
the evidence line names them.
Risk
Until the reboot, the server runs the old kernel with the vulnerabilities that the update fixed, while the package manager reports every package as current. The same holds for CPU microcode, and in practice for glibc and systemd, which almost every process uses.
How to fix it
Reboot at a time that suits the service. Check first that everything starts again 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 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. With reboot = when-needed in
/etc/dnf/automatic.conf, dnf-automatic reboots after such updates.
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 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 the planned maintenance window. Ubuntu Livepatch and RHEL kpatch apply the most severe kernel fixes without a reboot, and the check still reports: live patches cover part of the fixes, and Canonical states that Livepatch does not replace reboots.
Sources
- dnf needs-restarting (
-r, exit codes) - unattended-upgrades README
(
Automatic-Reboot,Automatic-Reboot-Time) - Ubuntu Livepatch. Livepatch is not a replacement for rebooting.