Fixing a GRUB Bootloader (What to do when your computer won’t boot!)

If, for some reason your linux computer won't boot, it could be because the bootloader has gotten correupted.  If you are using GRUB, a few things could have gone wrong, but I will describe how to do a complete re-install of grub, and then set up the boot menu again. The system I was working on was Ubuntu 6.10.

First, you will need an emergency rescue CD. I recommend the systemrescuecd  because at 115MB it is relatively quick to install, but has all of the tools you'll need.  Burn the CD, and then boot your computer off of it.

On my system, /dev/hda1 (a.k.a hd0,0 to grub) had a windows partition, /dev/hda2 had a linux swap partition, and /dev/hda3 (a.k.a. hd0,2 to grub) had the linux partition.

You can run the grub shell off of the rescue cd by simply typing: grub

It will probe your hardware and then give you a prompt. In my case, I knew that a full version of grub was already installed in /boot/grub/ on /dev/hda3, but to find where it is installed on your computer you can run the command: find /boot/grub/stage1

Now that you know where it is, tell grub to use that partition as your "root": root (hd0,2)
NOTE: I used (hd0,2) your parition may be different, see the find command above!

Then, to install the grub stage1 and 2 files, type: setup (hd0)
Note: I used hd0 which is the same as /dev/hda, if you have multiple disks you may need to use hd1 etc…

This will get the grub stage 1 and 2 installed on your disk, making it bootable.

Now, take out the rescue CD, and reboot your computer. If you did everything correctly, it will boot up to a GRUB prompt. You can use this grub prompt to manually boot into your linux partition. First, you will need to find your kernal and initrd image. On my Ubuntu disk, /vmlinuz and /initrd.img are links to the correct files, so the command: find /vmlinuz returns (hd0,2).

To specify the kernel and initrd, use the following commands:

kernel /vmlinuz root=/dev/hda3
initrd /initrd.img
NOTE: If your root is not /dev/hda3, you will need to replace that with the apprpriate drive/parition.

Now you can boot your system by typing:boot

Leave a Reply

Your email address will not be published. Required fields are marked *