How to Upgrade Ubuntu Server to a New Ubuntu Release.

Learn how to upgrade Ubuntu Server to a newer release with this step-by-step tutorial. Prepare your system, back up important data, check disk space, configure SSH recovery, run the upgrade, and verify that your services work afterward.

How to Upgrade Ubuntu Server to a New Ubuntu Release.
Image credit: Unknown. Please contact us if you are the owner.


Keeping Ubuntu Server up to date is essential for security, stability, and compatibility. While routine updates refresh packages within your existing release, a release upgrade moves the system to a newer Ubuntu version.

This process can introduce a newer Linux kernel, updated system libraries, security improvements, and newer software. However, it may also modify configurations, remove obsolete packages, or affect applications with specific dependencies.

In this tutorial, we'll cover the complete upgrade process, from system preparation and backup to installation and post-upgrade verification.

The procedure applies to supported Ubuntu release upgrades. Available upgrade paths and requirements depend on the current release and the target version.

Important: Before starting, verify that Ubuntu officially supports the upgrade path you intend to use. Do not assume that every release can be upgraded directly to every newer release.

Official documentation: Ubuntu Server — How to upgrade your release


1. Check your current Ubuntu version

Before making any changes, identify the Ubuntu release currently installed.

Run:

$ cat /etc/os-release

Alternatively:

$ lsb_release -a

Check the running kernel:

$ uname -r

These commands establish your system's current state and provide a baseline for comparison after the upgrade.

2. Check available disk space

A release upgrade downloads and installs many packages. Insufficient disk space can interrupt the process or leave packages partially configured.

Check filesystem usage:

$ df -h

If you have duf installed, you can use it for a more readable overview:

$ duf

Identify the largest directories:

$ sudo du -xhd1 / 2>/dev/null | sort -h

To investigate /var:

$ sudo du -xhd1 /var 2>/dev/null | sort -h

Pay particular attention to /, /boot, and /var.

If disk space is limited, identify what is consuming it before deleting anything. Avoid manually removing system directories or application data without understanding their purpose.

You can clear downloaded APT package archives:

$ sudo apt clean

Then check the available space again:

$ df -h /

Ensure sufficient free space remains for the upgrade. The required amount varies with the release, installed packages, and filesystem layout.

3. Check filesystem health

Before upgrading, investigate any existing filesystem or storage problems.

Check the root filesystem:

$ findmnt /

Review kernel errors from the current boot:

$ sudo journalctl -k -p err -b --no-pager

Pay attention to storage errors, I/O failures, and filesystem-related messages.

If the server has previously experienced filesystem corruption, resolve the underlying problem and secure a backup before proceeding.

Do not run filesystem repair operations against a mounted root filesystem. If an offline filesystem check is necessary, plan it through an appropriate recovery environment.

4. Back up important data

Always create and verify a backup before performing a major operating-system upgrade.

Although Ubuntu's upgrade process is designed to preserve existing data, failures can occur because of package conflicts, interrupted installations, hardware problems, or configuration incompatibilities.

Back up important information, including:

  • Application files and databases.
  • System configuration under /etc.
  • User data under /home.
  • Web server configuration and website content.
  • Docker Compose files, environment files, and persistent volumes, if applicable.
  • Other files needed to restore essential services.

For example, you can archive system configuration and home directories to a designated backup destination:

$ sudo tar -czpf /mnt/backup/server-configs.tar.gz /etc /home

Replace /mnt/backup with your actual backup destination.

Verify the archive and secure it, as it may contain sensitive data. Use database-native backup tools for consistent backups, and keep a separate copy of critical data in case the original system becomes inaccessible.

5. Check held packages

Some packages may be marked as held, preventing APT from automatically upgrading them.

List held packages:

$ sudo apt-mark showhold

An empty result means that no packages are currently held.

If packages are listed, investigate why they were held before changing their status.

To remove a hold when you have determined that it is safe:

$ sudo apt-mark unhold package_name

Replace package_name with the actual package name.

Do not blindly unhold every package. Some holds are intentional and may protect critical applications or dependencies.

6. Update the existing Ubuntu installation

Before upgrading the operating system, install the available updates for your current release.

Refresh the package indexes:

$ sudo apt update

Upgrade installed packages:

$ sudo apt upgrade

Then complete any remaining dependency changes:

$ sudo apt full-upgrade

Review the proposed changes before confirming them. If APT reports broken dependencies or proposes removing important software, investigate the problem first.

Remove packages that are no longer needed:

$ sudo apt autoremove --purge

Review the removal list before accepting it.

Check whether a reboot is required:

if [ -f /run/reboot-required ]; then
    cat /run/reboot-required
