Search This Blog

Thursday, November 9, 2017

GRUB

Configuration


The default loader for many Linux distributions, including enterprise Red Hat 5 and 6 , is GRUB (Grand Unified Bootloader). It is highly configurable, in particular by accepting encrypted password protection, using shell or graphics mode. It is configured with a text file and there is no need to reinstall GRUB with each change. Although replaced by GRUB2 in all distributions, do not think that GRUB has disappeared. There are strong chances, if you use Amazon EC2 instances on Linux, that the used boot loader is its first version, called "legacy".
Here is an example of a configuration file assuming that the first partition of the first disk is /boot, and that the second contains a Windows installation:

timeout=10
default=0
title Red Hat
    root (hd0,0)
    kernel /vmlinuz-2.6.12-15 ro root=LABEL=/
    initrd /initrd-2.6.12-15.img
title Windows XP
    rootnoverify (hd0,1)
    chainloader +1


Syntax: 

GRUB Parameter
Description
chainloader +1Start the first sector or the root specified above
default nDefault boot (0=first title, 1=second title, etc.)
gfx menuPath to graphic menu
initrdInitial ramdisk. The kernel will load this file in memory to find configuration details and initial drivers.
kernelName of the kernel image, folowed by its parameters. The / doesn't represent the file system root, but the one of (hd0,0), so /boot/vmlinuz...
root(hdx, y)All the file accesses will be from this partition (explained below). Here, hd0,0 represent the first partition of the first disk detected by the BIOS. It's the /boot partition
rootnoverifythe specified root, not mounted by GRUB (it doesn't support NTFS)
timeoutTimeout before default boot
title xxxxStart of a section, entry in GRUB menu

Installation

GRUB configuration can be found in /etc/grub.conf or /boot/grub/menu.lst (symbolic link). GRUB can be install on the MBR (Master Boot Record, 512 first bits of a disk) or PBR (Partition Boot Record, 512 first bits of a partistion).
To install or re-install GRUB - in case of a corrupted MBR, for example on /dev/sda -, use:
#/sbin/grub-install /dev/sda

Start and Edit

Options on the GRUB menu
  • e: edit the line ( adding parameters to the kernel or init)
  • d: delete a line
  • o: add a line
  • b: start the image
If you press Esc there are a grub interpreter available.

No comments:

Post a Comment