Linux VPS

Linux kernel updates: when and how to reboot your VPS

Learn how kernel updates work on Ubuntu, Debian, AlmaLinux and Rocky Linux, how to tell if a reboot is needed, and how to reboot a VPS safely with minimal downtime.

IntermediateLinux VPS2 min read

Package updates take effect when a service restarts, but a new kernel only runs after a reboot. Until then your VPS keeps running the old, possibly vulnerable kernel. This guide shows how to tell when a reboot is due and how to do it safely.

Before you start

  • sudo access over SSH and access to your VPS control panel or console.
  • Services set to start at boot (systemctl is-enabled, see systemctl).

Check the running and installed kernels

uname -r
dpkg --list | grep linux-image
rpm -q kernel

If the newest installed kernel is newer than uname -r, you need a reboot to use it.

Is a reboot required

On Ubuntu and Debian:

cat /var/run/reboot-required 2>/dev/null
cat /var/run/reboot-required.pkgs 2>/dev/null

On AlmaLinux and Rocky Linux:

sudo dnf needs-restarting -r

To find services that still run old libraries without rebooting, use sudo needrestart (Ubuntu) or sudo dnf needs-restarting -s.

Reboot safely

  1. Install all pending updates: see apt, dnf and yum.
  2. Check /etc/fstab is valid with sudo findmnt --verify, so the server boots.
  3. Pick a quiet time and warn users if needed.
  4. Reboot: sudo reboot.
  5. Reconnect after a minute or two and confirm with uname -r and systemctl --failed.

Tip: Schedule a reboot for later with sudo shutdown -r 03:00; cancel with sudo shutdown -c.

Automatic reboots

Ubuntu's unattended-upgrades can reboot automatically at a set time. In /etc/apt/apt.conf.d/50unattended-upgrades:

Unattended-Upgrade::Automatic-Reboot "true";
Unattended-Upgrade::Automatic-Reboot-Time "04:00";

On AlmaLinux and Rocky Linux, dnf-automatic installs updates; reboots are planned separately. See automatic security updates.

Remove old kernels

sudo apt autoremove --purge

dnf keeps three kernels by default (installonly_limit in /etc/dnf/dnf.conf).

Troubleshooting

  • VPS does not come back: open the console from your control panel to see boot errors; a broken fstab line is the most common cause (see mount a disk with fstab). Our team can help through a ticket.
  • uname still shows the old kernel: on some virtualisation types the kernel is set by the host; check with support.
  • A site is down after reboot: its service was not enabled; run sudo systemctl enable --now name.

Next steps

Was this guide helpful?

Still stuck?

Ask MdmHost AI for a quick answer, or open a ticket and our team will take a look. We are here 24/7.