Install a Linux kernel of choice under Ubuntu.

Install a Linux kernel of choice under Ubuntu.

Checking this one off of the "did not expect I'd ever have to figure this one out" list. Here's a quick guide on how to install a Linux kernel version of choice under Ubuntu 20.04 LTS.

Alternative title: Fix amdgpu issues and related system stability woes with your Radeon 5600/5700 GPUs under Ubuntu 20.04.

While you normally probably don't need or want to do this, there are a few cases where this can come in very handy. For example, it seems like the kernel version Ubuntu 20.04 ships with has some issues baked in related to more recent AMD GPUs that have since been resolved, but as 20.04 is the LTS release it might take a while before these more recent versions of the kernel are incorporated.

In my case I was having issues with incredibly slow boot up times, lots of amdgpu related error messages and things like it taking sometimes several minutes before my computer would become usable when trying to unlock the computer. Clearly not ideal, and a huge bother when trying to get work done. But I digress.

Mainline

Fortunately it is quite simple to install a kernel version of choice by using a tool called Mainline. This is an open source fork off of Ukuu, which recently has become a paid (and now closed-source) tool. Both options will work and are, at least at the time of this writing, very similar in functionality and feature set, so you can't go wrong with either choice. For this guide I'll use Mainline. Let's install it now.

sudo add-apt-repository ppa:cappelikan/ppa
sudo apt install mainline

Now you can go ahead and launch the application. It'll show up in your application list as Ubuntu Mainline Kernel Installer.

The first time you launch the application it will take a while as it downloads a list of a whole bunch of kernel versions. Just let it sit there for a while until eventually you'll see the above window. In my case at the time of publishing this article the recent-most kernel version included with Ubuntu 20.04 was 5.4.0.40.44, which you see as being installed in the screenshot above.

According the bug reports and whatnot I was reading through, it seemed like the issues I was experiencing with my AMD Radeon 5600XT should be resolved in versions of the Linux kernel newer than 5.7.1, so I opted to try the recent-most version at the time of writing, which is 5.7.9. Depending on what you're looking for you might want to select a more appropriate version, or simply go for the recent-most version if you're just out to live on the cutting edge of things.

Simply select the version you would like to install, and click the Install button on the right-hand side of the screen. Follow the on-screen instructions, and once everything is done you'll have to reboot to start using the new version.

Once rebooted, you should be running on the version you have selected. You can confirm this by running the uname -a command, which should tell you what current version of the linux kernel is running, or alternatively you can boot up the Mainline app again, which will tell you what the currently running version is too.

Next time you run through your usual apt-update steps, you'll notice when running apt autoremove that the previous version of the kernel will now be removed. You might want to wait a bit before you do this to ensure your system is running as you want it to. While you can always install an older version of the Linux kernel using the Mainline app, it only has the Mainline versions available, not Ubuntu-specific flavors, which is what is installed with your Ubuntu installation by default.

If you end up having removed the Ubuntu-specific flavors and want to go back to those later on, you might want to check out this bash script. While I have not used this myself as I'm happy with the stability of my system right now, this should help you get back to a Ubuntu-flavored kernel.

That's all for now. I hope this is helpful to some of you. It's not too complicated fortunately, though switching to a different kernel can cause stability issues or worse. As always, be sure to have a backup of your most important files, and ideally a way to fix your system ready just in case you need it.

Thank you.