hardware, linux

How to Rollback Your Linux Kernel on Ubuntu!

This post contains affiliate links. Read the full disclosure here.

TL;DR

If you just want the steps you need to take follow them here. If you want some information on how they fit together and why, feel free to read below

# you will need to install a few prereq's most likely
sudo apt install aptitude curl aria2 libaria2-0
cd /tmp && wget -c https://github.com/teejee2008/ukuu/releases/download/v18.9.1/ukuu-v18.9.1-amd64.deb
sudo dpkg -i ukuu-v18.9.1-amd64.deb
ukuu --list
# pick the kernel you want from the list (ex. v4.19.125 below)
sudo ukuu --install v4.19.125
sudo apt install grub-customizer
sudo grub-customizer

Background

I have a little ‘server’ I bought back in 2012 (Foxconn NTA350) which has been faithfully serving me since then as a HTPC (running mythv, recording via SiliconDust 2-Tuner OTA Tuner). Historically, it’s been bulletproof. I initially started with mythbuntu distribution, they recently stopped supporting that so I’ve gone to the mainstream ubuntu distribution and it’s been largely fine. It ran in my basement, headless, happily, for years.

Problem

Then linux 5.x changed everything. When I upgraded to 20.04 LTS, the new 5.x kernels came with the upgrade. Immediately I had issues with my Sabrent dual-bay external USB Drive that I have plugged in. I couldn’t go more than a couple days (at absolute best) without my server hanging on me. I troubleshot things (I’ll save you the gory details but in the end there was nothing but a reboot that could fix it, and the load would go from decimals to double digits

I also would see the following errors in my logs, and at this point the drive was hung and if I tried to access the mountpoint (or mythtv or any apps tried to use the drive) they would block waiting for i/o (which could never come).

Jun 29 20:20:35 tiny-myth kernel: [85834.433030] xhci_hcd 0000:04:00.0: WARN Cannot submit Set TR Deq Ptr
 Jun 29 20:20:35 tiny-myth kernel: [85834.433052] xhci_hcd 0000:04:00.0: A Set TR Deq Ptr command is pending.
 Jun 29 20:20:35 tiny-myth kernel: [85834.565209] usb 9-2: reset SuperSpeed Gen 1 USB device number 2 using xhci_hcd
 Jun 29 20:21:06 tiny-myth kernel: [85865.665815] xhci_hcd 0000:04:00.0: WARN Cannot submit Set TR Deq Ptr
 Jun 29 20:21:06 tiny-myth kernel: [85865.665838] xhci_hcd 0000:04:00.0: A Set TR Deq Ptr command is pending.
 Jun 29 20:21:06 tiny-myth kernel: [85865.805725] usb 9-2: reset SuperSpeed Gen 1 USB device number 2 using xhci_hcd

This led me to the following github issues (for raspberry Pi, but it’s the same issue) which is still being actively discussed as of late June 2021 (I’ll try to update as this changes).

Solution

The ‘resolution’ for the above (only thing that works as of now) is to rollback your kernel version to 4.19, which I had no idea how to do and felt nervous about rolling back YEARS given I had updated my Ubuntu to 21.04 in an attempt to see if this issue went away (it didn’t).

So without further ado, here’s the steps!

Install/Use ukuu

ukuu allows you to look at the kernels that are available for Ubuntu and will automate the installation of the kernels. It used to be available for free/open source but has been shifted to a pay model. I didn’t choose the pay option but used the (still legit/legal) open sourced version on github. Installing old kernels isn’t something I do, I didn’t think I’d get my “money’s worth” out of the app, that said if I need this again I’ll likely throw $15 to the author because it does make this process easy and everyone deserves compensation for their time if you get enough value (you determine when this threshold is!).

# you will need to install a few prereq's most likely
sudo apt install aptitude curl aria2 libaria2-0
cd /tmp && wget -c https://github.com/teejee2008/ukuu/releases/download/v18.9.1/ukuu-v18.9.1-amd64.deb
sudo dpkg -i ukuu-v18.9.1-amd64.deb

Now that it’s installed, you can list out the kernels you can try

ukuu --list

You should see something like below

jim@tiny-myth:~$ ukuu --list
 ukuu v18.9.1
 Distribution: Ubuntu 21.04
 Architecture: amd64
 Running kernel: 4.19.125-0419125-generic
 Kernel version: 4.19.125-0419125-generic
 Cache: /home/jim/.cache/ukuu
 Temp: /tmp/ukuu/42wM4AFE
 aria2c version: 1.35.0
 Fetching index from kernel.ubuntu.com…
 OK
 Found installed: 4.19.125-0419125.202005271314
 Found installed: 5.11.0-22.23
 Found installed: 3.13.0.158.168
 Found installed: 5.11.0.22.23
 Found installed: 5.8.0-59.66
 ======================================================================
 Available Kernels
 v5.11.0-22.23                  5.11.0.22.23              Installed
 v5.8.0-59.66                   5.8.0.59.66               Installed
 v5.6.17                        5.6.17                    
 v5.6.16                        5.6.16                    
 v5.6.15                        5.6.15                    
 v5.6.14                        5.6.14                    
 v5.6.13                        5.6.13             
....

Now you can install the version you want (v4.19.125 for our purposes)

sudo ukuu --install v4.19.125

That’s it. You now have the right kernel installed and can select it from Grub on a reboot. HOWEVER, it would be nicer if we could adjust this and make it the default in Grub, right?

Boot Kernels by Default

Grub

Grub is how linux sets up the bootloader. Grub is a pain. It’s normally taken care of by the distribution, and 99.9% of the time that’s fine and you’ll never have to worry about it nor should you care. But since we’re taking over for the distribution default kernel we’ll have to manage this ourselves.

You can look at the grub default for what kernel is booted by performing

cat /etc/default/grub

And looking for the ‘GRUB_DEFAULT’ setting. It’s typically a number and is the index of the kernel in the order that’s in the grub configuration. This is ALSO a pain to figure out the right number to change it to. Luckily there’s a utility for this as well, ‘grub-customizer’. This will allow us a graphical tool to select the kernel we want to use and it will make the change to the /etc/default/grub file

Install grub-customizer

Run the following command to install grub-customizer

sudo apt install grub-customizer

Then fire it up

sudo grub-customizer

Then select the ‘General’ tab and the kernel you’d like to be the default in the ‘predefined’ dropdown

The End

At this point you should be able to reboot and the new kernel should be selected (if you selected it in grub-customizer).

If this helped, let me know in the comments. I couldn’t find straightforward information on how to rollback a kernel and this did the job without a lot of fuss so I thought I’d write it down in case someone else benefited.

Cheers! 🙂