Friday, April 15, 2011

Restore GRUB

GRUB is the default bootmanager in linux. It helps to choose the desired OS to boot on the booting stage.It shows a list of OS, so that we can choose anyone to boot. GRUB is so powerful that can understand the filesystem without booting the system.

The modern linux come with the latest GRUB and they recognize all the existing operating systems and add them into the list.

But the problem comes with the other OS like windowz. They dont believe that the system can have other OS too. They believe that they are the only OS in the earth.

In the dual boot machines, often the windows should be reinstalled because of various reasons. When we do the reinstallation of windows, it erases the GRUB which resides at MBR normally.

So, after re-installing windows, Most of newbies think that we have to re-install linux too. No. No. No. Linux never went out. It is safely in its partition only, until you deleted that partition.

Only the GRUB is washed out by windows. we can recover it easily.

Here are some ways to do it.

Needed Materials:
1. Any LiveCD or Live DVd like ubuntu, knoppix
or
The installation CD of your or any Distro.

Way – 1:

1. Pop in the Live CD, boot from it until you reach the desktop.

2. Open a terminal window or switch to a tty.

3. Type “grub”

4. Type “root (hd0,6)”, or whatever your harddisk + boot partition
numbers are (my /boot is at /dev/sda7, which translates to hd0,6 for
grub).

5. Type “setup (hd0)”, ot whatever your harddisk nr is.

6. Quit grub by typing “quit”.

7. Reboot.

Way -2:

1. Boot from a Live CD, like Ubuntu Live, Knoppix, Mepis, or similar.

2. Open a Terminal. Go SuperUser (that is, type “su”). Enter root passwords as necessary.

3. Type “grub” which makes a GRUB prompt appear.

4. Type “find /boot/grub/stage1″. You’ll get a response like “(hd0)” or
in my case “(hd0,3)”. Use whatever your computer spits out for the
following lines.

5. Type “root (hd0,3)”.

6. Type “setup (hd0)”. This is key. Other instructions say to use
“(hd0)”, and that’s fine if you want to write GRUB to the MBR. If you
want to write it to your linux root partition, then you want the number
after the comma, such as “(hd0,3)”.

7. Type “quit”.

8. Restart the system. Remove the bootable CD.

Way – 3:

1. Boot with any live CD (I’ve done it with Knoppix 3.x and Ubuntu)

2. Get a root shell and make a folder (mkdir ubuntu)

3. mount the root (/) partition of ubuntu (e.g. mount /dev/hdb ubuntu if you have two disks)

4. chroot the mounted partition (chroot ubuntu)

5. grub-install /dev/hda

5. Exit the shell

6. Reboot

Try any of the three ways.

There may be also so many ways to do this same thing. Try yourself and keep learning.

No comments:

Post a Comment