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 21.10 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 make some minor changes depending on who your host is. For example, we’ll work with Linode.
Operating System: Ubuntu 21.10
Kernel: Linux 5.13.0-52-generic
Architecture: x86-64
Hardware Vendor: Linode
Update Repo Sources
Depending on your host, the repo sources might be pointing to internal mirrors. This is the case with Linode.
deb http://mirrors.linode.com/ubuntu/ impish main restricted
deb http://mirrors.linode.com/ubuntu/ impish-updates main restricted
deb http://mirrors.linode.com/ubuntu/ impish universe
deb http://mirrors.linode.com/ubuntu/ impish-updates universe
etc..
What happens when they do this is at the end of life they don’t get it synchronized and you get errors like this when trying to run upgrades:
Reading package lists... Done
E: The repository 'http://security.ubuntu.com/ubuntu impish-security Release' no longer has a Release file.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.
E: The repository 'http://mirrors.linode.com/ubuntu impish Release' no longer has a Release file.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.
E: The repository 'http://mirrors.linode.com/ubuntu impish-updates Release' no longer has a Release file.
To fix this, you need to reset the source list to point to the ubuntu mirrors. You can do this by using something like SED to make a quick update like this:
sed -i 's|http://mirrors.linode.com/ubuntu|http://old-releases.ubuntu.com/ubuntu|' /etc/apt/sources.list
All we’re doing is updating the sources.list file by replacing http://mirrors.linode.com/ubuntu with http://old-releases.ubuntu.com/ubuntu
Upgrade to 22.04
With the sources list updated, you can now run your normal updates like this:
sudo apt update
sudo apt upgrade
sudo apt dist-upgrade
Then finalize with this:
do-release-upgrade
This will require an update, but the end result will be:
Operating System: Ubuntu 22.04.4 LTS
Kernel: Linux 5.15.0-113-generic
Architecture: x86-64
Hardware Vendor: Linode