In this tutorial, I will show you how to upgrade your Linux kernel to the latest version.
But first, what is Linux Kernel? Linux Kernel is a free and open-source, monolithic, modular, multitasking Unix-like operating system. It is the main component of a Linux operating system and is the core interface between the computer’s hardware and its processes. It makes communication possible between computer hardware and processes running on it and it manages resources effectively.
Related Articles
- How to upgrade Linux Kernel on Rocky Linux/AlmaLinux/CentOS 8
- How to upgrade Linux Kernel 5.13 to 5.15 on Ubuntu 21.10
Prerequisites
- Have Ubuntu 20.04 server
- Have commandline knowledge
- Have access to internet.
Table of Contents
- Run updates for your system
- Check the current version of Linux kernel you are running
- Download Linux kernel headers from Ubuntu Mainline
- Download Linux Kernel image
- Download modules required to build the kernel
- Install new kernel
- Reboot the system
- Conclusion
1. Run system update
The first thing we need to do in any system is to run updates in order to make system repositories up to date. If there is any upgrade needed you can run the upgrade command too.
$ sudo apt update
$ sudo apt upgarde -y
When that is complete, move to the next step.
2. Check the current Kernel version
You need to check the current kernel you are running on your system with the following command.
$ uname -r
5.4.0-88-generic
My Ubuntu 20.04 is running Kernel version 5.4.0-88-generic, so we need to upgrade this to the latest version. Head over to Ubuntu mainline to download the necessary files.
3. Get Linux kernel headers
We need to download the Linux kernel headers from the Ubuntu mainline. Head there and check for the latest release. If you do not want to download the tarball you can use the following command to download.
$ wget -c https://kernel.ubuntu.com/~kernel-ppa/mainline/v5.15-rc7/amd64/linux-headers-5.15.0-051500rc7_5.15.0-051500rc7.202110251930_all.deb
You will get the following sample output
linux-headers-5.15.0-051500r 100%[===========================================>] 11.62M 16.2MB/s in 0.7s
2021-11-21 06:39:15 (16.2 MB/s) - ‘linux-headers-5.15.0-051500rc7_5.15.0-051500rc7.202110251930_all.deb’ saved [12189104/12189104]
Also, download generic headers with the following command
$ wget -c https://kernel.ubuntu.com/~kernel-ppa/mainline/v5.15-rc7/amd64/linux-headers-5.15.0-051500rc7-generic_5.15.0-051500rc7.202110251930_amd64.deb
4. Download Linux kernel image
Next, we will need the Linux kernel image. Download with the following command;
$ wget -c https://kernel.ubuntu.com/~kernel-ppa/mainline/v5.15-rc7/amd64/linux-image-unsigned-5.15.0-051500rc7-generic_5.15.0-051500rc7.202110251930_amd64.deb
Sample output
Saving to: ‘linux-image-unsigned-5.15.0-051500rc7-generic_5.15.0-051500rc7.202110251930_amd64.deb’
linux-image-unsigned-5.15.0- 100%[===========================================>] 9.77M 14.1MB/s in 0.7s
2021-11-21 06:51:50 (14.1 MB/s) - ‘linux-image-unsigned-5.15.0-051500rc7-generic_5.15.0-051500rc7.202110251930_amd64.deb’ saved [10241908/10241908]
5. Download modules necessary to build Linux kernel
What we need now are the modules that will aid in building the Linux kernel. Get the modules by downloading them from the following;
$ wget -c https://kernel.ubuntu.com/~kernel-ppa/mainline/v5.15-rc7/amd64/linux-modules-5.15.0-051500rc7-generic_5.15.0-051500rc7.202110251930_amd64.deb
sample output
Saving to: ‘linux-modules-5.15.0-051500rc7-generic_5.15.0-051500rc7.202110251930_amd64.deb’
linux-modules-5.15.0-051500r 100%[===========================================>] 72.18M 32.9MB/s in 2.2s
2021-11-21 07:00:18 (32.9 MB/s) - ‘linux-modules-5.15.0-051500rc7-generic_5.15.0-051500rc7.202110251930_amd64.deb’ saved [75682652/75682652]
After the download is complete it is now time to run the installation
Let’s ls to see if everything has been downloaded into the system.
$ ls
linux-headers-5.15.0-051500rc7-generic_5.15.0-051500rc7.202110251930_amd64.deb
linux-headers-5.15.0-051500rc7_5.15.0-051500rc7.202110251930_all.deb
linux-image-unsigned-5.15.0-051500rc7-generic_5.15.0-051500rc7.202110251930_amd64.deb
linux-modules-5.15.0-051500rc7-generic_5.15.0-051500rc7.202110251930_amd64.deb
snap
So everything is there so we are good to run the installation.
6. Install Linux kernel
To run the installation, you can use the following command;
$ sudo dpkg -i *.deb
sample output..
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-5.15.0-051500rc7-generic
Found initrd image: /boot/initrd.img-5.15.0-051500rc7-generic
Found linux image: /boot/vmlinuz-5.4.0-90-generic
Found initrd image: /boot/initrd.img-5.4.0-90-generic
Found linux image: /boot/vmlinuz-5.4.0-88-generic
Found initrd image: /boot/initrd.img-5.4.0-88-generic
done
Give it time for the installation to complete. Now we need to reboot the system for the changes to take effect.
$ sudo shutdown -r now
Check your version again to confirm if changes took effect
$ uname -r
5.15.0-051500rc7-generic
7. Conclusion
As you can see we have successfully upgraded to the latest stable Kernel release. In case of any difficulty, you can check this documentation.