Install Linux Kernel 5.18 on Ubuntu 20.04 LTS
If you’re still running the stock 5.4 kernel on your trusty 20.04 machine and need the new features or bug fixes in 5.18, this guide shows you how to get it up and running without turning your system into a broken mess.
Why bother with 5.18?
I’ve seen users complain that their Wi‑Fi stalls after a firmware upgrade while they’re stuck on an old kernel. Kernel 5.18 brings better hardware support for newer GPUs, improved power management, and the latest security patches. If you need one of those, upgrading is worth it.
1. Prepare Your System
sudo apt update sudo apt upgrade -y sudo apt install build-essential dkms linux-headers-generic
The build-essential package gives you the compiler and libraries you might need for optional DKMS modules. linux-headers-generic ensures you have headers that match whatever kernel is currently active; they’ll be handy if you later need to rebuild a module.
2. Download the Kernel Packages
Head over to the official mainline builds: https://kernel.ubuntu.com/~kernel-ppa/mainline/v5.18/ . Pick three files:
- linux-headers-5.18.x_all.deb
- linux-headers-5.18.x_generic_amd64.deb (or _i386.deb)
- linux-image-unsigned-5.18.x_generic_amd64.deb
On the command line, something like:
wget https://kernel.ubuntu.com/~kernel-ppa/mainline/v5.18/$(uname -m)/linux-headers-5.18.*_all.deb wget https://kernel.ubuntu.com/~kernel-ppa/mainline/v5.18/$(uname -m)/linux-headers-5.18.*_generic_$(dpkg --print-architecture).deb wget https://kernel.ubuntu.com/~kernel-ppa/mainline/v5.18/$(uname -m)/linux-image-unsigned-5.18.*_generic_$(dpkg --print-architecture).deb
Those are the only packages you actually need; no meta‑packages or signed images for 20.04, because we’re installing a “mainline” kernel manually.
3. Install the Kernel
First install the header files so that any DKMS modules can compile against the new headers:
sudo dpkg -i linux-headers-5.18.*_all.deb sudo dpkg -i linux-headers-5.18.*_generic_$(dpkg --print-architecture).deb
Then install the image:
sudo dpkg -i linux-image-unsigned-5.18.*_generic_$(dpkg --print-architecture).deb
If dpkg complains about missing dependencies, run:
sudo apt-get -f install
The dpkg commands will copy the files into /boot, register them with GRUB, and update the initramfs. Running apt‑get -f install pulls in any runtime dependencies you might have missed.
4. Verify
After installation, run:
uname -r
You should see something like 5.18.0-1-generic. If that shows up, you’re good to go. Now reboot:
sudo reboot
During the boot menu, if you’re not automatically taken to the new kernel, press Esc or Shift at startup to bring up GRUB and select “Advanced options for Ubuntu” => “5.18.x generic”.
5. Rollback if Things Go South
If you hit a wall—boot loop, missing drivers—re‑boot into recovery mode and choose the previous kernel from the GRUB menu. Once back in, you can remove the new kernel packages:
sudo dpkg -r linux-image-unsigned-5.18.*_generic_$(dpkg --print-architecture) sudo dpkg -r linux-headers-5.18.*_all sudo dpkg -r linux-headers-5.18.*_generic_$(dpkg --print-architecture)
Then run sudo update-grub to clean up.
That’s the whole dance: pull the right debs, install them, reboot, and if you’re unlucky, roll back. No fancy scripts or third‑party PPA required.