else
    echo "No reboot is currently flagged."
fi

If a reboot is required, restart the system:

$ sudo reboot

Reconnect afterward and confirm that the system and essential services are functioning normally.

7. Review third-party repositories and applications

Applications installed through external repositories may require additional attention after a release upgrade.

List configured APT sources:

$ grep -RhsE '^[[:space:]]*(deb |URIs:)' \
    /etc/apt/sources.list \
    /etc/apt/sources.list.d/ 2>/dev/null

Review manually installed packages:

$ apt-mark showmanual

Check whether critical applications support the destination Ubuntu release.

Examples include:

  • Docker and container runtimes.
  • Node.js and other development tools.
  • Database servers.
  • VPN software.
  • Web servers and reverse proxies.
  • Monitoring and security tools.

Ubuntu's release-upgrade process may temporarily disable third-party repositories. Software installed from these repositories may remain installed, but it might not receive updates until compatible repository configurations are available.

Record important repository configurations and verify application compatibility before continuing.

8. Install the release-upgrade utility

The do-release-upgrade command is provided by the ubuntu-release-upgrader-core package.

Ensure that the package is installed:

$ sudo apt install ubuntu-release-upgrader-core

Check the release-upgrade configuration:

$ cat /etc/update-manager/release-upgrades

The configuration may contain a setting such as:

Prompt=lts

This tells Ubuntu to check for supported LTS release upgrades. Systems following intermediate releases may require a different setting.

Choose the option that matches your upgrade policy. Do not use development-release options to bypass Ubuntu's supported stable upgrade path.

9. Prepare SSH access

If you are upgrading a remote server over SSH, prepare a recovery method before starting.

Keep your existing SSH session open throughout the upgrade. If possible, establish a second session and ensure that you have another way to access the system if SSH becomes unavailable.

When you start the upgrade, Ubuntu will display a warning similar to this:

This session appears to be running under ssh.

If you continue, an additional ssh daemon will be started
at port '1022'.

Do you want to continue?

Continue [yN]

If you choose to continue, the upgrader attempts to start a temporary SSH daemon on TCP port 1022.

This provides an alternative connection if the original SSH session becomes unusable.

However, starting the temporary daemon does not automatically guarantee that port 1022 is accessible through your firewall.

Check UFW:

$ sudo ufw status

If UFW is active, verify whether TCP port 1022 is already allowed.

If necessary, restrict access to your trusted public IP:

$ sudo ufw allow from YOUR_PUBLIC_IP to any port 1022 proto tcp

Replace YOUR_PUBLIC_IP with your actual public IP address.

If you cannot restrict access by source IP, you can temporarily allow the port more broadly:

$ sudo ufw allow 1022/tcp

Use the broader rule only when necessary. Other firewall rules or network firewalls may still block access.

If UFW is inactive, do not enable it or add rules blindly during the upgrade.

If your original SSH connection fails, the recovery connection would look like this:

ssh -p 1022 YOUR_USERNAME@YOUR_SERVER_IP

Replace the placeholders with your actual username and server address.

After the upgrade, remove any temporary firewall rule you added once normal SSH access is confirmed.

10. Start the Ubuntu release upgrade

Once the preparation steps are complete, check whether the target release is available:

$ sudo do-release-upgrade -c

If the upgrade is available, start it:

$ sudo do-release-upgrade

The upgrader checks the system, calculates the required changes, and presents a summary of the proposed upgrade.

Depending on your installation, the summary may include:

  • Packages to install.
  • Packages to upgrade.
  • Packages to remove.
  • Download and installation requirements.

Review the summary carefully before accepting it.

If the upgrader proposes removing essential software or reports unresolved dependency problems, stop and investigate before continuing.

What if the upgrade reports "No candidate ver"?

During a release upgrade, you may encounter messages similar to:

No candidate ver:
linux-image-example

These messages indicate that the upgrader could not find a candidate version for the referenced package in the package metadata it is using.

They do not necessarily mean that the entire upgrade has failed. However, you should review the complete output and determine whether the upgrader can proceed successfully.

Investigate obsolete packages, repository configuration, package availability, and any subsequent errors before deciding what to do.

Should you use the -d option?

The following command is also available:

$ sudo do-release-upgrade -d

The -d option requests an upgrade to the development release offered by Ubuntu's upgrade tooling. It is not a general-purpose way to force an ordinary stable release upgrade.

If the stable release you want is not available, consult Ubuntu's official release-upgrade documentation rather than automatically using the development option.

For a supported stable upgrade, the standard command is:

$ sudo do-release-upgrade

11. Handle configuration file prompts

