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
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:
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.
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.
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.
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.
For me also another commands helps in chroot environment to all packages configure properly (run this before
dpkg ,dist
etc) :