Rescuing an Interrupted Ubuntu Upgrade

Upgrading Ubuntu from one version to the next has always been amazingly reliable; yet, sometimes, things happen. How do you recover when your upgrade is interrupted and you can’t boot the system in the usual way?

First step is to boot the machine to a shell that you can use to recover. This can be done in the standard system by using the Recovery Mode. Press the left shift key as the system boots up and choose a recovery mode kernel from the menu that appears – it will be labeled with “(recovery mode)” on the end. The recovery mode kernel will present you with the option to use a recovery shell.

You could use the rescue mode by booting with an Ubuntu install CDROM and entering “rescue” at the boot prompt, but then you must remember to mount all of your partitions and to perform a chroot to /target where the root partition is mounted.

After the system has booted to the menu, select the item that says “Drop to root shell prompt with networking”. This provides you with the ability to update the software packages from the Internet.

When the prompt appears, start by making sure that all currently installed programs are configured:

dpkg --configure -a

This may take a long time, depending on how many programs were installed before the system stopped. Then go ahead and update the current list of packages:

apt-get update

Following this, upgrade the software on the system:

apt-get upgrade

This last step, again, may take a long time to complete. You should pay attention to the list of packages held back (listed at the top of the output from this command); these packages will have to be requested specifically. Usually, packages are held back because they require new software or other drastic changes: the Linux kernel is always held back. Use a command like this one to install these packages:

apt-get install some-package some-other-package

You may have to repeat this more than once until all of the packages have been installed and none are held back.

Then, you should repeat the update and upgrade in order to completely verify that the system is as updated as it can be:

apt-get update
apt-get upgrade

These last commands should execute quickly, as everything is probably complete – however, it is not impossible that the upgrades would have affected something that requires another upgrade. Not doing this probably won’t matter, but why not do it anyway?

Once done, a reboot is required to make sure that the old software is no longer being used and all that is used is the new upgraded software. Don’t just continue the boot: reboot.

One more thing can be done to clean up afterwards – possibly after the reboot. At a command shell, enter this command to remove unneeded software:

apt-get autoremove

Some general tips on making distribution upgrades as easy as possible: first, upgrade the system to the latest set of patches and software available. If there are bugs in the ugprading software, you want to fix it first.

Once upgraded to the most recent patch set (or the most recent minor level), then upgrade to the next major level (and no more!). Upgrades are normally tested only to the next major release. Any other upgrade is certainly not tested and not guaranteed to work.

If you want to upgrade beyond just the next major release, repeat the above steps for each major release: first upgrade to the most recent software, then upgrade to the next major release.

Make sure that you have reliable power throughout: if a system loses power in the middle of an upgrade process (or otherwise stops cold) then you will have to perform a recovery and hope that nothing was lost.

9 thoughts on “Rescuing an Interrupted Ubuntu Upgrade”

  1. Nice guide, will come in handy for quite a few I think.

    Just one small thing to add: I’d suggest to go for apt-get dist-upgrade in order to handle the dependency changes with new versions of packages and therefore making the manual step of installing new dependencies obsolete.

    Keep it up!
    Thomas

    1. Thanks for the tip!

      Presumably, the interrupted upgrade was an apt-get dist-upgrade in the background; I always figured it was bad to repeat it. Wouldn’t it also try to bump the distribution yet another major level up? That is, a failed upgrade to Natty would be pushed further to Oneiric with a dist-upgrade – wouldn’t it?

      1. It’s quite safe to execute the apt-get dist-upgrade as it only tells apt to automatically handle dependency changes on packages.

        For doing an ‘actual’ upgrade to a later release you’d have to use do-release-upgrade (at least with ubuntu). This handles re-pointing the sources.list.d and/or sources.list entries to the newer distribution and *then* performs an apt-get dist-upgrade to actually upgrade the packages (plus probably some magic in between 🙂 ).

        Cheers
        – Thomas

    1. this is quite buggy if already have the egg to operate on. it skips the basics with maachine_id, primary-, default- and rescue-target …… which is needed prior to enter a working anything without playing hangman inside grub/… bootmanager!!!

  2. Hi and thanks for your tips, in my case it cannot go ahead with apt-get update, it says “no sandbox user ‘_apt’ on the system, can not drop privileges
    W: failed to fetch http:…”
    So I guess that the networkmanager cannot connect to internet, could this be ?
    How can I fix that, any help please?

  3. Mr. Douthitt, thank you for this helpful post. The part down through “dpkg –configure -a” was enough to help me get back to a bootable state with my failed Kubuntu 17.10 install this weekend.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s