How to re-install grub???

Posted by Md. Mahidul Hasan on 3:08 AM with No comments
How to re-install grub???
---------------------------------------

1.  First find the partition which contains the /boot directory
grub> find  /boot/grub/stage1
  (hd0,4) 

or,
grub> find  /grub/stage1
  (hd0,4) 

2.  Execute the root command to find "/boot" partition
grub> root
  (hd0,4)

grub> root (hd0,4)
 Filesystem is type ext2fs, partition type 0x83

3.  Lets re-install Grub to a partition boot sector
grub> setup  (hd0,4)

4. Now restart the server-
grub> reboot

5. After restarting your server will get a grup menu but still it may not open. If it happens follow the below steps-
    - Press "e" from the grup menu where it says (hd0,1)
    - Now change to (hd0,4) and press "b" for boot.

6. It should start the OS. But to make this entry permanent edit the grub.conf as below-

[root@mahidul ~]# vim /etc/grub.conf
# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE:  You have a /boot partition.  This means that
#          all kernel and initrd paths are relative to /boot/, eg.
#          root (hd0,6)
#          kernel /vmlinuz-version ro root=/dev/sda9
#          initrd /initrd-[generic-]version.img
#boot=/dev/sda

default=0
timeout=5
splashimage=(hd0,4)/grub/splash.xpm.gz
hiddenmenu
title CentOS (2.6.32-220.el6.x86_64)
        root (hd0,4)
        kernel /vmlinuz-2.6.32-220.el6.x86_64 ro root=UUID=cd9be899-3467-4601-a6a7-b5a5774d7a55 rd_NO_LUKS rd_NO_LVM LANG=en_US.UTF-8 rd_NO_MD quiet SYSFONT=latarcyrheb-sun16 rhgb crashkernel=auto  KEYBOARDTYPE=pc KEYTABLE=us rd_NO_DM
        initrd /initramfs-2.6.32-220.el6.x86_64.img
title Other
        rootnoverify (hd0,0)
        chainloader +1


Thats it. Restart the server. It should works properly now. shue !!! big relief. :D