Tips Linux Explorers   All Things Linux Forum   Great Linux Links   Hometown    

GRUB ( The Grub bootloader )

There are people that like Lilo and there are people that like the Grub bootloader. I have written many Tips about Lilo, so here is to balance out the information: “all you always wanted to know about Grub”.

To restore Grub to the MBR:

$ su
< password >
# grub-install /dev/hda

To setup Grub or add new entries:


QUOTE (Info @ Grub)
Grub uses its own naming structure for drives and partitions, in the form of (hdn,m), where n is the hard drive number, and m the partition number, both starting from zero. This means, for instance, that partition hda1 is (hd0,0) to Grub, and hdb2 is (hd1,1). Grub doesn't consider CD-ROM drives to be hard drives, so if you have a CD on hdb, for example, and a second hard drive on hdc, that second hard drive would still be (hd1).


QUOTE (Info @ Grub)
Note that GRUB does _not_ distinguish IDE from SCSI - it simply counts the drive numbers from zero, regardless of their type. Normally, any IDE drive number is less than any SCSI drive number, although that is not true if you change the boot sequence by swapping IDE and SCSI drives in your BIOS.

Setup Grub:

# grub

First, tell Grub where to find the 'stage files' -- you can use Tab to show the alternatives: ( in this example hda4 )

root (hd0,3)

Now tell Grub to install into the MBR of hda:

setup (hd0)

And close with:


Make or adapt the menu.lst: ( And new entries )

# vi /boot/grub/menu.lst

QUOTE (Text @ Screen)

# Begin /boot/grub/menu.lst

# By default boot the first menu entry.
default 0

# Allow 30 seconds before booting the default.
timeout 30

# Use prettier colors.
color green/black light-green/black

# The first entry is for Linux.
title Linux
root (hd0,3)
kernel /boot/vmlinuz root=/dev/hda4 ro

# If you want, a second entry for RedHat
title RedHat
root (hd0,2)
kernel /boot/kernel-2.4.20 root=/dev/hda3 ro
initrd /boot/initrd-2.4.20

# You wish to include Windows ?
title Windows
rootnoverify (hd0,0)
chainloader +1


If things go really wrong and you get only a grub prompt you can still boot . . . .
For Windows:

grub> root noverify (hd0,0)
grub> chainloader +1
grub> boot

For Linux ( on hda4 like in example above ):

grub> root (hd0,3)
grub> kernel /boot/vmlinuz root=/dev/hda4 ro
grub> boot

Well, this was more or less all I can tell you on Grub. More info:

See also Jasons post "What to do when you get the GRUB prompt" Here


-- Dec 30 2003 ( Revised Dec 12 2005 ) --

Tips Linux Explorers   All Things Linux Forum   Great Linux Links   Hometown