How to resotre MBR for GRUB?

There are several reasons that you would like to fix your Master Boot Record (MBR). And may be one of those is same as mine, overwritten by Microsoft Windows during re-installation.


Steps:

  1. Boot from CD/DVD and get into rescue mode of find a Linux live CD
  2. Check grub.conf, usually is in /boot/grub or /grub, depends on distribution. [sourcecode language=’css’]
    default=1
    timeout=5
    splashimage=(hd0,5)/boot/grub/splash.xpm.gz
    hiddenmenutitle Fedora (2.6.23.9-85.fc8)
    root (hd0,5)  kernel /boot/vmlinuz-2.6.23.9-85.fc8 ro root=LABEL=/ rhgb quiet  initrd /boot/initrd-2.6.23.9-85.fc8.img title Microsoft Windows XP  rootnoverify (hd0,0)  chainloader +1[/sourcecode]
  3. Write to MBR
    First, get into GRUB shell

    [sourcecode language=’css’]  [[email protected] ~]$ grub  [/sourcecode]

    Then you have to find which partition is installed with your “grub” directory, if you don’t konw:

    [sourcecode language=’css’] grub> find /boot/grub/stage1[/sourcecode]

    if,