Knowledgebase

Find frequently asked questions and setup guides by searching or by browsing the categories.

The Short Answer

uname -r
sudo apt update
sudo apt upgrade
sudo reboot

After the server is back, run uname -r again: it should print the newer version. The same steps work on Debian, where the kernel metapackage is linux-image-amd64.

Before You Start

  • Take a snapshot: it is the fastest way back if the server does not boot. See snapshot vs backup.
  • Find the console: open the server console in your provider's control panel once, so you know where it is. You need it to pick an older kernel at boot.
  • Check your services: make sure the services you need start on their own after a reboot; see how to list services with systemctl.

How Ubuntu Packages the Kernel

A metapackage such as linux-generic always depends on the newest kernel of its series. Each kernel version that changes the kernel's internal interface gets a new package name, so apt installs it next to the old one rather than over it. List the installed kernels:

dpkg --list 'linux-image*' | grep ^ii

After the upgrade, Ubuntu creates /var/run/reboot-required. The kernel you see in uname -r does not change until you reboot.

GA and HWE Kernels

Each Ubuntu LTS release starts with a general availability (GA) kernel that is supported for the life of the release. Hardware enablement (HWE) kernels bring newer kernel series from later releases, mainly for new hardware, and move forward as those releases appear. On a virtual server the GA kernel is usually the right choice. Change to HWE only for a specific reason, such as a driver or feature you need, and test it on a copy first. The metapackage name shows which one you have: HWE metapackages contain hwe.

Keep the Previous Kernel

sudo apt autoremove removes old kernels, but by default it keeps two: the one you are running and the newest installed one, or the one before it if you already run the newest. A fallback stays installed. Do not purge the kernel you came from until the new one has run well for a few days. Never remove the kernel that uname -r shows.

Boot an Older Kernel from GRUB

  1. Open the server console in your provider's control panel.
  2. Reboot, and hold Shift (BIOS boot) or press Esc (UEFI boot) as the server starts to show the GRUB menu.
  3. Choose "Advanced options for Ubuntu" and pick the older kernel.

That choice lasts for one boot. Cloud images often hide the menu with a zero timeout. To show it every time, set GRUB_TIMEOUT_STYLE=menu and GRUB_TIMEOUT=5 in /etc/default/grub, check that no file in /etc/default/grub.d/ overrides them, and run sudo update-grub.

Live Patching

Canonical Livepatch applies some critical kernel security fixes to the running kernel without a reboot. It is part of Ubuntu Pro, so the machine must be attached to a Pro subscription, and it covers supported Ubuntu kernels only:

sudo pro enable livepatch
sudo canonical-livepatch status

Livepatch shortens the time between reboots; it does not replace them. New kernel packages still take effect only after a restart.

Troubleshooting

  • uname -r has not changed: the new kernel was not installed (check apt list --upgradable for kernel packages kept back), or GRUB booted another entry.
  • The new kernel does not boot: start the older one from GRUB through the console, then remove the faulty kernel package or wait for the next update.
  • /boot is full: on systems with a separate /boot partition, old kernels fill it. Run sudo apt autoremove --purge; see how to check disk space.

Stay with kernels from the Ubuntu archive. Kernels installed by hand from elsewhere get no security updates through apt. For the restart itself, see how to reboot a Linux server.

Was this answer helpful?
Loading...