Ubuntu supports the ability to upgrade from one LTS to the next LTS in sequential order. For example, a user on Ubuntu 16.04 LTS can upgrade to Ubuntu 18.04 LTS, but cannot jump directly to Ubuntu 20.04 LTS. To do this, the user would need to upgrade twice: once to Ubuntu 18.04 LTS, and then upgrade again to Ubuntu 20.04 LTS.
How to Upgrade Ubuntu 16.04 to Ubuntu 18.04
- Step 1: Create a backup of your environment
- Step 2: Upgrade the installed packages of Ubuntu version 16.04.
Step 4: Upgrade Ubuntu
Step 1: Create a backup of your environment
- Most upgrades will go smoothly, but you want to be prepared just in case. When you upgrade LTS versions, you are rolling two years of gradual changes into one major update. There are many moving pieces, and a backup can easily fix anything that goes wrong. Do not skip this step, create a backup.
Step 2: Upgrade the installed packages of Ubuntu version 16.04
- Updating the packages to the latest version for 16.04 decreases the chance of something going wrong during the upgrade to version 18.04. Run the command below to update and upgrade the packages.
sudo apt-get update && sudo apt-get upgrade
Ubuntu will grab the available package upgrades and ask you to confirm you want to continue.
Hit:1 http://us.archive.ubuntu.com/ubuntu xenial InRelease
Get:2 http://us.archive.ubuntu.com/ubuntu xenial-updates InRelease [109 kB]
Get:3 http://us.archive.ubuntu.com/ubuntu xenial-backports InRelease [107 kB]
Get:4 http://security.ubuntu.com/ubuntu xenial-security InRelease [107 kB]
Fetched 323 kB in 0s (470 kB/s)
Reading package lists... Done
Reading package lists... Done
Building dependency tree
Reading state information... Done
Calculating upgrade... Done
The following packages were automatically installed and are no longer required:
linux-headers-4.4.0-138 linux-headers-4.4.0-138-generic linux-headers-4.4.0-21 linux-headers-4.4.0-21-generic linux-image-4.4.0-138-generic linux-image-4.4.0-21-genericUse 'sudo apt autoremove' to remove them.
The following packages will be upgraded:ca-certificates python3-software-properties software-properties-common update-notifier-common
4 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Need to get 359 kB of archives.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n]Type Y in your terminal to continue
Step 3: Install the Ubuntu Update Manage
- To no one's surprise, you need to have the Update Manager installed on your server to use it. To add the Update Manager to your server add command below to your terminal.
sudo apt install update-manager-core
sudo apt install update-manager-core
If you are using a Liquid Web VPS, you can skip this step. The Upgrade manager is installed by default.
Step 4: Upgrade Ubuntu
Now that you have created a backup installed package updates and have the upgrade manager you are ready to upgrade Ubuntu.
sudo do-release-upgrade
After you enter the upgrade command, you will be asked to confirm that you want to update via SSH. Type Y to continue.
To make an easy recovery in case of failure, 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]
After hitting Enter, Ubuntu will get all the packages needed to update and will inform you how many packages will be added and removed and the size of the update.
Do you want to start the upgrade?
3 installed packages are no longer supported by Canonical. You can
still get support from the community.
3 packages are going to be removed. 121 new packages are going to be
installed. 349 packages are going to be upgraded.
You have to download a total of 263 M. This download will take about
33 minutes with a 1Mbit DSL connection and about 10 hours with a 56k
modem.
Fetching and installing the upgrade can take several hours. Once the
download has finished, the process cannot be canceled.
You will need to type YN to continue upgrading.
The installation will take some time to complete. You may see some prompts during the upgrade that will require your interaction so plan on staying near your terminal.
The installation will take some time to complete. You may see some prompts during the upgrade that will require your interaction so plan on staying near your terminal.
You may see a prompt like the one above. The prompt is informing us that a new version of a file is available, but the version currently installed on the server has been locally modified. You will have to choose whether you want to install the new version of the file and overwrite the changes, keep the currently installed version, or merge the files. There isn't a correct choice, and you just need to choose which option is the best for you.
Searching for obsolete software
Reading state information... Done
Remove obsolete packages?
38 packages are going to be removed.
Continue [yN] Details [d]
Type YN into your terminal to remove the packages and continue upgrading.
After the upgrade is complete, a restart will be required.
You will be logged out during the restart, and you will need to log back in to confirm the upgrade was successful. To check what version of Ubuntu is currently installed use the command below.
lsb_release -a
Use the lsb_release -a command to check what version of Ubuntu is currently installed.
We did it, our upgrade to Ubuntu 18.04 was successful.