Jump to Navigation

128 - Installation of GRUB

GNU GRUB is a Multiboot boot loader. It was derived from GRUB, the GRand Unified Bootloader.
boot loader is the first software program that runs when a computer starts.
It is responsible for loadingand transferring control to the operating system kernel software.
A GRUB installation consist of at least two and sometimes three executables,

known as stages.

Stage1 --> the piece of GRUB that resides in the MBR or the boot sector of another partition or drive.

Stage1.5 --> It is loaded by Stage 1 only if the hardware requires it. Stage 1.5 is filesystem-specific.

Stage2 --> It runs the main body of the GRUB code.

< Install GRUB >

GRUB comes with a shell script, grub-install, which uses the GRUB shell
to automate the installation. The command syntax is:

# grub-install <option install-device>

(hd0,0)  --> First Hard Drive & First Partition
(hd1,2)  --> Second Hard Drive & Third Partition
(fd0)    --> floppy Drive
( * GRUB makes no distinction between IDE drives and SCSI drives.)

For example, under Linux the following will install GRUB into
the MBR of the first IDE disk:

# grub-install /dev/hda

This command installs GRUB into MBR of the first hard drive.
Likewise, under GNU/Hurd, this has the same effect:

# grub-install /dev/hd0

If it is the first BIOS drive, this is the same as well:

# grub-install '(hd0)'

Or you can omit the parentheses:

# grub-install hd0

But all the above examples assume that GRUB should use images under the root directory.
If you want GRUB to use images under a directory other than the root directory,
you need to specify the option "--root-directory=".
The typical usage is that you create a GRUB boot floppy with a filesystem.

Here is an example:

# mke2fs /dev/fd0
# mount -t ext2 /dev/fd0 /mnt
# grub-install --root-directory=/mnt fd0
# umount /mnt

Another example is when you have a separate boot partition which is mounted at /boot. Since GRUB is a boot loader,
it doesn't know anything about mountpoints at all. Thus, you need to run grub-install like this:

# grub-install --root-directory=/boot /dev/hda


Main menu 2

Story | by Dr. Radut