Sub topic 15
Major release upgrades are a separate project
This chapter assumes you can run apt and dnf updates, read their output, and use sudo over SSH. It also assumes you know how repositories, holds and transaction history work from earlier chapters. Everything so far has kept a server current inside one release. Here you learn why moving to the next major release is a different kind of work, and how to plan it.
Patching versus upgrading the release
A routine patch run stays inside one release, such as Ubuntu 22.04 or RHEL 9. The distribution keeps package versions stable and backports security fixes into them. A package that updates from 1.2.3-1 to 1.2.3-2 rarely changes behavior. Its configuration format, library interfaces and command-line options stay the same.
A major release upgrade replaces that stable base. The new release ships a new kernel, a new C library, a new OpenSSL, a new Python and often a new systemd. Defaults change, and some packages are dropped or renamed. Config files that worked for years may be rejected or silently ignored.
| Aspect | Routine patching | Major release upgrade |
|---|---|---|
| Frequency | Weekly or daily | Every few years |
| Repositories | Unchanged | Switched to the new release |
| Behavior changes | Rare, deliberate backports only | Expected |
| Typical duration | Minutes | An hour or more, plus testing time |
| Reboot | Sometimes | Always |
| Undo | `dnf history undo` where available | Restore from snapshot or backup |
| Planning | A routine | A project with an owner and a date |
The last two rows matter most. In the history and rollback chapter you saw that dnf history undo can reverse a transaction. A release upgrade changes thousands of packages, the kernel and the boot setup. The package manager cannot reliably reverse it. Your rollback plan has to be a snapshot, a backup, or a second server.
Why you cannot postpone it forever
Every release has a support window. After it ends, the distribution stops publishing security fixes for that release, and apt upgrade or dnf upgrade quietly stops finding them. A server on an unsupported release looks fully patched while it collects known vulnerabilities.
- Ubuntu LTS releases get five years of standard security maintenance. Ubuntu Pro (ESM) extends this for subscribers.
- RHEL major releases get ten years of support. Rebuilds such as Rocky Linux and AlmaLinux follow upstream dates.
- Debian stable releases get security support for about three years, then a volunteer-run long-term support period.
Record the end-of-support date for each server in your inventory. Start planning the upgrade at least six months before that date.
The tools differ by distribution
Each family has its own upgrade path. Using the wrong approach, such as editing repository files by hand on a distribution that has a supported tool, is a common cause of broken systems.
Ubuntu
Ubuntu provides do-release-upgrade. By default it moves only from one LTS release to the next, and only after the first point release of the new LTS is published. That policy is set in /etc/update-manager/release-upgrades.
# /etc/update-manager/release-upgrades (excerpt)
[DEFAULT]
Prompt=ltsTo see whether an upgrade is available without starting one, run sudo do-release-upgrade -c. When you run the real upgrade over SSH, the tool starts an extra SSH daemon on port 1022 as a fallback if your session drops. If a firewall sits in front of the server, allow that port for the upgrade window.
Debian
Debian has no wrapper tool. You follow the release notes for the target release. The usual steps are:
- Fully patch the current release.
- Back up the system.
- Point the APT sources at the new release's codename.
- Run
apt update. - Run a minimal
apt upgrade --without-new-pkgs. - Run
apt full-upgrade. - Reboot.
The release notes also name steps that are specific to that version. These can include removed packages, changed network naming and moved configuration. Read them for the exact target release, because they differ each time. Debian supports upgrading one release at a time only.
RHEL and rebuilds
RHEL uses the Leapp framework for in-place upgrades. Only supported paths work, and each is a single major step, such as 8 to 9. You first run an analysis that changes nothing, then review its report.
sudo leapp preupgrade
less /var/log/leapp/leapp-report.txtThe report lists "inhibitors", which are problems that block the upgrade until you fix them. Typical examples are an unsupported kernel module or a disabled required feature. Rocky Linux and AlmaLinux use the ELevate project, which is built on Leapp. Fedora uses a different tool, dnf system-upgrade, and that tool is not for RHEL.
Inventory before you plan
Third-party repositories and manually installed packages cause most upgrade failures. A vendor repository built for the old release may not exist for the new one. The upgrade tool will then disable it, leaving those packages orphaned. The script below is read-only. Run it on each server and keep the output with your upgrade plan.
#!/usr/bin/env bash
# Read-only preflight checks before planning a release upgrade.
. /etc/os-release
echo "OS: ${PRETTY_NAME}"
echo "Kernel: $(uname -r)"
echo "--- free space on /, /var and /boot"
df -h / /var /boot 2>/dev/null
if command -v apt >/dev/null 2>&1; then
echo "--- held packages"
apt-mark showhold
echo "--- repository sources"
grep -rhE '^(deb|URIs:)' /etc/apt/sources.list /etc/apt/sources.list.d/ 2>/dev/null
echo "--- packages not from a configured repository"
apt list --installed 2>/dev/null | grep -F '[installed,local]'
elif command -v dnf >/dev/null 2>&1; then
echo "--- version locks"
dnf versionlock list 2>/dev/null
echo "--- enabled repositories"
dnf repolist --enabled
echo "--- packages not in any enabled repository"
dnf list extras
fiRead the output for these items:
- Held or version-locked packages. The upgrade tool may refuse to proceed, or may break the pin. Decide in advance whether to release each hold.
- Third-party repositories. For each one, check whether the vendor publishes packages for the target release.
- Local or "extras" packages. These come from no repository, so nothing will upgrade them. Check that each one still works on the new libraries.
- Free space. An upgrade downloads and unpacks thousands of packages. Low space on
/bootis a classic failure when old kernels pile up. The cleanup chapter'sautoremovehelps here.
The project, step by step
- Rehearse on a clone. Restore a recent backup or snapshot of the server into an isolated test environment. Run the full upgrade there. Write down every manual fix, because you will repeat them in production.
- Test the application, not just the OS. A clean boot proves little. Run the application's own tests, check database connections, and confirm that services start in the right order.
- Take a recovery point. Use a VM or cloud snapshot, or a verified backup that you have tested restoring. Confirm you can reach the console, since SSH may be down after a failed upgrade.
- Run it in a maintenance window. Use
tmuxorscreenso a dropped SSH session does not interrupt the upgrade. Ubuntu's tool does this for you, but starting your own is harmless. - Verify afterwards. Use the same checks as after any patch run: service status, logs, listening ports and application tests. Then confirm the new release with
cat /etc/os-release. - Return to routine. Re-add third-party repositories for the new release and re-apply any holds you still need. Run a normal patch cycle on the new release.
If the system is stateless, building a fresh server on the new release and moving traffic over is often safer than an in-place upgrade. The old server stays untouched as the rollback. This costs more up front and needs automated provisioning. It fits web tiers well and databases poorly.
Common errors
- Upgrading with pending patches. Fully patch the current release first. Both Ubuntu and RHEL tools check for this, and some failures come from old package versions.
- Forgetting repository files. After a Debian-style source edit, a leftover third-party file still pointing at the old release can pull in mismatched packages.
- Ignoring config prompts. Package scripts ask whether to keep your modified config file or install the maintainer's version. Keeping yours preserves your settings but may miss new required options. Look at the differences before you decide, and keep a copy of both.
- No console access. If the machine does not boot after the upgrade, SSH will not help. Make sure you have a virtual console, IPMI or a recovery path first.
- Treating the tool's success message as verification. The upgrade finishing only means the packages installed. The application still needs testing.
Exercise
A colleague wants to move a production RHEL 8 server to RHEL 9 by running sudo dnf upgrade after changing its repository files to the RHEL 9 URLs, and says dnf history undo will be the rollback. List two things wrong with this plan and what you would do instead.
Show answer
First, a supported in-place path exists (Leapp), and hand-editing repositories bypasses its checks and its fixes for incompatible packages. Use leapp preupgrade, review the report, and fix any inhibitors before running leapp upgrade. Second, dnf history undo cannot reliably reverse a change of thousands of packages, a new kernel and a new C library. The rollback must be a snapshot or tested backup taken before the upgrade. A good plan also rehearses the whole upgrade on a clone first, and runs it in a maintenance window with console access available.
Exercise
Why does the preflight script list packages that come from no repository, and what do you do with the result?
Show answer
Nothing in a repository will upgrade those packages, so the release upgrade will not update or rebuild them. They may break when the libraries underneath them change. For each one, check whether a build for the target release exists, plan to reinstall or rebuild it afterwards, and test it on the clone.