Recover from shutdown during Ubuntu distribution upgrade

Solution 1:

If you can get to a place where you can use dpkg as root, you can run dpkg --configure -a

However, you might find that explodes for a borked dist-upgrade, so you might need:

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

Solution 2:

Try pressing CTRL-ALT-F1 and see if you get a command prompt. See if you can login, then try running sudo apt-get dist-upgrade. This should allow you too finish the upgrade. You may get errors so you might also need to try using sudo dpkg --configure -a.


To get a list of the installed software you can run the command dpkg --get-selections. If you save they output of that command to a file you can use the command cat selections | sudo dpkg --set-selections and then use the command sudo apt-get dselect-upgrade to actually get all the packages installed.

If you do go that route you probably should backup your /etc and /home folders to another device.


Solution 3:

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

1st line refreshes the current level of the repo you're downloading against

2nd line reconfigures any packages that are in a "bad" state

3rd line is in there just in case the repository "moves" to the new version during the 2nd line's process.

4th line should finish the job.


Solution 4:

I was able to recover from a catastrophic situation where Xubuntu would not boot up after the power went out during an upgrade. About 10 seconds after POST, Xubuntu would halt with a host of errors (trying to load the "recovery" option in grub would not even work either).

So if anyone stumbles upon this, I am posting some info from the Ubuntu forums that helped me to get to a terminal window so I could use the commands Colin and Avery posted above.

---------- snip ---------- snip ---------- snip ---------- snip ----------

ubuntuforums.org/showthread.php?t=157250

Let's say your system just melted down after an upgrade, or your new kernel won't boot. You can't fix the problem with apt-get, because you can't even get to a command line; the kernel just spews out errors and hangs on bootup. Thankfully, with a live cd, you can repair your system and get it up and running. You have 2 options for the live cd: Knoppix or the Ubuntu live cd. Since Knoppix generally has better hardware detection, this will be used as an example.

  1. First, download the iso from http://www.knoppix.org/ and burn it to a disk.
  2. Get your BIOS set up to boot from the cd, pop in the Knoppix disk, and boot.
  3. Your hard drive should show up on the KDE desktop as hda1 or sdb2 or something, depending on your system.
  4. Click on it to mount it, then right-click, actions -> change to read-write mode. It'll pop open a dialog; click yes.
  5. Now, open a root terminal, found in the Knoppix menu (the one next to the K on the panel). Enter: chroot /mnt/hda1 or whatever the icon for your harddrive says on the desktop.

You can now use all the commands on the hard drive, including apt-get. If you ever get this error: "/dev/null: Permission denied" then do this: "sudo rm /dev/null" and it should go away. Now, use apt-get to upgrade your kernel, udev, or anything else that's messing up your system.

---------- snip ---------- snip ---------- snip ---------- snip ----------

It worked out perfectly too! I mounted my hard drive per the instructions, opened a terminal window, entered "sudo chroot /media/hda1", and finally had access to my hard drive. I was then able to use the commands posted earlier in this thread to restart the upgrade process. :)

It's any wonder why the Ubuntu Live/Installation CD doesn't have a "recovery console" built in to facilitate this whole recovery process.

Tags:

Ubuntu

Upgrade