How to downgrade the kernel on Ubuntu 20.04 to the 5.4 (LTS) version

No matter what your reasons are, you may be in a situation where you need to downgrade your kernel to a specific version. In this guide, I will show you how to downgrade a recent Ubuntu Pro 20.04 AMI’s kernel to the original LTS version (5.4)

This guide has been tested on Ubuntu Pro 20.04 on AWS, but it should work also for any other cloud and with the regular versions as well.


From 18.04 onwards, Canonical introduced the rolling kernel model, which enabled the user to get the latest upstream kernel with bug fixes and performance improvements from the interim Ubuntu versions via regular updates or by launching the latest AMIs.

But what happens if you need specific kernel versions (LTS or any other) due to internal compliance, application compatibility or any other you may encounter.

How it’s done

Log in into your console and install the LTS kernel:

sudo apt update
sudo apt install -y linux-aws-lts-20.04

Now that you have the kernel installed, you need to change your boot configurations to select the older kernel as the default one.

Find the grub entry name with the following command:

sudo grep 'menuentry \|submenu ' /boot/grub/grub.cfg | cut -f2 -d "'"

This will not only list all the entries, but also will include menu sections, since it will be needed for setting the default kernel.

This is what I have in my freshly installed EC2 instance. Note that yours can change.

Advanced options for Ubuntu
Ubuntu, with Linux 5.11.0-1027-aws
Ubuntu, with Linux 5.11.0-1027-aws (recovery mode)
Ubuntu, with Linux 5.4.0-1064-aws
Ubuntu, with Linux 5.4.0-1064-aws (recovery mode)
Ubuntu 20.04.3 LTS (20.04) (on /dev/xvda1)
Advanced options for Ubuntu 20.04.3 LTS (20.04) (on /dev/xvda1)
Ubuntu (on /dev/xvda1)
Ubuntu, with Linux 5.11.0-1027-aws (on /dev/xvda1)
Ubuntu, with Linux 5.11.0-1027-aws (recovery mode) (on /dev/xvda1)

Tip: “Advanced options for…” are not kernels but just sections of the Grub menu. If you want an option that is under one of the advanced options, you need to write everything concatenated with a > sign.

Find the entry name with the desired kernel version and copy it for pasting it into the grub config file.

Warning: Backup your grub configuration:

sudo cp /etc/default/grub /etc/default/grub.bak

Open and edit the default entry in your grub configuration

sudo nano /etc/default/grub

find the line GRUB_DEFAULT=0 and change it for the following:

GRUB_DEFAULT='Advanced options for Ubuntu>Ubuntu, with Linux 5.4.0-1064-aws'

Note that yours can be different.

Note also that you need to add the "Advanced options for Ubuntu>" since this entry is under advanced options as a subitem.

Save and exit.

Now run update-grub for recreating the config file.
sudo upgrade-grub

and reboot!
(ok, sudo reboot)

Further reading

:warning: Warnings

  1. Don’t do this on production instances. The idea is to run it on a base and clean instance and use this as your base images.
  2. If you are running a new instance type that was released after the LTS release, be aware that the hardware may not be compatible with this kernel.

Thanks for the article.

It works correctly with
sudo update-grub.

sudo upgrade-grub
is an error.

1 Like

Thanks for noticing it. It seems that I can’t edit the post now… I’ll try later.

1 Like

A post was split to a new topic: Kernal downgrade support

Thanks for this lifesaver tutorial. I have one question here, if I’ve set the system up for unattended upgrades will it also automatically upgrade my kernel and grub the next time there’s a kernel upgrade available? i.e. will I lose these customizations to revert to a specific kernel?

You can use apt-mark to manually put a package on hold