How To Upgrade From Ubuntu 16.04 To Ubuntu 18.04

The recent Ubuntu version 18.04 (Bionic Beaver) comes with exciting features that make it easy to use. If you’re using Ubuntu 16.04 or 17.04, this guide will take you step-by-step through the process of upgrading to Ubuntu 18.04.

Prerequisites

An existing Ubuntu 16.04 LTS or later system configured with a non-root user with sudo privileges.

Thing To Consider Before the Upgrade

Before you upgrade to a new system, it is considered safe to switch to a new major release by installing the software from scratch and configuring the services carefully as you test the steps along the way.

Never upgrade to a new system without testing all the software options. This is because things like languages, libraries, and system services may have changed. Also, ensure you read the Bionic Beaver Release notes.

Step 1: System Backup

Before you do a significant upgrade on your system, it is essential to ensure your data won’t be lost in case the backup goes wrong. The best way to do this is to back up the entire file system online or on an external hard drive.

Step 2: Updating Current Packages

The next step before we begin the upgrade is updating the latest versions of all packages. To do so, open Ubuntu Dashboard and look for the Software & Updates tab.

Navigate to the Updates tab and set the section Notify me of a new Ubuntu version to For long-term support versions or LTS. This will reload the Software repository cache.

Once the right software source setting is selected, open a new terminal and run the command below to update the system.

$ sudo apt-get update

Then, go ahead and upgrade the installed packages to the latest versions available.

$ sudo apt-get upgrade

You will be presented with a list of all the available upgrades. Answer yes and click Enter.

This process may take a couple of minutes. Once it’s done, you will need to perform any available upgrades that require you to change dependencies, or either add or remove new packages. To do so, run the command below:

$ sudo apt-get dist-upgrade

Next, answer y for yes when asked to continue, then wait for the upgrade process to finish.

Having updated the current Ubuntu packages, you can go ahead and upgrade to 18,04 release using do-release-upgrade.

Step 3: Upgrading Ubuntu with do-release-upgrade Tool

Initially, Ubuntu upgrades have always been done by changing apt description; /etc/apt/sources.list, and replacing it with apt-get dist upgrade> to complete the upgrade itself. This process may still work, but to make the process easier and safer, Ubuntu offers a tool known as do-release-upgrade.

This tool helps check for new releases, update sources.list, and perform other tasks. It’s the recommended upgrade path for any upgrades on the server done on a remote connection.

To begin the upgrade process, run do-release-upgrade command with no options:

$ sudo do-release-upgrade

If there is no new Ubuntu version released, you will see the output below:

Checking for a new Ubuntu release
No new release found

If you run into this information, add the -d option to upgrade the system to the development release:

$ sudo do-release-upgrade -d

If your system connection is under SSH, you will need to confirm whether you want to continue. If you’re using virtual machines or managed servers, it is important to maintain SSH connectivity as losing it may pose a risk to your system.

Then proceed to enter y then click Enter to continue

You should have the output below:

Output
Reading cache

Checking package manager

Continue running under SSH?

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.

If you continue, an additional ssh daemon will be started at port
'1022'.
Do you want to continue?

Continue [yN] y

At this point, do-release-upgrade tool will inform you of a new instance of sshd executed on port 1022:

Output
Starting additional sshd

To make recovery in case of failure easier, an additional sshd will
be started on port '1022'. If anything goes wrong with the running
ssh you can still connect to the additional one.
If you run a firewall, you may need to temporarily open this port. As
this is potentially dangerous it's not done automatically. You can
open the port with e.g.:
'iptables -I INPUT -p tcp --dport 1022 -j ACCEPT'

To continue please press [ENTER]

Go ahead and press Enter. You may receive a message with a warning that no mirror entry was found. You can ignore this warning and continue with the upgrade since a local mirror for Ubuntu 18.04 is actually available. Type y:

Output
Updating repository information

No valid mirror found

While scanning your repository information no mirror entry for the
upgrade was found. This can happen if you run an internal mirror or
if the mirror information is out of date.

Do you want to rewrite your 'sources.list' file anyway? If you choose
'Yes' here it will update all 'xenial' to 'bionic' entries.
If you select 'No' the upgrade will cancel.

Continue [yN] y

Now, a new package will be downloaded and all the changes made. You will be prompted to start the upgrade process. Press y to continue:

Utput

Do you want to start the upgrade?


6 installed packages are no longer supported by Canonical. You can
still get support from the community.

9 packages are going to be removed. 104 new packages are going to be
installed. 399 packages are going to be upgraded.

You have to download a total of 232 M. This download will take about
46 seconds with your connection.

Installing the upgrade can take several hours. Once the download has
finished, the process cannot be canceled.

 Continue [yN]  Details [d]y

Now, all the packages for the new version will be installed. This may take a while.

Once installing the new packages, you will be prompted to remove any unnecessary packages. On a system that doesn’t require much custom configuration, it’s safe to enter y here.

On the other hand, if it’s a system with a lot of modification, you may need to enter d and check all the packages that need to be removed.

The output should be as follows:

Output
Remove obsolete packages?

53 packages are going to be removed.

 Continue [yN]  Details [d]y

If everything went well, you will get a message that the upgrade is finished and you can restart your system. Enter y to proceed.

Output
System upgrade is complete.

Restart required

To finish the upgrade, a restart is required.
If you select 'y' the system will be restarted.

Continue [yN] y
For SSH, you are likely to see the following output:
Output
Connection to 203.0.113.241 closed by remote host.
Connection to 203.0.113.241 closed.

Press any key to exit local prompt.

Wait for a while for the system to reboot, then reconnect. Once you login back in, you will see a message to confirm that you’re on Ubuntu 18.04.

Welcome to Ubuntu 18.04 LTS (GNU/Linux 4.15.0-19-generic x86_64)

Now, your upgrade is complete and successful

Conclusion

That’s it. Now you should find it easier to upgrade to Ubuntu 18.04 from Ubuntu 16.04. From here, you can check the necessary configuration changes to your system and applications.

 

Check out these top 3 Linux hosting services

Was this article helpful?