A lot of times we loose GRUB from the MBR of the hard-disk, for a lot different causes, like file-system damage, Microsoft Windows eating it up and etc. Many people try to reinstall the full GNU+Linux distro as a solution to this. Here is the normal method how you can restore your grub boot-loader into your MBR or in your Partition. Read on.


[tweetmeme source=”phoxis”]
Please note this guide is written for GRUB version less than 2.0 .

  1. First you need a rescue CD\DVD or LiveCD/DVD of any GNU+Linux distro. You should have the installation DVD of the distro you are using, so you can use that. Select the rescue mode from the installation DVD menu, or boot any GNU+Linux LiveCD OS. Then run:
    grub
    

    Now you are in the GRUB prompt. If you have booted into a liveCD session then you will need root permission for the above command, so log into super user first by executing su

  2. Now you need to find out which BIOS drive you have the boot-loader files. You can do this by executing the following in the GRUB prompt:
    find /boot/grub/stage1
    

    You should have the GRUB’s stage1 file if you have GRUB installed in some partition. This will locate the BIOS drive(s) in which, the file stage1 is present. Note down the BIOS drive. If you have more than one GRUB in your HDD then decide which one to use and note that down. It will be in the format (hd?,?) . Where the ‘?’ are numbers. Like for me it shows (hd0,2) and (hd0,5) as i have two partitions with GRUB (O_o).

    Note: if you don’t find any such partition, then GRUB files are destroyed/removed and you need to reinstall GRUB with grub-install utility. Read this post to know how to install GRUB freshly

  3. Now set the BIOS drive as root by executing the following in the GRUB prompt.
    root (hd?,?)
    

    Replace the ‘?’ (question marks) with appropriate values that you got in the previous command. If you do not have any files in any of your partitions, in case the partition was formatted or the files were removed, or you are just installing GRUB first time, then you need to replace the ‘?’ (question marks) with the proper bios drive. For example /dev/sda1 is generally mapped to (hd0,0) /dev/sdb1 is to (hd1,0) /dev/sdc5 is into (hd0,4) etc. So enter the appropriate value.

  4. At last execute the following to install GRUB in MBR of the disk in the GRUB prompt:
    setup (hd?)
    

    Or To install GRUB in the Partition’s first sector, execute the following.

    setup (hd?,?)
    

    If you install GRUB in the Partition then you can ‘chainload’ that GRUB installation from another GRUB or some other bootloader.

  5. Then type the below command in the GRUB shell to exit from it.
    quit
    

And GRUB is restored.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s