The Ubuntu operating system’s latest Long Term Support (LTS) release, Ubuntu 18.04 (Bionic Beaver), was released on April 26, 2018. This guide will explain how to upgrade an Ubuntu system of version 16.04 or later to Ubuntu 18.04.
Warning: As with almost any upgrade between major releases of an operating system, this process carries an inherent risk of failure, data loss, or broken software configuration. Comprehensive backups and extensive testing are strongly advised.
To avoid these problems, we recommend migrating to a fresh Ubuntu 18.04 server rather than upgrading in-place. You may still need to review differences in software configuration when upgrading, but the core system will likely have greater stability. You can follow our series on how to migrate to a new Linux server to learn how to migrate between servers.
This guide assumes that you have an Ubuntu 16.04 or later system configured with a sudo-enabled non-root user.
Although many systems can be upgraded in place without incident, it is often safer and more predictable to migrate to a major new release by installing the distribution from scratch, configuring services with careful testing along the way, and migrating application or user data as a separate step.
You should never upgrade a production system without first testing all of your deployed software and services against the upgrade in a staging environment. Keep in mind that libraries, languages, and system services may have changed substantially. Before upgrading, consider reading the Bionic Beaver Release Notes and our article What’s New in Ubuntu 18.04.
Before attempting a major upgrade on any system, you should make sure you won’t lose data if the upgrade goes awry. The best way to accomplish this is to make a backup of your entire filesystem. Failing that, ensure that you have copies of user home directories, any custom configuration files, and data stored by services such as relational databases.
On a DigitalOcean Droplet, one approach is to power down the system and take a snapshot (powering down ensures that the filesystem will be more consistent). See How To Use DigitalOcean Snapshots to Automatically Backup your Droplets for more details on the snapshot process. After you have verified that the Ubuntu update was successful, you can delete the snapshot so that you will no longer be charged for its storage.
For backup methods which will work on most Ubuntu systems, see How To Choose an Effective Backup Strategy for your VPS.
Before beginning the release upgrade, it’s safest to update to the latest versions of all packages for the current release. Begin by updating the package list:
- sudo apt-get update
Next, upgrade installed packages to their latest available versions:
- sudo apt-get upgrade
You will be shown a list of upgrades, and prompted to continue. Answer y for yes and press Enter.
This process may take some time. Once it finishes, use the dist-upgrade
command with apt-get
, which will perform any additional upgrades that involve changing dependencies, adding or removing new packages as necessary. This will handle a set of upgrades which may have been held back by apt-get upgrade
:
- sudo apt-get dist-upgrade
Again, answer y when prompted to continue, and wait for upgrades to finish.
Now that you have an up-to-date installation of Ubuntu, you can use do-release-upgrade
to upgrade to the 18.04 release.
Traditionally, Ubuntu releases have been upgradeable by changing Apt’s /etc/apt/sources.list
– which specifies package repositories – and using apt-get dist-upgrade
to perform the upgrade itself. Though this process is still likely to work, Ubuntu provides a tool called do-release-upgrade
to make the upgrade safer and easier.
do-release-upgrade
handles checking for a new release, updating sources.list
, and a range of other tasks, and is the officially recommended upgrade path for server upgrades which must be performed over a remote connection.
Start by running do-release-upgrade
with no options:
- sudo do-release-upgrade
If the new Ubuntu version has not been officially released yet, you may get the following output:
OutputChecking for a new Ubuntu release
No new release found
If this is the case, add the -d
option to upgrade to the development release:
- sudo do-release-upgrade -d
If you’re connected to your system over SSH, you’ll be asked whether you wish to continue. For virtual machines or managed servers you should keep in mind that losing SSH connectivity is a risk, particularly if you don’t have another means of remotely connecting to the system’s console. For other systems under your control, remember that it’s safest to perform major operating system upgrades only when you have direct physical access to the machine.
At the prompt, type y and press Enter to continue:
OutputReading 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
Next, you’ll be informed that do-release-upgrade
is starting a new instance of sshd
on port 1022:
OutputStarting 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]
Press Enter
. Next, you may be warned that a mirror entry was not found. On DigitalOcean systems, it is safe to ignore this warning and proceed with the upgrade, since a local mirror for 18.04 is in fact available. Enter y:
OutputUpdating 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
Once the new package lists have been downloaded and changes calculated, you’ll be asked if you want to start the upgrade. Again, enter y
to continue:
OutputDo 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
New packages will now be retrieved, unpacked, and installed. Even if your system is on a fast connection, this will take a while.
During the installation, you may be presented with interactive dialogs for various questions. For example, you may be asked if you want to automatically restart services when required:
In this case, it is safe to answer Yes. In other cases, you may be asked if you wish to replace a configuration file that you have modified. This is often a judgment call, and is likely to require knowledge about specific software that is outside the scope of this tutorial.
Once new packages have finished installing, you’ll be asked whether you’re ready to remove obsolete packages. On a stock system with no custom configuration, it should be safe to enter y here. On a system you have modified heavily, you may wish to enter d and inspect the list of packages to be removed, in case it includes anything you’ll need to reinstall later.
OutputRemove obsolete packages?
53 packages are going to be removed.
Continue [yN] Details [d]y
Finally, assuming all has gone well, you’ll be informed that the upgrade is complete and a restart is required. Enter y to continue:
OutputSystem 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
On an SSH session, you’ll likely see something like the following:
OutputConnection to 203.0.113.241 closed by remote host.
Connection to 203.0.113.241 closed.
You may need to press a key here to exit to your local prompt, since your SSH session will have terminated on the server end.
Wait a moment for your server to reboot, then reconnect. On login, you should be greeted by a message confirming that you’re now on Bionic Beaver:
OutputWelcome to Ubuntu 18.04 LTS (GNU/Linux 4.15.0-19-generic x86_64)
You should now have a working Ubuntu 18.04 installation. From here, you likely need to investigate necessary configuration changes to services and deployed applications.
You can find more 18.04 tutorials on our Ubuntu 18.04 Tutorials tag page.
Thanks for learning with the DigitalOcean Community. Check out our offerings for compute, storage, networking, and managed databases.
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Sign up for Infrastructure as a Newsletter.
Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
It aborts every time. Where is the log? How is this diagnosed?
Checking for a new Ubuntu release Get:1 Upgrade tool signature [819 B] Get:2 Upgrade tool [1,258 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 Reading package lists… Done Building dependency tree Reading state information… Done Hit http://archive.ubuntu.com/ubuntu xenial InRelease Get:1 http://security.ubuntu.com/ubuntu xenial-security InRelease [107 kB] Hit http://ppa.launchpad.net/certbot/certbot/ubuntu xenial InRelease Hit https://deb.nodesource.com/node_8.x xenial InRelease Hit http://ppa.launchpad.net/nginx/stable/ubuntu xenial InRelease Hit http://apt.postgresql.org/pub/repos/apt xenial-pgdg InRelease Fetched 107 kB in 0s (0 B/s) Reading package lists… Done Building dependency tree Reading state information… Done
Restoring original system state
Aborting Reading package lists… Done Building dependency tree Reading state information… Done
I updated a fairly bone stock 16.04 Wordpress droplet and php was disabled upon upgrade to 18.04.1 completion, rendering wordpress nonfunctional. For anyone who has run into this issue, the fix was
sudo a2enmod php7.2 sudo systemctl restart apache2
FYI for anyone trying this and getting the above “Invalid package information” error:
The problem is that the Digital Ocean mirror of 16.04 is missing
ubuntu-minimal
, probably because 16.04 is so old and has been archived by Ubuntu.The solution is to point apt at
us.archive.ubuntu.com
instead which has all the archived packages.You can do this with:
Then run
do-release-upgrade
like normal.When you’re finished with the upgrade you can switch back to the DO mirrors with:
not doing it from 18.04 to 18.10 :/ complains missing ubuntu-minimal
A warning to Ubuntu 16.04 LTS users: you can’t upgrade to 18.04 LTS through this guide because they already warned that it will not be available through ‘do-release-upgrade’ until 18.04.1 (screenshot).
I’m getting this error:
Failed to lock /var/cache/apt/archives/lock
PermissionError: [Errno 1] Operation not permitted: ‘/etc/apt/sources.list’
Original exception was: Traceback (most recent call last): File “/tmp/ubuntu-release-upgrader-o1qm2vbn/bionic”, line 8, in <module> File “/tmp/ubuntu-release-upgrader-o1qm2vbn/DistUpgrade/DistUpgradeMain.py”, line 238, in main File “/tmp/ubuntu-release-upgrader-o1qm2vbn/DistUpgrade/DistUpgradeController.py”, line 1949, in run File “/tmp/ubuntu-release-upgrader-o1qm2vbn/DistUpgrade/DistUpgradeController.py”, line 1913, in fullUpgrade File “/tmp/ubuntu-release-upgrader-o1qm2vbn/DistUpgrade/DistUpgradeController.py”, line 1330, in doDistUpgrade File “/tmp/ubuntu-release-upgrader-o1qm2vbn/DistUpgrade/DistUpgradeController.py”, line 1452, in abort File “/tmp/ubuntu-release-upgrader-o1qm2vbn/DistUpgrade/sourceslist.py”, line 366, in restore_backup File “/usr/lib/python3.5/shutil.py”, line 236, in copy copymode(src, dst, follow_symlinks=follow_symlinks) File “/usr/lib/python3.5/shutil.py”, line 138, in copymode chmod_func(dst, stat.S_IMODE(st.st_mode)) PermissionError: [Errno 1] Operation not permitted: ‘/etc/apt/sources.list’
Any thoughts on this one?
Upgraded from 16.04 to 18.04. Seemed to work overall, but now when I try to start nginx it fails:
Checking journalctl:```
gmaddock@Wrecked:/etc/apt/sources.list.d$ journalctl -xe Hint: You are currently not seeing messages from other users and the system. Users in groups ‘adm’, ‘systemd-journal’ can see all messages. Pass -q to turn off this notice. Jan 22 04:59:08 Wrecked systemd[2181]: snap.kubectl.kubectl.ec252aa9-1c98-4827-bc15-3fb1c7db158d.scope: Failed to add PIDs to scope’s control group: Permission denied Jan 22 04:59:08 Wrecked systemd[2181]: snap.kubectl.kubectl.ec252aa9-1c98-4827-bc15-3fb1c7db158d.scope: Failed with result ‘resources’. Jan 22 04:59:08 Wrecked systemd[2181]: Failed to start snap.kubectl.kubectl.ec252aa9-1c98-4827-bc15-3fb1c7db158d.scope. – Subject: Unit UNIT has failed – Defined-By: systemd – Support: http://www.ubuntu.com/support
– Unit UNIT has failed.
– The result is RESULT. Jan 22 04:59:19 Wrecked systemd[2181]: snap.kubectl.kubectl.61e51116-9f4d-4c6f-86e9-b3967e5248d7.scope: Failed to add PIDs to scope’s control group: Permission denied Jan 22 04:59:19 Wrecked systemd[2181]: snap.kubectl.kubectl.61e51116-9f4d-4c6f-86e9-b3967e5248d7.scope: Failed with result ‘resources’. Jan 22 04:59:19 Wrecked systemd[2181]: Failed to start snap.kubectl.kubectl.61e51116-9f4d-4c6f-86e9-b3967e5248d7.scope. – Subject: Unit UNIT has failed – Defined-By: systemd – Support: http://www.ubuntu.com/support
– Unit UNIT has failed.
– The result is RESULT. Jan 22 05:06:23 Wrecked sudo[3144]: pam_unix(sudo:auth): authentication failure; logname= uid=1000 euid=0 tty=/dev/pts/0 ruser=gmaddock rhost= user=gmaddock Jan 22 05:06:50 Wrecked systemd[2181]: Started snap.kubectl.kubectl.b4b3876e-4d44-483c-a47e-d35c1390b90c.scope. – Subject: Unit UNIT has finished start-up – Defined-By: systemd – Support: http://www.ubuntu.com/support
– Unit UNIT has finished starting up.
– The start-up result is RESULT.
I am trying to upgrade but keep getting the following error message. I can’t make head or tail of whats wrong and how to fix it.
do-release-upgrade aborts, seems to be a problem with jessie-backports and failing to get some release file. Anyone else have this problem, how do you resolve?
Just a heads up if you are getting an error about missing repos then you will need to allow 3rd party repos