Thursday, January 30, 2014

How To Fix A Non-Bootable Ubuntu System Due To Broken Updates Using A LiveCD And Chroot

----
How To Fix A Non-Bootable Ubuntu System Due To Broken Updates Using A LiveCD And Chroot
// Web Upd8 - Ubuntu / Linux blog

If your Ubuntu system doesn't boot because of some broken updates and the bug was fixed in the repositories, you can use an Ubuntu Live CD and chroot to update the system and fix it.

1. Create a bootable Ubuntu CD/DVD or USB stick, boot from it and select "Try Ubuntu without installing". Once you get to the Ubuntu desktop, open a terminal.

2. You need to find out your root partition on your Ubuntu installation. On a standard Ubuntu installation, the root partition is "/dev/sda1", but it may be different for you. To figure out what's the root partition, run the following command:

sudo fdisk -l

This will display a list of hard disks and partitions from which you'll have to figure out which one is the root partition.

To make sure a certain partition is the root partition, you can mount it (first command under step 3), browse it using a file manager and make sure it contains folders that you'd normally find in a root partition, such as "sys", "proc", "run" and "dev".

3. Now let's mount the root partition along with the /sys, /proc, /run and /dev partitions and enter chroot:
sudo mount ROOT-PARTITION /mnt
for i in /sys /proc /run /dev; do sudo mount --bind "$i" "/mnt$i"; done
sudo cp /etc/resolv.conf /mnt/etc/
sudo chroot /mnt
Notes:
ROOT-PARTITION is the root partition, for example /dev/sda1 in my case - see step 2;the command that copies resolv.conf gets the network working, at least for me (using DHCP); if you get an error about resolv.conf being identical when copying it, just ignore it.
Now you can update the system - in the same terminal, type:
sudo apt-get update
sudo apt-get upgrade

Since you've chrooted into your Ubuntu installation, the changes you make affect it and not the Live CD, obviously.

If the bug that caused your system not to boot is happening because of some package in the Proposed repositories, the steps above are useful, but you'll also have to know how to downgrade the packages from the proposed repository - for how to do that, see: How To Downgrade Proposed Repository Packages In Ubuntu

Refrences: 1, 2, 3

Originally published at WebUpd8: Daily Ubuntu / Linux news and application reviews.

----
Shared via my feedly reader