Smoothwall Firewall project

Sunday, 8 November 2009

Another very useful feature of the Ubuntu live CD

I had to look at an Ubuntu installation the other day that had a problem after it had been upgraded. This problem turned out to be that the friend had previously installed an early version of the Grub boot loader and had not regressed this before the upgrade , an easy mistake to make.

The cure for this is well documented on the web and the solution is to boot your PC with an Ubuntu live CD and mount the harddisk in a chroot jail so we can then play with it and re-install the correct version of Grub. This procedure was taken from the official Ubuntu wiki.

Reinstalling GRUB 2 from LiveCD
If you cannot boot from GRUB 2 and need to reinstall it:

* Boot to the 9.10 Karmic LiveCD Desktop.
* Open a terminal - Applications, Accessories, Terminal.
* Determine your normal system partition - `sudo fdisk -l` (That is a lowercase L)
* If you aren't sure, run `df -Th`. Look for the correct disk size and ext3 or ext4 format.
* Mount your normal system partition:
Code:

sudo mount /dev/sdXX /mnt

o Note: substitue the correct partition: sda1, sdb5, etc.
o Note: GRUB 2 counts the first drive as "0", but the first partition as "1"
* Only if you have a separate boot partition:
o

sudo mount /dev/sdYY /mnt/boot

with sdYY being your /boot partition designation.
* Note: If you have any other system partitions such as "/usr" these should also be mounted in a similar manner.
* Mount devices:

sudo mount --bind /dev/ /mnt/dev

* Chroot into your normal system device:

sudo chroot /mnt

* Reinstall GRUB 2:

sudo grub-install /dev/sdX

*
o Note: Substitute the correct device - sda, sdb, etc. Do ''not'' specify a partition number.
* Verify the install:

sudo grub-install --recheck /dev/sdX

o Note: Substitute the correct device - sda, sdb, etc. Do ''not'' specify a partition number.
* Exit chroot: CTRL-D
* Unmount devices:

sudo umount /mnt/dev

* If you mounted a separate /boot partition:

sudo umount /mnt/boot

* Unmount last device:

sudo umount /mnt

* Reboot.


This procedure had his machine up and running perfectly again in five minutes, but just shows how flexible this live CD is and there are no real limitations to what you can get up to once you have this up and running.

2 comments:

nick_lee_5 said...

And another useful use of the CD - as a coffee coaster.... The best use I've found for it ever!

Codfather said...

Yes, and someone with your intellect using all OS CD's as a coaster is a good idea.