Linux Kernel 5.18 has been released with support for AMD HSMP driver, various AMD nested virtualization improvements, freesync enabled by default in AMDGPU driver, Btrfs support encoded I/O and faster fsync, Numa balancing scheduler updates for AMD EPYC servers, and much more.
For a complete list of changes, visit the 5.18 kernel changelog by visiting Kernel Newbies.
In the following tutorial, you will learn how to install the latest 5.18 Linux Kernel on Ubuntu 20.04 LTS Focal Fossa using the command line terminal and remove and restore the original kernel.
Table of Contents
Update Ubuntu
Before you begin, update your system to ensure all existing packages are up to date, as this is essential when installing/upgrading Linux kernels to avoid conflicts.
sudo apt update && sudo apt upgrade
Install Linux Kernel 5.18 – PPA Method
Import TuxInvader PPA
NOTE THIS PPA METHOD ONLY WORKS CURRENTLY FOR UBUNTU 20.04 LTS OR SIMILAR RELEASES BASED ON FOCAL FOSSA SUCH AS LINUX MINT 20 ONLY!!
The first option to install the Linux 5.18 kernels is to install the ppa:tuxinvader/lts-mainline by TuxInvader. This has some of the most up-to-date 5.18 generic kernels, and the previous 5.17 kernel builds and is often updated regularly.
The drawback is that this is an untrusted PPA and not an official release by the Ubuntu teams, but given the history of the PPA, it is safe as any other reputable PPA.
First, install the LTS Mainline Tuxinvader PPA as follows.
sudo add-apt-repository ppa:tuxinvader/lts-mainline -y
Once installed, update your repository list.
sudo apt update
Next, proceed to the installation of the Linux Kernel. Ensure that any sensitive documents are backed up just in case anything goes wrong.
Install Linux Kernel 5.18 from Tux PPA
Next, install the 5.18 generic Linux kernel drivers by executing the following command.
sudo apt-get install linux-generic-5.18 -y
Once complete, you will need to reboot your system for the new kernel to be fully activated.
reboot
Once logged back into your system, run the following command to confirm the new kernel version is running.
uname -r
Example output:
For people that love pretty printouts, install the neofetch package.
sudo apt install neofetch -y
Now print your system specs that will show the kernel version as follows.
neofetch
Example output:
Install Linux Kernel 5.18 – Ubuntu Mainline Repo
The second option is to manually install the Linux Kernel to download the .deb package from the Ubuntu mainline repository. This works well, but you will need to keep the maintenance up when new updates arise by manually re-installing the new kernel packages.
First, visit the Ubuntu Mainline Kernel 5.18 Repository and find the latest version. Available are AMD64, ARM64, ARMHf, ppc64el, and s390x. The most common will be AMD64 for most users.
Example:
Next, download the required packages using the wget command.
Example (ONLY DO NOT USE):
Required for AMD64 users:
wget https://kernel.ubuntu.com/~kernel-ppa/mainline/v5.18/amd64/linux-image-unsigned-5.18.0-051800-generic_5.18.0-051800.202205222030_amd64.deb
wget https://kernel.ubuntu.com/~kernel-ppa/mainline/v5.18/amd64/linux-modules-5.18.0-051800-generic_5.18.0-051800.202205222030_amd64.deb
Optional Extras for AMD64 users:
wget https://kernel.ubuntu.com/~kernel-ppa/mainline/v5.18/amd64/linux-headers-5.18.0-051800_5.18.0-051800.202205222030_all.deb
Handy tip for s390x, ppc64el, armhf, and arm64 users, change the https://kernel.ubuntu.com/~kernel-ppa/mainline/v5.18/amd64/ to https://kernel.ubuntu.com/~kernel-ppa/mainline/v5.18/{alternative architecture/ or grab the links from the download page.
The required packages are what they mean, and you need to download those to install the Linux Kernel. The optional extras include support for DKMS modules and can be recommended to install for Desktop users.
Next, in the folder, you downloaded the new Linux Kernel packages, give the packages executable permission using the following blanket command.
sudo chmod +x *.deb
Now begin the installation using the dpkg -i command.
sudo dpkg -i *.deb
Once complete, you will need to reboot your system for the new kernel to be fully activated.
reboot
Once logged back into your system, run the following command to confirm the kernel version is running.
uname -r
Example output:
And that’s it; you have successfully installed the latest Linux Kernel 5.18.
How to Restore Default Kernel
For users who find the new kernel has bugs for their hardware, say, loss of sound, use the following steps to restore the default kernel; if you installed an alternative kernel, replace the default kernel section with whatever you want to install.
For users that installed the Tux PPA Mainline kernel, you must remove the repository by adding the –remove syntax to the previous add command.
sudo add-apt-repository --remove ppa:tuxinvader/lts-mainline -y
Now run an APT update.
sudo apt update
Begin the removal and restoration, use the following command.
sudo apt-get autoremove linux-generic-5.18* linux-headers-5.18* linux-image-unsigned-5.18* linux-modules-5.18* -y
Next, you will see the following prompt advising that you must make sure a kernel is installed or re-installed before you reboot if you remove the current kernel. Otherwise, your system will be destroyed, unbootable, broken, etc.
Example:
Press the tab key, select <No>, and press the ENTER KEY.
Before we reboot, make sure the default generic is installed, do not fuss too much as you can install alternative versions later on as we are just trying to get your system back to working order.
sudo apt install --install-recommends linux-generic-hwe-20.04 -y
Now, you may notice it will show an output saying this is already installed. You did not remove the kernel after installing Linux Kernel 5.18; users who did this will re-install the latest recommended kernel for Ubuntu 20.04 LTS.
Example:
Now reboot.
reboot
Now verify the kernel installed, which should be the default generic kernel.
sudo uname -r
Example output:
As above, you have fallen back to the default kernel.
Alternative Kernels
For those that want different options besides the PPA or manually installing, check out the following custom kernel tutorials, which often boast the latest Linux custom-built kernels.
- How to Install XanMod Linux Kernel on Ubuntu 20.04 – Edge branch contains the latest kernel.
- How to Install Liquorix Linux Kernel on Ubuntu 20.04 – Often up-to-date but not as fast as XanMod, often a week behind.
Comments and Conclusion
In the tutorial, you have learned how to install the latest 5.18 Linux kernel on your Ubuntu 20.04 LTS Focal Fossa Desktop or Servers. Note, if your system is a production server, it would be advised to use the existing kernel that ships the standard installation for the most stability.
However, for those wanting to try kernel 5.18, take backups as many jump ahead sometimes and regret the decision. Ensure that the users who manually install the .deb packages keep checking for updates.