How to upgrade Ubuntu 22.04 to 24.04 LTS safely

Upgrade an Ubuntu 22.04 server to 24.04 LTS in place with do-release-upgrade, with a snapshot first, a backup SSH port, and checks for what changes.

Tested on Ubuntu 22.04 LTS, Ubuntu 24.04 LTS

Before you start

  • A server running Ubuntu 22.04 LTS
  • Root or a user with sudo
  • A recent backup or snapshot
  • About 3 GB of free disk space

To upgrade Ubuntu 22.04 to 24.04, take a snapshot, run sudo apt update && sudo apt full-upgrade and reboot, then run sudo do-release-upgrade and answer its questions. Canonical's upgrader switches the package sources, installs 24.04's packages, removes obsolete ones, and asks you to reboot at the end.

Ubuntu 22.04's standard security updates end in April 2027, so plan the move before then. We ran this upgrade in a 22.04 container with nginx, OpenSSH and cron installed, using the upgrader's non-interactive mode; it ended on Ubuntu 24.04.5 LTS with nginx and cron running and SSH moved to socket activation (more on that below). A container has no kernel or bootloader of its own, so the reboot wasn't part of our test.

Before you start

  1. Take a snapshot or backup. There's no downgrade. A snapshot taken just before the upgrade is the quickest way back.
  2. Free disk space. The upgrader checks and stops if there isn't enough; df -h / should show a few GB free. Free some up if needed.
  3. Check your third-party software. The upgrader turns off third-party repositories (PPAs, Docker, PostgreSQL, Node.js). Check each supports 24.04 ("noble") before you start, and re-enable them afterwards.
  4. Keep a second way in. If SSH breaks, the serial console is how you get back in. Make sure you know your root or user password for it.

Bring 22.04 fully up to date

bash
sudo apt update
sudo apt full-upgrade
sudo apt autoremove --purge
sudo reboot

do-release-upgrade refuses to start while updates are pending, so this step isn't optional. Rebooting loads the newest 22.04 kernel and clears any "restart required" state.

Check it worked

bash
grep PRETTY_NAME /etc/os-release
sudo do-release-upgrade -c

The first shows Ubuntu 22.04.5 LTS; the second says New release '24.04.x LTS' available. If it says no release is available, check that /etc/update-manager/release-upgrades has Prompt=lts.

Run the upgrade

Run it from an SSH session (it uses screen on its own, so a dropped connection doesn't kill it):

bash
sudo do-release-upgrade

What happens, in order:

  1. SSH warning. Over SSH, it offers to start a second SSH server on port 1022 in case the main one breaks during the upgrade. Say yes. If a firewall (ufw or the panel's) blocks 1022, you can open it temporarily, or rely on the serial console.
  2. Third-party sources. It tells you it is disabling them.
  3. A summary of how many packages will be installed, upgraded and removed, and the download size. Answer y.
  4. Configuration file questions for files you changed, such as Configuration file '/etc/nginx/nginx.conf' ... What would you like to do about it? Keeping your version (N) is the safe default; D shows the difference first. Settings kept in drop-in directories (/etc/ssh/sshd_config.d/, /etc/nginx/conf.d/) don't trigger questions.
  5. Services to restart. Accept the defaults.
  6. Obsolete packages. Answer y to remove them, unless you recognise one you need.
  7. Restart required. Answer y.

How long it takes depends on how much is installed and the download speed.

If you are disconnected, log back in and reattach to the upgrader's session with sudo screen -x, or connect on port 1022 (ssh -p 1022 ...).

Check the upgrade worked

After the reboot, log back in:

bash
grep PRETTY_NAME /etc/os-release
uname -r
systemctl --failed

You should see Ubuntu 24.04.x LTS, a 6.8 or newer kernel, and no failed units. Then test each of your own services.

What changed that you'll notice

SSH is socket-activated. On 24.04, ssh.socket listens on port 22 and starts ssh.service when the first connection comes in. systemctl status ssh can show inactive while SSH works perfectly; systemctl status ssh.socket is the one to check. If you change the SSH port, it's set in the socket, not only in sshd_config, so follow Ubuntu's documentation for that.

apt sources moved. Ubuntu's sources are now in /etc/apt/sources.list.d/ubuntu.sources (the newer format), and /etc/apt/sources.list only holds a comment saying so.

Newer everything. PHP 8.3 instead of 8.1, Python 3.12 instead of 3.10, PostgreSQL 16 instead of 14, OpenSSL 3.0 stays. Applications pinned to the old versions need attention; PostgreSQL clusters in particular stay on the old version until you upgrade them with pg_upgradecluster.

Re-enable third-party repositories

The upgrader disabled them by commenting them out or renaming the files. Look in /etc/apt/sources.list.d/, change jammy to noble in each one whose vendor supports 24.04, and update:

bash
ls /etc/apt/sources.list.d/
sudo apt update
sudo apt full-upgrade

For Docker, PostgreSQL's PGDG or NodeSource, reinstalling the vendor's repository with their 24.04 instructions is often simplest.

Troubleshooting

Please install all available updates for your release before upgrading. Run sudo apt update && sudo apt full-upgrade, reboot, and try again.

No new release found. Check Prompt=lts in /etc/update-manager/release-upgrades. Canonical can also hold back upgrades for a while after a problem; sudo do-release-upgrade -c shows what it currently offers.

The upgrade stopped half-way with an error. Run sudo dpkg --configure -a, then sudo apt full-upgrade to finish. The details are in /var/log/dist-upgrade/main.log and apt-term.log.

SSH doesn't answer after the reboot. Use the serial console and check systemctl status ssh.socket and journalctl -u ssh -b. A custom port set only in sshd_config is a common cause, because of socket activation.

Next steps

Doing it on VPSNine

Take a snapshot in the panel right before you start; reverting to it undoes the whole upgrade. If the server doesn't come back, the panel's serial console shows where the boot stopped. Building a fresh server on Ubuntu 24.04 or 26.04 and moving your data across is the alternative, and often less work for a server you've changed a lot; Ubuntu 22.04 stays available for software that needs it. See plans.

Be first when orders open

Join the waitlist and we'll send you one email when VPSNine launches. Pick a plan if you already know which one you want, and we'll size the first servers around it.

  • One email, on launch day
  • Monthly or yearly, no lock-in
  • 14-day money-back guarantee