When using the latest version of Debian 10 stable, also known as buster, even with all updates installed, by default, you can’t get the most recent kernel via the standard repositories in your package manager. While the idea of using Debian stable is to remain stable and rather conservative, there are several benefits with installing a newer kernel and in some cases it’s the only option to get the OS to support all your hardware. The risk and impact on stability is small and the process is rather simple.
Some of the benefits are:
- Support for previously unsupported hardware: every kernel release has a list of added drivers. Especially when you have recent hardware, a newer kernel could be required to fully support your video card for example.
- Performance improvements and bug fixes: newer kernels often contain a lot of bug fixes, have new functions and performance tweaks. Here again, the most is to gain on newer hardware.
- New kernel options and security fixes
The most recent (stable) kernel that is available at the moment of writing is version 5.9, released October 11 – 2020. You can find a complete overview of changes in every kernel version at https://www.kernel.org/ or http://kernelnewbies.org/LinuxVersions
The latest version of the kernel available, at the time of writing, via the standard repositories for Debian 10 is/was 4.19. This one was release about 2 years ago on October 22 – 1018.
jensd@deb:~$ cat /etc/debian_version 10.7 jensd@deb:~$ uname -r 4.19.0-12-amd64
There are basically two options to install a newer kernel in Debian stretch. The first is the easiest and this is what I will explain in this post. The second is not so easy. It is simply to compile a newer kernel yourself. While compiling a kernel nowadays isn’t rocket science anymore, the first way is still preferable and will save you a lot of time because others have been through the second method and present you the result of their work :)
Installing a newer kernel in Debian Buster
If you are interested, I also created a YouTube video from this blogpost. If you prefer classic text, you can just follow the rest of this article.
The easiest way to install a newer kernel in Debian, is to install it from the backports. Backports are packages taken from the next Debian release, adjusted and recompiled for usage on the stable release. For this post, I’m starting with a minimal install (system tools only), the only packages I added after finishing the installation were sudo and aptitude.
In order to install a kernel from the backports, we need to add the backports-repository for your Debian version to the apt-sources and update the list of available packages:
jensd@deb:~$ echo "deb http://deb.debian.org/debian buster-backports main" | sudo tee -a /etc/apt/sources.list deb http://deb.debian.org/debian buster-backports main jensd@deb:~$ sudo apt-get update ... Reading package lists… Done
Now, you can browse the available kernels in the backports-repository by adding -t buster-backports to your apt commands. Or just search for all available:
jensd@deb:~$ aptitude search linux-image i A linux-image-4.19.0-11-amd64 - Linux 4.19 for 64-bit PCs (signed) p linux-image-4.19.0-11-amd64-dbg - Debug symbols for linux-image-4.19.0-11-amd64 … i A linux-image-4.19.0-12-amd64 - Linux 4.19 for 64-bit PCs (signed) p linux-image-4.19.0-12-amd64-dbg - Debug symbols for linux-image-4.19.0-12-amd64 … p linux-image-5.8.0-0.bpo.2-amd64 - Linux 5.8 for 64-bit PCs (signed) p linux-image-5.8.0-0.bpo.2-amd64-dbg - Debug symbols for linux-image-5.8.0-0.bpo.2-amd64 … p linux-image-5.9.0-0.bpo.2-rt-amd64-dbg - Debug symbols for linux-image-5.9.0-0.bpo.2-rt-amd64 p linux-image-5.9.0-0.bpo.2-rt-amd64-unsigned - Linux 5.9 for 64-bit PCs, PREEMPT_RT i linux-image-amd64 - Linux for 64-bit PCs (meta-package) … jensd@deb:~$
At this point, you can either install a specific version manually or choose to go for the latest release. To install the latest release, including necessary dependencies:
jensd@deb:~$ sudo apt -t buster-backports upgrade Reading package lists… Done ... After this operation, 296 MB of additional disk space will be used. Do you want to continue? [Y/n] y
After the upgrade, you can simply perform a reboot and the new kernel should be activated as the new default.
jensd@deb:~$ uname -r 5.9.0-0.bpo.2-amd64
In most cases this is probably what you but if you experience issues with this new kernel, maybe due to issues with a change or difference in the kernel modules, you can easily switch back to the previous, or any installed, version with grub.
During boot, before the timeout expires, select “Advanced options for Debian GNU/Linux”:
In the next screen choose the working, or desired, kernel:
Install a specific kernel version
If, for some reason, you prefer a specific kernel version, you choose a kernel from the list in the aptitude output above and install it with apt. Most of the kernel images in the backports repo have suffixes. The rt-suffix stands for realtime and is mostly interesting for embedded projects or machines that will drive industrial hardware. dbg stands for debugging. And bpo is for the standard kernel from backports.
jensd@deb:~$ sudo apt install linux-image-5.8.0-0.bpo.2-amd64 [sudo] password for jensd: Reading package lists… Done Building dependency tree Reading state information… Done The following packages were automatically installed and are no longer required: geoip-database libbind9-161 libdns1104 libgeoip1 libisc1100 libisccc161 libisccfg163 liblwres161 linux-image-4.19.0-11-amd64 node-co Use 'sudo apt autoremove' to remove them. Suggested packages: linux-doc-5.8 debian-kernel-handbook The following NEW packages will be installed: linux-image-5.8.0-0.bpo.2-amd64 0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded. Need to get 50.4 MB of archives. ...
After the installation, reboot your system and select the newly installed kernel from the selection displayed in GRUB, after selecting “Advanced options for Debian GNU/Linux”:
To verify that the new kernel is used after booting:
jensd@deb:~$ uname -r 5.8.0-0.bpo.2-amd64
Uninstalling unused kernels in Debian
When everything works as expected, you can safely uninstall the older kernel in order to clean up your system and to free up some space in /boot
To check which kernels are currently installed:
jensd@deb:~$ dpkg --get-selections|grep linux-image linux-image-4.19.0-11-amd64 install linux-image-4.19.0-12-amd64 install linux-image-5.8.0-0.bpo.2-amd64 install linux-image-5.9.0-0.bpo.2-amd64 install linux-image-amd64 install
Uninstall the old one:
jensd@deb:~$ sudo apt remove linux-image-4.19.0-11-amd64 Reading package lists… Done Building dependency tree Reading state information… Done The following packages were automatically installed and are no longer required: geoip-database libbind9-161 libdns1104 libgeoip1 libisc1100 libisccc161 libisccfg163 liblwres161 linux-image-4.19.0-12-amd64 node-co Use 'sudo apt autoremove' to remove them. The following packages will be REMOVED: linux-image-4.19.0-11-amd64 0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded. After this operation, 270 MB disk space will be freed. Do you want to continue? [Y/n] y Removing linux-image-4.19.0-11-amd64 (4.19.146-1) … /etc/kernel/postrm.d/initramfs-tools: update-initramfs: Deleting /boot/initrd.img-4.19.0-11-amd64 /etc/kernel/postrm.d/zz-update-grub: Generating grub configuration file … Found linux image: /boot/vmlinuz-5.9.0-0.bpo.2-amd64 Found initrd image: /boot/initrd.img-5.9.0-0.bpo.2-amd64 Found linux image: /boot/vmlinuz-5.8.0-0.bpo.2-amd64 Found initrd image: /boot/initrd.img-5.8.0-0.bpo.2-amd64 Found linux image: /boot/vmlinuz-4.19.0-12-amd64 Found initrd image: /boot/initrd.img-4.19.0-12-amd64 done
That should be all it takes in order to install a recent kernel and cleanup older kernels on a Debian system. Not so difficult as you thought probably :)