Tuesday, November 10, 2009

Grub Commands for restoring Grub

Hi All,

This post tells you how to install Grub, a.k.a Grand Unified Boot Loader, using the basic so called Grub commands[common man terminologies :)]

Points to Ponder:

1. Grub gets installed on usually by default on the MBR [master boot record] , or on any other partition as a matter of fact.
2. hda - This is called the MBR of a hdd [hard disk drive/device]
3. "h"da - the older hard disks with the IDE cables
4. "s"da - the newer serial ata hard disk.

Say you had installed - Karmic Koala [code name of Ubuntu 9.10 released on Oct 29th, 09]
On Oct 30th you installed the unsupported Windows XP. XP would erase your MBR.

Note that only your MBR is destroyed and your Ubuntu 9.10 setup is perfectly intact.

To restore GRUB of a single / partition Ubuntu 9.10 - installed on /dev/hda2.

1. Put any Live Linux CD. I would prefer simpler ones like Knoppix, DSL, System Rescue CD, Puppy Linux or any live cd including Ubuntu 9.10.
2. Open a terminal as root or being sudo to konsole.
3. cd to /boot/grub folder
4. Enter "grub"
5. This step 4 will open a prompt with "*grub>"
6. root (hd0,1) --- It is zero and not Oh [character O]
7. setup (hd0) --- It is zero and not Oh [character O]

Things to re-ponder:

1. Since it is hda - yours is an IDE based harddisk. Be careful - this plays differently in different distros. Best is to check your /dev/ folder.

2. Above step 6: It is "hd0,1" --- here since you have installed the GRUB to your MBR - in the maths terms of GRUB - a "hd'a'" is equivalent to "hd'0'"
[If it is hdb then it is hd1 ---> a=0,b=1...]

3. Above step 6: Since I had told earlier that the Ubuntu is installed as a single / partition in /dev/hda2 --- here since it is 2 - Grub terms it to a "1"
[If it is /dev/hda4 then it is 4-1=3, here 1=0,2=1 and etc]

4. In step 7 above - the same 2nd point of re-ponder works for the setup command. :)

Hope this is in detail. There is one more method of restoring the GRUB without using these commands which I will post it some time later.

Take care,
Ananth Gouri

No comments:

Post a Comment