Tuesday, November 11, 2008

Restore Grub

I am using Linux for more than 4 years but never used Grub command line to restore grub. I have used Puppy Linux Live CD GUI to restore Grub. Today I decided to use Grub command line.
$ sudo grub
[ Minimal BASH-like line editing is supported. For
the first word, TAB lists possible command
completions. Anywhere else TAB lists the possible
completions of a device/filename. ]

grub> find /boot/grub/stage1
(hd0,2)
(hd0,5)

grub>
root (hd0,5)

grub> setup (hd0)
Checking if "/boot/grub/stage1" exists... yes
Checking if "/boot/grub/stage2" exists... yes
Checking if "/boot/grub/e2fs_stage1_5" exists... yes
Running "embed /boot/grub/e2fs_stage1_5 (hd0)"... 16 sectors are embedded.
succeeded
Running "install /boot/grub/stage1 (hd0) (hd0)1+16 p (hd0,5)/boot/grub/stage2
/boot/grub/menu.lst"... succeeded
Done.

grub> quit
$
There is Ubuntu Intrepid Ibex installed on (hd0,5) and I installed OzOS (Ubuntu variant using E17 Desktop) on (hd0,2) which overwrote the MBR. Now I want to format (hd0,2) but if I do it without setting up the Grub's MBR pointing to (hd0,5) my system would become un-bootable.

By the command root (hd0,5) I have told Grub to use the menu.lst of (hd0,5) while setting up.

Simple, isn't it, only three commands:
grub> find /boot/grub/stage1
grub> root (hd0,X)
grub> setup (hd0)
Now suppose I want to boot OzOS installed on (hd0,2) I can edit menu.lst on (hd0,5) and make an entry to boot it but I decided to use some other way which is not commonly used to boot Linux.

$ sudo grub
grub> root (hd0,2)
grub> setup (hd0,2)
Checking if "/boot/grub/stage1" exists... yes
Checking if "/boot/grub/stage2" exists... yes
Checking if "/boot/grub/e2fs_stage1_5" exists... yes
Running "embed /boot/grub/e2fs_stage1_5 (hd0,2)"... failed (this is not fatal)
Running "embed /boot/grub/e2fs_stage1_5 (hd0,2)"... failed (this is not fatal)
Running "install /boot/grub/stage1 (hd0,5) /boot/grub/stage2 p /boot/grub/menu
.lst "... succeeded
Done.

grub> chainloader +1
grub> boot
I have setup grub of (hd0,2) on the partition itself instead of MBR and edited menu.lst as follows:
title OzOS
root (hd0,2)
chainloader +1
When I select OzOS on grub installed on MBR it "chainloads" the bootloader installed on (hd0,2) which opens another boot menu (listing menu.lst of hda3).

1 comment:

Charan said...

Dear Kamalesh,

I would like to talk to you regarding building Linux Distro.

Can you please let me know your mail id to take it further.

With Best Regards,
Charan
scharanb@yahoo.com

Zero income tax on Capital Gain on sale of house property

We signed agreement to sale our flat in Delhi on 31st March 2025 and started house hunting in Bhopal online immediately on sites like 99acre...