Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have a computer which was unexpectedly shut down during a distribution upgrade (Ubuntu 8.10 -> 9.04). It now won't finish booting - various X errors, then it goes to the login screen but won't allow logins.

I have a backup of it and the /home data is all still OK on the drive so it's no emergancy, but a complete rebuild is still an annoying and time consuming process. Is there any way to recover from this? I have a 9.04 CD, I was debating trying installing over the top - is that a good idea?

Failing that, is there any good way of inspecting the drive and generating a list of software installed, and preferably even the setttings from outside /home (like /etc)?


If I've got to start again from scratch, any recommendations for dealing with the person responsible for the unexpected shutdown? :)


EDIT: Thank you very much for all the answers, I really need to accept all the answers as I needed to use bits from each. I was able to fully repair the install using something like this:

sudo dpkg --configure -a
sudo apt-get update
sudo dpkg --configure -a
sudo dpkg --configure -a --abort-after=99999
sudo apt-get dist-upgrade
sudo apt-get -f install
sudo apt-get dist-upgrade
share|improve this question
1  
Use a LART (catb.org/jargon/html/L/LART.html): "The LART classic is a 2x4 or other large billet of wood usable as a club [...] knobkerries, automatic weapons, flamethrowers, and tactical nukes all have their partisans." –  David Schmitt May 15 '09 at 11:48
    
Can you actually type in you login credentials, or are the keyboard and/or mouse unavailable? –  Oddmund May 15 '09 at 14:36
    
I could type in the credentials, but it wouldn't go any further. CTRL+ALT+F1 gave me a terminal however and I was able to log in there –  Colin Pickard May 20 '09 at 9:39
    
You may get a troubles when /usr, /home and similar folders are mounted from separate disks, in this situation bind helps. use mount --bind /proc /chrooted/proc mount --bind /mnt/usr /chrooted/usr ... –  user90572 Aug 5 '11 at 0:03

5 Answers 5

up vote 7 down vote accepted

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
share|improve this answer

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.

share|improve this answer
    
I'm going to add dpkg --get-selections to my backup scripts I think. Very useful. –  Colin Pickard May 20 '09 at 6:54
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.

share|improve this answer

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.

share|improve this answer

For me also another commands helps in chroot environment to all packages configure properly (run this before dpkg ,dist etc) :

Upstart jobs cannot be started in a chroot because upstart acts as a service supervisor, and processes within the chroot are unable to communicate with the upstart running outside of the chroot (Bug:430224). This will cause some packages that have been converted to use upstart jobs instead of init scripts to fail to upgrade within a chroot. Users are advised to configure their chroots with /sbin/initctl pointing to /bin/true, with the following commands run within the chroot:

Code:

dpkg-divert --local --rename --add /sbin/initctl
ln -s /bin/true /sbin/initct
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.