You might find yourself in a situation where you configured a server to a version of Ubuntu that is not considered Long Term Support (LTS). Version 19.04 is a good example of this. In these situations, it might be tricky to upgrade to a current LTS version like 24.04.
To perform the upgrade, we have to take a couple hops to get there.
Upgrade to 19.10
First you want to upgrade to 19.10, if you don’t you’ll get an error like this
Reading cache
Checking package manager
Can not upgrade
An upgrade from 'disco' to 'focal' is not supported with this tool.
This is because the version is not supported. No problem, to get around this you’ll want to move to 19.10 (Eon).
Switch Mirrors to Upgrade to 19.10
Upgrading to 19.10 should be painless, just update your sources.list here: /etc/apt/sources.list
Copy it to a safe location, and create a new sources.list file. Copy and paste these values into the file
deb http://old-releases.ubuntu.com/ubuntu eoan main
deb http://old-releases.ubuntu.com/ubuntu eoan-updates main
deb http://old-releases.ubuntu.com/ubuntu eoan-security main
Now you can run the normal update steps like this:
sudo apt update
sudo apt upgrade
sudo apt dist-upgrade
The end results, after a reboot to apply some packages, should be this:
#cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=19.10
DISTRIB_CODENAME=eoan
DISTRIB_DESCRIPTION="Ubuntu 19.10"
Upgrade to Latest Release
Depending on what version you’re on, you might have to upgrade multiple times (incremental upgrades).
For this example, being on 19.10 you will perform a release upgrade like this
do-release-upgrade
Follow the prompts, and if all goes well you should be upgraded to the next version, not necessarily the latest.
For example, from 19.10 it steps you to 20.04
# cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=20.04
DISTRIB_CODENAME=focal
DISTRIB_DESCRIPTION="Ubuntu 20.04.6 LTS"
After restarting, you will want to make sure to run the latest updates / upgrades:
sudo apt update
sudo apt upgrade
sudo apt dist-upgrade
sudo do-release-upgrade
From 20.04 we will move to 22.04 after running this second do-release-upgrade:
# cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=22.04
DISTRIB_CODENAME=jammy
DISTRIB_DESCRIPTION="Ubuntu 22.04.4 LTS"