During the upgrade, Ubuntu may ask whether to keep an existing configuration file or replace it with the package maintainer's version.

For example, you may be prompted about:

/etc/ssh/sshd_config

Read each prompt carefully.

  • Keep the existing file if it contains custom settings that must be preserved.
  • Install the maintainer's version if you have determined that the new configuration is appropriate.
  • Review the differences if you are unsure.

Pay particular attention to SSH, networking, authentication, firewall, and other critical service configurations.

Avoid automatically accepting or rejecting every configuration change.

12. Complete the upgrade and reboot

When the upgrade finishes, Ubuntu normally indicates that a restart is required.

A message may resemble:

System upgrade is complete.

Restart required

To finish the upgrade, a restart is required.
If you select 'y' the system will be restarted.

Continue [yN]

Enter y when you are ready to restart.

Alternatively, if the upgrader has completed successfully and you are instructed to reboot manually:

$ sudo reboot

Wait for the system to restart, then reconnect.

If the system does not boot successfully, investigate the problem before attempting another upgrade or making additional changes.

13. Verify the new Ubuntu installation

After reconnecting, verify that the upgrade succeeded.

Check the installed Ubuntu version

$ lsb_release -a

Alternatively:

$ cat /etc/os-release

Confirm that the reported release matches your intended destination.

Check the running kernel

$ uname -r

The running kernel should reflect the version currently booted after the upgrade.

Check disk space

$ df -h

Confirm that sufficient space remains on the root filesystem and other important partitions.

Check for failed services

$ systemctl --failed

Investigate any failed services that are expected to be running.

Review system errors

$ sudo journalctl -p err -b --no-pager

Not every logged error is necessarily serious. Focus on errors affecting storage, networking, authentication, boot, and essential services.

Check for incomplete package operations

$ sudo dpkg --audit

If the command reports incomplete package operations, investigate and resolve them before considering the upgrade complete.

You can also refresh the package indexes:

$ sudo apt update

Review any repository errors, particularly those involving third-party sources that may have been disabled during the upgrade.

14. Verify essential services

A successful operating-system boot does not guarantee that every application is working correctly.

Check the services that your system uses.

For example, check SSH:

$ systemctl status ssh --no-pager

Check Nginx, if installed:

$ systemctl status nginx --no-pager

Check Docker, if installed:

$ systemctl status docker --no-pager

Check listening ports:

$ sudo ss -lntup

Test important applications, websites, databases, and network services.

If you use Docker, verify that the expected containers are present:

$ docker ps -a

Confirm that persistent data is intact and that applications can access their required databases and services.

Remove temporary firewall rules

If you added a temporary UFW rule for port 1022, remove it after confirming that normal SSH access works.

For a rule restricted to a particular IP:

$ sudo ufw delete allow from YOUR_PUBLIC_IP to any port 1022 proto tcp

For a rule allowing access from anywhere:

$ sudo ufw delete allow 1022/tcp

Use the command corresponding to the rule you actually created.

Confirm the final firewall configuration:

$ sudo ufw status



Bonus: How to reconnect to an interrupted do-release-upgrade session

What happens if your SSH connection drops while do-release-upgrade is running?

The release-upgrade utility can use a screen session to help preserve the upgrade process across an SSH disconnection. It may also start a temporary SSH daemon on port 1022.

These mechanisms provide recovery options, but their availability depends on the upgrade environment and configuration.

Step 1: Check for an existing screen session

Run:

$ sudo screen -list

If an upgrade session exists, the output may resemble:

There is a screen on:
    3466.ubuntu-release-upgrade-screen-window (Detached)
1 Socket in /run/screen/S-root.

The session name and identifier will differ on your system.

Step 2: Reattach to the session

Use the session identifier shown in your output:

$ sudo screen -d -r 3466.ubuntu-release-upgrade-screen-window

Replace the example session name with the actual name reported by screen -list.

If successful, you should return to the existing upgrade session.

Important: Do not start another release upgrade while the original upgrade is still running. First determine whether the original process is active and whether you can recover its session.

If no screen session exists, use the available SSH recovery connection or another recovery method to assess the system before taking further action.


Upgrading Ubuntu Server involves more than running a single command. Proper preparation, a verified backup, sufficient disk space, and a reliable recovery method help reduce the risk of downtime and data loss.

By following this tutorial, you can prepare your system, perform a supported release upgrade, and verify that your services are functioning afterward.

For release-specific requirements and the officially supported upgrade path, consult the Ubuntu Server release-upgrade documentation.

We hope this was helpful.
Keep learning. Keep exploring.

Keep Us Caffeinated  ⦿ ⦿
Spotify Logo
↑
SNUBmonkey Join our readers