Friday, February 17, 2012

how to install or restore grub

Many times the grub installation on my system gets corrupted and my system refuse to startup with the error
GRUB ERROR 24

Error 24 : Attempt to access block outside partition

In this case I use to boot up with Live Knoppix CD or USB stick and restore grub installation using the following approaches:

(I have Knoppix Linux installed on the third partition of the first HDD and due to a failure in Disk Controller of my Acer Aspire laptop it is crashing the file system from time to time)

Solution 1 (to repair grub):

- run dmesg
If you see some disk related errors run fsck
run su
>umount -f /media/sda3
>fsck.reiserfs --rebuild-tree /dev/sda3
>mount /media/sda3

> sudo grub-install --recheck --no-floppy --root-directory=/media/sda3 hd0



Soluton 2 (to install fresh grub):

1. Open terminal and run sudo grub
2. run find /boot/grub/stage1
 The result would be something like : (hd0,2)
3. run root (hd0,2)
 The result should be something like : Filesystem type is reiserfs, partition type 0x83
4. run setup (hd0)
5. run quit and restart

Alternatively you can try to edit the /boot/grub/menu.lst file from /dev/sda3 (assuming your linux installation in on third partition of the first harddisk, else from /dev/sd<n><X>)