How to Upgrade Ubuntu Server to 20.04 from 18.04
This step by step guide shows how to upgrade Ubuntu 18.04 LTS server to 20.04 LTS over an SSH connection or otherwise.
Ubuntu 20.04 LTS is released with new kernel and new features. If you are running an Ubuntu server, you might be wondering about upgrading to Ubuntu 20.04 LTS server.
In this tutorial, I’ll show you the steps to upgrade Ubuntu server version from 18.04 to 20.04 LTS.
Upgrading to Ubuntu 20.04 LTS server from 18.04
Before you go on upgrading your server, you should keep a few thing in mind.
The server upgrade process may take half an hour or more and this will result in downtime. If you are running a web service like WordPress or some other public facing service, be prepared for your services to be offline for some time.
This is why you should only upgrade to the new version when it is really critical.
Second thing is to make a backup of your server. I use Linode cloud platform for my servers and creating a backup of the entire server image is just a matter of a few clicks.
With that in mind, let’s see how to upgrade to Ubuntu 20.04 server.
I am using root for running the commands. If you are not logged in as root, you should have sudo rights and run these commands with sudo.
Step 1: Update your system
Log in to your Ubuntu server. If you it’s a remote system, use SSH to log in. I mean you already know how to access your server, right?
Update your Ubuntu server first for any pending software update:
apt update && apt dist-upgrade -y
If it asks you to reboot, you must restart your Ubuntu server. Otherwise, it won't start the upgrade procedure.
Checking for a new Ubuntu release
You have not rebooted after updating a package which requires a reboot. Please reboot before upgrading.
Step 2: Configure Update Manager
Ubuntu provides a crucial tool called Update Manager for upgrading your system to a newer version.
Normally, it should already be installed but do verify that your Ubuntu server has update manager tool installed:
apt install update-manager-core
Next, you should check the content of the /etc/update-manager/release-upgrades file and make sure that the last line is Prompt=lts and it is not commented out.
This means that your Ubuntu system will be updated to a new stable LTS version. It looks something like this:
Step 3: Upgrade Ubuntu server to a new LTS version
Once you have made sure of that, you can upgrade your Ubuntu 18.04 server to Ubuntu 20.04 LTS with this command:
do-release-upgrade
You may see a message like this that says it cannot find a new version to upgrade to.
Checking for a new Ubuntu release
There is no development version of an LTS available.
To upgrade to the latest non-LTS develoment release
set Prompt=normal in /etc/update-manager/release-upgrades.
If you do, you can force the upgrade with -d option like this:
do-release-upgrade -d
The -d option forces to look for development release which is 20.04 at present.
The rest of the procedure is basically pressing enter to what it demands.
Upgrading Ubuntu server over SSH connection? Pay attention!
If you are using SSH to log in to your system, you should see a warning message like this:
This session appears to be running under ssh. It is not recommended to perform a upgrade over ssh currently because in case of failure it is harder to recover.
See, the version upgrade procedure needs your input at several steps. If you are doing it over SSH and your connection gets disconnect, what happens to the upgrade? Will it hang? How will it receive the critical user input to proceed with the upgrade?
Don’t worry. Ubuntu is intelligent. The do-release-upgrade tool takes care of this. It automatically opens a new ssh session at port 1022 with screen. If you have custom firewall, you must open the port 1022.
iptables -I INPUT -p tcp --dport 1022 -j ACCEPT
If you get disconnected from the server in the middle of the upgrade, you can reconnect and recover the session by connecting to your server through ssh but at port 1022 like this:
ssh root@server_ip_address -p 1022
If you don’t see the upgrade procedure running, use the screen command like this:
screen -x
Follow the on screen instructions and you should be upgraded to the new server in around 20-30 minutes (or even less).
I noticed that it took considerable time at the step where it upgrades LXD. I almost thought that my SSH connection hanged.
And if you screens like the one above where you have to make a choice, press tab to switch between the choices and enter to confirm your input.
After the upgrade completes, you have to restart your Ubuntu server. You can verify that you are using Ubuntu 20.04 with lsb_release -a command:
lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 20.04 LTS
Release: 20.04
Codename: focal
I hope you liked this quick little tutorial helpful in upgrading to Ubuntu 20.04 LTS server.
Have questions? Please feel free to ask.