Securing VPS/Servers Upgrading
Upgrade Ubuntu Server to 24.04 LTS (and On to 26.04) with do-release-upgrade
Upgrade an Ubuntu server from 22.04 to 24.04 LTS, or from 24.04 to 26.04 LTS, with do-release-upgrade, including preparation, SSH precautions and checks afterwards.
This guide upgrades a running Ubuntu server in place to the next long-term support (LTS) release with do-release-upgrade, the tool Ubuntu recommends for servers and cloud images. It applies to going from Ubuntu 22.04 LTS to 24.04 LTS, and from 24.04 LTS to 26.04 LTS, which has been offered to 24.04 systems since the 26.04.1 point release.
If you arrived looking for the upgrade to Ubuntu 18.04: that release, and 16.04 before it, are long past their standard support period. The procedure below is the same one, applied to releases that still receive updates.
Supported upgrade paths
An LTS release can only be upgraded to the next LTS release. You cannot skip one.
| Running now | do-release-upgrade takes you to |
|---|---|
| Ubuntu 20.04 LTS | 22.04 LTS |
| Ubuntu 22.04 LTS | 24.04 LTS |
| Ubuntu 24.04 LTS | 26.04 LTS |
To get from 22.04 to 26.04, run the whole procedure twice: upgrade to 24.04, reboot, confirm everything works, then upgrade again. Upgrades to a new LTS are only offered once its first point release is out, which is why a brand-new LTS does not show up immediately.
An in-place upgrade is convenient but not risk-free. If the server is easy to rebuild, creating a new server on the target release and moving your data across is the cleaner option, and it gives you a tested fallback.
Before you start
- Read the release notes of the target release for changes that affect your software.
- Back up. Take a snapshot in your hosting control panel if it offers one, and copy databases and important data off the server. There is no downgrade path; a backup is the only way back.
- Make sure you have console access. Your provider's web console works even if networking or SSH breaks during the upgrade.
- Check free disk space. The upgrade downloads several gigabytes of packages.
- Plan time. The process is interactive and asks questions; services restart and the server reboots at the end.
Check the current release, free space and any packages on hold. Held packages can block the upgrade, so release the ones you do not need to pin with sudo apt-mark unhold <package>.
lsb_release -a
df -h / /boot
apt-mark showhold
Install all pending updates
The upgrade tool refuses to start while updates are outstanding. Ubuntu's documentation recommends including phased updates, which a normal upgrade may hold back:
sudo apt update
sudo apt dist-upgrade -o APT::Get::Always-Include-Phased-Updates=true
Reboot if the system asks for it, so that you start from the newest kernel of the current release:
[ -f /run/reboot-required ] && sudo reboot
Third-party repositories and PPAs are disabled during the upgrade. List them now so you know what to re-enable later:
ls /etc/apt/sources.list.d/
Prepare the upgrade tool and your connection
Make sure the upgrader is installed and set to follow LTS releases:
sudo apt install update-manager-core
grep ^Prompt /etc/update-manager/release-upgrades
The output should be Prompt=lts. If it says never, edit the file and change it.
When you run the upgrade over SSH, the tool warns you and starts a second SSH daemon on port 1022 as a fallback in case the main one stops. If you use ufw, open that port for the duration of the upgrade; if your provider has its own firewall, allow it there as well:
sudo ufw allow 1022/tcp
Running the upgrade from the provider's web console instead avoids the dependency on SSH altogether and is the safer choice when it is practical.
Run the upgrade
First check that a new release is being offered:
sudo do-release-upgrade -c
Then start the upgrade:
sudo do-release-upgrade
The tool walks you through several stages:
- SSH warning. Confirm that you want to continue over SSH and note the fallback port.
- Summary. After its checks, the tool lists how many packages will be removed, installed and upgraded, and the download size. This is the last point at which you can cancel; once the downloads have finished, the process cannot be stopped.
- Configuration files. When you have changed a configuration file and the new package ships a different version, you are asked what to do:
YorIinstalls the maintainer's version,NorOkeeps yours,Dshows the differences andZopens a shell. Keeping your version is the default and usually right for files you edited deliberately, such assshd_config. Look at the differences first; occasionally the new version is needed. - Obsolete packages. At the end you can remove packages that the new release no longer needs.
- Restart. The system is not fully upgraded until it has rebooted. Confirm the restart.
If your SSH session drops
Do not start a second upgrade. Reconnect on the normal port, or on the fallback port if that fails:
ssh -p 1022 deploy@203.0.113.10
The upgrader runs inside a screen session owned by root, so it keeps going without you. Find and reattach to it:
sudo screen -ls
sudo screen -x
If neither port answers, use the web console.
Verify after the reboot
Log in again and check the release, the running kernel and whether any service failed to start:
lsb_release -a
uname -r
systemctl --failed
Then finish the cleanup:
sudo apt update
sudo apt full-upgrade
sudo apt autoremove --purge
sudo ufw delete allow 1022/tcp
Re-enable the third-party repositories you listed earlier. Open each file in /etc/apt/sources.list.d/, check that the vendor publishes packages for the new release, update the release codename if the entry contains one (noble for 24.04, resolute for 26.04), remove the marker that disabled the entry, and run sudo apt update again. Finally, test your own applications: web server, database, scheduled jobs and anything that depends on a language runtime, since PHP, Python and similar packages change version with the release.
Ubuntu's own instructions are in the Ubuntu Server guide, How to upgrade your release.
Frequently asked questions
do-release-upgrade says there is no new release. Why?
The usual causes are pending updates on the current release, Prompt=never in /etc/update-manager/release-upgrades, or a new LTS whose first point release is not out yet. The -d option forces an upgrade to a release that is not yet being offered, including development releases; Ubuntu's documentation says not to use it in production.
Can I undo the upgrade?
No. There is no supported downgrade. Restoring the snapshot or backup you made beforehand is the only way to return to the old release.
How long is the server unavailable?
It depends on the number of installed packages, disk speed and download speed. Services are restarted while their packages are replaced, and the server is offline during the final reboot. Schedule a maintenance window instead of relying on an estimate.
Should I stop my services before upgrading?
It is not required, but stopping databases and other write-heavy services after taking a final backup reduces the chance of an inconsistent state if something goes wrong. Use sudo systemctl stop <service>; they start again after the reboot if they are enabled.