I was very late to the game in upgrading my Ubuntu Servers. I was running Ubuntu 16.04. Even though is it a LTS branch, also known as Long Term Support, the ESM period starting in April 2021. Which means, if you want security updates, you have to pay between $25-$1500 (depending on the ESM product) per year.

So, upgrading before hand is recommended. But, if you are like me, you wait until you can no longer update. 😥 You may get an error like this:

Invalid package information 

After updating your package information, the essential package 
'ubuntu-minimal' could not be located. This may be because you have 
no official mirrors listed in your software sources, or because of 
excessive load on the mirror you are using. See /etc/apt/sources.list 
for the current list of configured software sources. 
In the case of an overloaded mirror, you may want to try the upgrade 
again later. 

Well, I got some good news for you! I figured a way to update it. Well, at least on Digital Ocean. Which you should be able to translate to any other environment. First and foremost, I would probably make sure you update your MySQL installation. I had to move everything into a docker for MySQL on the server, which I can talk about later on, but, do that first, because upgrading from 16.04 to 20.04 is huge and I ended up not getting my MySQL server over every time until I put it into a docker.

As always, backup your server by creating a snapshot.

Next we will backup your sources.list and run this command:

sudo cp /etc/apt/sources.list ~/sources.list
sudo sed -i 's/mirrors.digitalocean.com/us.archive.ubuntu.com/' /etc/apt/sources.list

What this does, is first, the cp copies your sources.list file to your home directory. Then the sed replaces everything that is pointing to the Digital Ocean servers to the archived ubuntu servers. This is so we can get the update files. I would then run this:

sudo apt-get update
sudo apt-get upgrade -y
sudo apt-get dist-upgrade

Which should upgrade your system. Answer any of the questions the best you can. For me, this upgraded me from 16.04 all the way to 20.04. It failed at some point, but ran it again made it work. Most files I kept my local version, since, I had modifications in there on purpose. Once finished, you can then revert your sources.list file back to normal by running this:

sudo sed -i 's/us.archive.ubuntu.com/mirrors.digitalocean.com/' /etc/apt/sources.list

I would then update your package list and upgrade anything

sudo apt-get update
sudo apt-get upgrade -y

That’s it, you are done! Congrats, you should now be running Ubuntu 20.04!