How to Recover an Interrupted Ubuntu Distribution Upgrade (8.10 to 9.04) and Fix Broken Packages


22 views

Few things are more frustrating than an interrupted system upgrade. When Ubuntu 8.10 was being upgraded to 9.04 on my machine, someone pulled the plug (literally). The result? A system that wouldn't boot properly - X errors, login screen issues, and general instability. While my /home data was safe, I needed to recover the system without a complete reinstall.

Before attempting any fixes, it's crucial to understand what state the package manager is in:

sudo dpkg --audit
sudo apt-get check

These commands will show you any broken or half-configured packages from the interrupted upgrade.

After several attempts, this sequence proved most effective for repairing the installation:

sudo dpkg --configure -a
sudo apt-get update
sudo dpkg --configure -a --abort-after=99999
sudo apt-get dist-upgrade
sudo apt-get -f install
sudo apt-get dist-upgrade

Let's break down what each command does:

  • dpkg --configure -a: Attempts to configure all unpacked but unconfigured packages
  • The --abort-after=99999 flag prevents premature termination during complex configurations
  • apt-get -f install fixes broken dependencies

If the system remains unbootable, you can still extract important configuration data:

# List all installed packages
dpkg --get-selections > installed_packages.list

# Backup important configs
sudo tar -cvzf etc_backup.tar.gz /etc/
sudo tar -cvzf usr_share_backup.tar.gz /usr/share/

Some lessons learned:

  1. Always use screen or tmux for long upgrade processes
  2. Consider upgrading via the alternate installer rather than the GUI
  3. Maintain regular backups with deja-dup or similar tools

If package repair fails, you can attempt an overinstall:

# Boot from 9.04 CD
# Choose "Install Ubuntu" but select "Manual" partitioning
# Mount existing partitions without formatting
# The installer should preserve your configs while fixing system files

Remember that while /home is preserved by default, system configurations in /etc might get overwritten during this process.


When a distribution upgrade gets interrupted (especially between major versions like Ubuntu 8.10 to 9.04), you'll typically see:

  • X server failing to start with cryptic errors
  • Login screen appearing but rejecting credentials
  • Broken package dependencies in the apt system

Boot into recovery mode (select it from GRUB) and run these essential commands:

sudo dpkg --configure -a
sudo apt-get update
sudo apt-get -f install
sudo apt-get dist-upgrade

The --abort-after flag can help with stuck configurations:

sudo dpkg --configure -a --abort-after=99999

For stubborn cases, manually verify package states:

sudo dpkg --audit
sudo dpkg --get-selections | grep -v deinstall
sudo apt-cache policy <problem-package>

After fixing packages, rebuild X configuration:

sudo dpkg-reconfigure xserver-xorg
sudo service gdm restart

For NVIDIA/ATI drivers:

sudo apt-get install --reinstall nvidia-current
sudo nvidia-xconfig

If all else fails, consider a fresh install while preserving:

/home
/etc (backup first!)
/var/lib/dpkg/status (contains installed package list)

To document installed packages before reinstall:

dpkg --get-selections > package_list.txt
sudo tar czf etc_backup.tar.gz /etc/

For production systems, consider using LTS releases or Debian stable with:

sudo apt-get install debian-goodies
sudo deborphan | xargs sudo apt-get -y purge