Skip to content
STAGE33R

Guides · Reboot and uptime · 5 steps · reviewed

Kernel updates without surprises: reboot-required, needrestart and Livepatch on Ubuntu

Installing a kernel update does not protect you until the server runs it. Library updates have the same issue: running services keep the old code in memory until restarted. Knowing which applies saves unneeded reboots and avoids false confidence.

  1. Is a reboot required?

    Compare the running kernel with the newest installed one.

    uname -r
    ls /boot/vmlinuz-* | tail -n 2
    cat /var/run/reboot-required 2>/dev/null || echo 'no reboot flagged'
  2. Which services use old libraries?

    needrestart reads the running processes and tells you which ones must be restarted.

    sudo apt-get install -y needrestart
    sudo needrestart -r l
  3. Restart them, in a quiet moment

    Each restart interrupts that service for a moment.

    sudo needrestart -r a
  4. Consider Livepatch for the kernel

    Ubuntu Pro includes Livepatch, which applies critical kernel fixes without a reboot. It reduces urgency, but you still reboot for other updates.

    sudo pro status
    sudo canonical-livepatch status
  5. Plan the reboot with the reboot checklist

    Check that services, pm2 apps and containers will return.

Common mistakes

  • Believing apt upgrade made you safe while the old kernel still runs.
  • needrestart in interactive mode blocking an unattended run: set restart to list or automatic.
  • Livepatch is not a substitute for rebooting after other updates.

How to undo it

A kernel that fails to boot can be selected from the boot menu through the provider console, which keeps the previous kernel by default.

Sources

Commands are for Debian and Ubuntu unless noted. Test on a copy first and keep a backup: you are responsible for changes on your own systems.