Avoiding the “Broken Packages” Hang When Upgrading From Ubuntu 22.04 to 24.04 on a Home Server

Why the “Broken Packages” Hang is a Common Pain Point

When I run a fresh upgrade from Ubuntu 22.04 LTS to 24.04 LTS on a home server, the first thing that can bite me is the infamous “Broken Packages” dialog that stalls the upgrade process. It isn’t a bug in the installer; it’s the package manager trying to juggle a huge shift in dependencies between releases. The result is a long pause—sometimes hours—before the system finally moves on. For a server that should stay online, that pause is unacceptable.

Below is a step‑by‑step guide that turns the upgrade into a predictable, low‑risk operation. It covers the preparatory work, the actual upgrade, and the post‑upgrade cleanup. I’ll also point out the security trade‑offs that pop up when you decide to keep or drop certain packages.


1. Prepare the System

1.1 Update and Upgrade the Current System

sudo apt update && sudo apt full-upgrade -y
sudo apt autoremove -y

Running a full upgrade ensures that all packages on 22.04 are at their latest point releases. This reduces the number of “orphaned” packages the upgrader will try to reconcile.

1.2 Clean the Cache

sudo apt clean

The apt cache can grow large over time. Cleaning it frees disk space and reduces the chance of pulling in stale packages.

1.3 Verify Disk Space

df -h /

Ubuntu 24.04 needs roughly 10 GB more space than 22.04 for the base system and the new kernel. If you’re on Btrfs or ZFS, make sure the subvolume you’ll upgrade has enough free space.

1.4 Snapshot the Root Filesystem

If you’re using Btrfs or ZFS, create a snapshot before the upgrade:

sudo btrfs subvolume snapshot / /root-snap-$(date +%F)
# or for ZFS
sudo zfs snapshot rpool/ROOT@upgrade-$(date +%F)

Snapshots give you a quick rollback point if something goes wrong. On LVM, a thin‑pool snapshot is the closest alternative.

1.5 Disable Unnecessary Services

Some services (e.g., snapd, ufw, fail2ban) can interfere with the upgrade. Temporarily stop them:

sudo systemctl stop snapd
sudo systemctl stop ufw
sudo systemctl stop fail2ban

You’ll re‑enable them after the upgrade.


2. Configure the Upgrade Path

2.1 Edit /etc/update-manager/release-upgrades

sudo nano /etc/update-manager/release-upgrades

Make sure the Prompt line reads:

Prompt=lts

This tells do-release-upgrade to target the next LTS release.

2.2 Pin Packages You Want to Keep

If you have custom packages or specific versions you must keep, pin them:

echo "Package: my-custom-app
Pin: version 1.2.3
Pin-Priority: 1001" | sudo tee /etc/apt/preferences.d/my-custom-app

High‑priority pins prevent the upgrader from pulling in newer, potentially incompatible versions.

2.3 Check for Held Packages

dpkg --get-selections | grep hold

If any packages are on hold, decide whether to unhold them:

sudo apt-mark unhold package-name

Held packages are a common source of “Broken Packages” because the upgrader cannot resolve their dependencies.


3. Start the Upgrade

sudo do-release-upgrade -d

The -d flag forces the upgrade to the next LTS even if the release is not yet officially announced. In 2026, 24.04 is the current LTS, so this flag is optional but harmless.

3.1 Watch the Dependency Resolver

During the upgrade, do-release-upgrade will invoke apt to install new packages and remove old ones. If it stalls, press Ctrl+C to abort, then run:

sudo apt -f install
sudo dpkg --configure -a

These commands fix broken dependencies and reconfigure partially installed packages. Afterward, re‑run the upgrade.

3.2 Avoid the “Broken Packages” Dialog

If the dialog appears, it usually means that apt can’t resolve a dependency chain. A quick fix is to allow apt to remove the problematic package:

sudo apt remove problematic-package

If the package is critical, consider replacing it with an alternative that’s available in 24.04.


4. Post‑Upgrade Tasks

4.1 Re‑enable Services

sudo systemctl enable snapd
sudo systemctl enable ufw
sudo systemctl enable fail2ban
sudo systemctl start snapd
sudo systemctl start ufw
sudo systemctl start fail2ban

4.2 Verify Kernel and Initramfs

uname -r
sudo update-initramfs -u -k all

The kernel should now be 6.5.x. If you’re using custom initramfs hooks, double‑check that they still work.

4.3 Clean Up Old Kernels

sudo apt autoremove --purge

This removes kernels that are no longer needed, freeing space.

4.4 Check for Security Updates

Ubuntu 24.04 ships with newer kernel patches and libssl updates. Run:

sudo apt update && sudo apt upgrade -y

to make sure you’re on the latest security patches.


5. Common Pitfalls and How to Avoid Them

PitfallWhy It HappensFix
Unclean package cacheStale packages cause dependency mismatchessudo apt clean before upgrade
Held packagesPrevents dependency resolutionsudo apt-mark unhold
Custom PPAsPPAs may not have 24.04 buildsDisable PPAs or pin to 22.04 versions
Large number of snap packagesSnap confinement can conflict with system packagesRemove or update snaps before upgrade
Insufficient disk spaceUpgrade needs extra space for new packagesFree space or expand partition

6. Security‑Focused Trade‑Offs

6.1 Snap vs. APT

Snap packages are sandboxed, which is great for isolation but can interfere with system upgrades. If you rely heavily on snaps, consider migrating critical services to APT‑managed packages before the upgrade.

6.2 Firewall Configuration

After the upgrade, firewall rules may reset to defaults. Re‑apply custom rules:

sudo ufw status numbered
sudo ufw allow 22/tcp

Fail2ban’s jail configuration may also need review to ensure it still matches your SSH port and authentication methods.

6.3 Kernel Hardening

Ubuntu 24.04 includes the latest kernel hardening patches (e.g., mitigations for Spectre, Meltdown). Verify that grub is configured to enable all mitigations:

cat /etc/default/grub | grep mitigations

If you disabled any mitigations for performance, consider re‑enabling them.


7. Troubleshooting “Broken Packages” After Upgrade

If you still encounter broken packages after the upgrade, run:

sudo apt-get check
sudo apt-get -f install

These commands identify and fix broken dependencies. If a specific package remains problematic, search for its status:

dpkg -l | grep package-name

Sometimes the package is no longer available in the new release. In that case, either remove it or find an alternative.


8. Automating the Process

For repeatable upgrades (e.g., in a homelab with multiple servers), wrap the steps in a Bash script:

#!/usr/bin/env bash
set -euo pipefail

# 1. Update
sudo apt update && sudo apt full-upgrade -y
sudo apt autoremove -y
sudo apt clean

# 2. Snapshot
sudo btrfs subvolume snapshot / /root-snap-$(date +%F)

# 3. Stop services
sudo systemctl stop snapd ufw fail2ban

# 4. Upgrade
sudo do-release-upgrade -d

# 5. Restart services
sudo systemctl start snapd ufw fail2ban

Run it with sudo and monitor the output. The script will fail fast if any step encounters an error, allowing you to intervene before the system becomes unstable.


9. Final Checklist

  • Disk space ≥ 10 GB free on root.
  • All packages upgraded to latest 22.04 point release.
  • Snap, firewall, and security services stopped.
  • Root snapshot created.
  • do-release-upgrade executed without abort.
  • Services re‑enabled and verified.
  • Kernel and initramfs updated.
  • Security patches applied.

If you tick all boxes, the upgrade should finish cleanly, and your home server will be running Ubuntu 24.04 LTS with minimal downtime.



See also