Tutorial: Upgrading to Ubuntu 18.04 from Ubuntu 16.04
The Ubuntu’s latest Long Term Support (LTS) release, Ubuntu 18.04 - Bionic Beaver, was released on April 26, 2018. If you’re running Ubuntu 16.04 LTS - Xenial Xerus, you may want to upgrade to the latest release to test the new features. The process of upgrading from Ubuntu 16.04 to Ubuntu 18.04 is relatively straightforward and should take no more than 30 minutes if you have a good internet connection.
- You have an Ubuntu 16.04 system with access to a sudo enabled user.
You should keep the following things in mind while you do release upgrade of Ubuntu 16.04 to Ubuntu 18.04.
- Backup all critical data from the system to a remote location using a utility program like
rsync. Even better, take a complete snapshot of your system.
- Make sure the SSH connection does not drop while the upgrade process is running. You can use a small utility program called
screento prevent the session from “timing out” or disconnecting. If there is any SSH connectivity failure during the upgrade process, you can reconnect to the session using
- Don’t run the upgrade procedures in a production system. If you are keen to upgrade in a production system, first test all your software and apps against the upgrade in a staging environment.
Before you begin the release upgrade process, update all your existing packages to the latest versions.
Only $123/yr for 48GB RAM and
480GB 960GB NVMe and free backups for LIFE!
Celebrating our 9 year anniversary! Capacity is limited and some deals will sell out. Get yours before they are gone!
Issue the following command to check the current release version of your system:
$ cat /etc/lsb-release DISTRIB_ID=Ubuntu DISTRIB_RELEASE=16.04 DISTRIB_CODENAME=xenial DISTRIB_DESCRIPTION="Ubuntu 16.04.2 LTS"
Update the list of available packages and their versions with the following command:
$ sudo apt-get update
Now, install the newer versions of these packages:
$ sudo apt-get upgrade
After upgrading the packages, check the Ubuntu’s release number. You will find that your distribution of Ubuntu 16.04 is upgraded. In our case, it upgraded to
Ubuntu 16.04.4 LTS.
$ cat /etc/lsb-release DISTRIB_ID=Ubuntu DISTRIB_RELEASE=16.04 DISTRIB_CODENAME=xenial DISTRIB_DESCRIPTION="Ubuntu 16.04.4 LTS"
The primary purpose of upgrading packages to the latest release is to keep the difference between your installed packages and the new ones in Ubuntu 18.04 as small as possible. Smaller differences minimize the risk of potential errors during the process.
The official recommended upgrade procedure uses a tool called
do-release-upgrade. This tool is a part of
update-manager-core package and is installed by default.
If for some reason
update-manager-core package is missing from your system, you can always install it with the following command from the terminal.
$ sudo apt-get install update-manager-core
Now, you should edit the configuration file for
do-release-upgrade. Make sure to set the
Prompt parameter to
$ sudo vi /etc/update-manager/release-upgrades .... .... Prompt=lts .... ....
You can now issue the following command from the terminal to begin the upgrade procedure:
$ sudo do-release-upgrade Checking for a new Ubuntu release No new release found.
Well, that seems wrong, doesn’t it? Well, upgrades to Ubuntu 18.04 from 16.04 will only be enabled a few days after the 18.04.1 release expected in late July. Same goes for 17.10 upgrades. For more information about these upgrade rollouts, check out the Ubuntu wiki.
We do have a workaround, however. You can use the
-d option to upgrade to a development release.
$ sudo do-release-upgrade -d Checking for a new Ubuntu release Get:1 Upgrade tool signature [819 B] Get:2 Upgrade tool [1,257 kB] Fetched 1,258 kB in 0s (0 B/s) authenticate 'bionic.tar.gz' against 'bionic.tar.gz.gpg' extracting 'bionic.tar.gz' 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
Since you’re using an SSH connection to start the upgrade process, the system asks whether you want to upgrade through SSH this connection. Press
y to continue.
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' Reading package lists... Done Building dependency tree Reading state information... Done ........ ........ Fetched 0 B in 0s (0 B/s) Reading package lists... Done Building dependency tree Reading state information... Done 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
The update manager informs you that a new SSH process is now running on port number 1022. You can add this port number to your firewall rules, if you have them, to allow this SSH connection as a precautionary measure. If for some reason the SSH connection drops and cannot let you connect again via port 22, you can connect to this new SSH instance using port 1022.
y to continue:
.............. .............. Checking package manager Reading package lists... Done Building dependency tree Reading state information... Done Calculating the changes Calculating the changes Do you want to start the upgrade? 3 installed packages are no longer supported by Canonical. You can still get support from the community. 88 new packages are going to be installed. 333 packages are going to be upgraded. You have to download a total of 230 M. This download will take about 56 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
Once again, press
y to continue. The update manager now starts downloading new packages for the upgrade and will inform you about the time remaining. New packages are be downloaded, unpacked, and installed one by one in your system. During the procedure, you will be asked to choose your keyboard- configuration, and if you want to restart services automatically when required.
Generally speaking, it is safe to restart these services. You may also be prompted to replace the configuration files for a service you may have configured earlier.
Searching for obsolete software Reading package lists... Done Building dependency tree... 50% Building dependency tree Reading state information... Done Reading state information... Done Remove obsolete packages? 36 packages are going to be removed. Continue [yN] Details [d]y System upgrade is complete.
Next, the update manager asks you to remove obsolete packages. It is safe to answer
y in a system where you have not modified the packages extensively. In a system where you have modified the packages heavily, you probably want to check in details (the
At this stage, the upgrade is finished.
Restart required To finish the upgrade, a restart is required. If you select 'y' the system will be restarted. Continue [yN]y
y to do a restart of your system.
If everything goes well, the system will be restarted. Login to the upgraded system, you will be greeted by a welcome prompt:
Welcome to Ubuntu 18.04 LTS
You can also check the release version in the terminal, as you did at the beginning of this tutorial:
$ cat /etc/lsb-release DISTRIB_ID=Ubuntu DISTRIB_RELEASE=18.04 DISTRIB_CODENAME=bionic DISTRIB_DESCRIPTION="Ubuntu 18.04 LTS"
Now that your system is upgraded to latest release which is Ubuntu 18-04 Bionic Beaver, you can test the new versions of your software and services against the previous ones. Make sure everything works as expected, and have fun on the new Ubuntu LTS!