How to upgrade Ubuntu Server from 20.04 to 22.04

How to upgrade Ubuntu Server from 20.04 to 22.04

The official release of Ubuntu 22.04 is almost upon us. Jack Wallen walks you through the process of upgrading version 20.04 to the new LTS, so you’re primed and ready for the big day.

Linux written in silver on a wooden background
Image: XtravaganT/Adobe Stock

Ubuntu 22.04 is almost upon us. At the moment, the beta version of the platform has been made available, which means the official release is drawing near. With a date of April 21, 2022, it’s just a matter of days before you can get your hands on the latest version.

SEE: 40+ open source and Linux terms you need to know (TechRepublic Premium)

But for those who want to get an early start, you can always run an upgrade. I realize that many hesitate to upgrade a server from one major release to another but Ubuntu has always been rock solid with upgrades. However, if you’re hesitant to run such upgrades on production machines, you can always run them in test environments to see how they go. And, of course, you should always backup your data before doing so.

For those who are interested in upgrading Ubuntu Server (or desktop) from 20.04 LTS to 22.04 LTS, I’m going to walk you through the process.

Once again I will warn you that this should not be done on a production machine until:

  • The full release is made available.
  • You’ve backed-up all of your data.
  • You’ve tested the process on a non-production machine.

With that public service announcement out of the way, let’s upgrade.

What you’ll need

To successfully pull off an upgrade, you’ll need a running instance of Ubuntu 20.04 and a user with sudo privileges.

How to upgrade to Ubuntu 22.04

The first thing you need to do is run a standard update and upgrade to make sure all of the software installed on the machine is at the latest version. Log into your Ubuntu Server instance and issue the following two commands:

sudo apt-get update

sudo apt-get upgrade -y

When that completes, run the dist-upgrade command like so:

sudo apt-get dist-upgrade -y

Next, remove any packages that are no longer required with:

sudo apt-get autoremove -y

This is a good opportunity to remind you to back up your data and make sure you’re running this on a non-production machine.

We now need to install the update-manager-core package that allows us to upgrade from one release to another. To install this package, issue the command:

sudo apt install update-manager-core

Now, we can run the actual upgrade. Since Ubuntu 22.04 is still in beta, there is no official release available, so we have to force the upgrade. After April 21, 2022 (the planned date for the official release), you won’t have to use the -d flag. While 22.04 is still in beta, the upgrade command is:

sudo do-release-upgrade -d

Since we’re logged in via SSH, you’ll receive a couple of warnings, the first of which asks you if you’d like to continue (Figure A).

Figure A

Since we're running over SSH, we have to instruct the upgrade process to continue.
Since we’re running over SSH, we have to instruct the upgrade process to continue.

Type y and you will then be informed that SSH has been restarted on port 1022 (should anything go wrong). Hit Enter on your keyboard to continue. Eventually, you’ll be presented with an information window (Figure B), informing you what is going to change during the upgrade process.

Figure B

Eighteen packages will be removed, 106 new packages will be installed and 591 packages will be upgraded in my example.
Eighteen packages will be removed, 106 new packages will be installed and 591 packages will be upgraded in my example.

Type y to continue. At this point, the upgrade will proceed. Soon after the process begins, you’ll be asked if you’d like certain services to be restarted during the upgrade (Figure C).

Figure C

Restarting processes during the upgrade is necessary.
Restarting processes during the upgrade is necessary.

Use Tab to select Yes and hit Enter on your keyboard.

Depending on the software you have installed on your system, you might be asked other questions (such as for Postfix hostnames). Hang out for a bit, in case the upgrade requires your input. But once you start seeing packages upgrading, it’s nothing but a waiting game. At this point, either sit back and watch the output fly by in the terminal window, or go take care of one of your other admin tasks, ’cause this will take a while. Give the upgrade anywhere from 15-60 minutes (depending on the speed of your network connection and hardware).

When the upgrade completes, you’ll be prompted to reboot the machine. When asked, type y to reboot.

Once the machine reboots, log in and issue the command:

cat /etc/lsb-release

You should see the following lines:

DISTRIB_RELEASE=22.04

DISTRIB_CODENAME=jammy

DISTRIB_DESCRIPTION=”Ubuntu Jammy Jellyfish (development branch)”

Congratulations, you’ve just upgraded Ubuntu from 20.04 to 22.04. It’s time to kick the tires of the new release to see how well it fares. If all goes well, you shouldn’t have any problem upgrading your production machines (when the official release is made available). Just remember to back up your data and make sure you’ve thoroughly tested this process on a non-production server that perfectly mimics those in production.

Subscribe to TechRepublic’s How To Make Tech Work on YouTube for all the latest tech advice for business pros from Jack Wallen.

Source of Article