Tuesday, July 23, 2013

GRUB

To access and use your Linux system, you must carefully follow required start up and shut down procedures. You do not simply turn off and turn on your computer. If you have installed a boot loader, either GRUB or LILO(Linux Loader), when you turn on or reset your computer, the boot loader first decides what operating system to load and run. GRUB will display a menu of operating systems to choose, whereas LILO will display a command-line prompt.

The Grand Unified Bootloader (GRUB) is a multiboot boot loader. It is now the default boot loader used by Ubuntu, Red Hat systems and many more other operating system. GRUB offers extensive compatibility with a variety of operating system. Users can select operating systems to run from a menu interface displayed when a system boots up. Use arrow keys to move to an entry and press ENTER. Press e to edit a command, letting you change kernel arguments or specify a different kernel. The c command places you in a command line interface, GRUB can boot from anywhere on them. Use shell command “info grub” we can list detailed documentation of grub.

GRUB configuration is held in the /etc/grub.conf file. You only need to make your entries, and GRUB will automatically read them when you reboot. There are several options you can set such as the time out period and the background image to use. You can specify a system to boot by creating a title entry for it, beginning with the term title. You then have to specify where the operating system kernel or program is located, which hard drive and what partition on that hard drive. This information is listed in parenthesis following the root option. Numbering starts from 0, not 1, and hard drives are indicated with an hd prefix. So root(hd0,2) references the first hard drive (hda) and the third partition on that hard drive (hda3). For Linux systems, you will also have to use the kernel option to indicate the kernel program to run, using the full path name and any options the kernel may need. The Ram disk is indicated by the initrd option.
       title Ubuntu 11.04
       root (hd0,2) 
       kernel /boot/vmlinuz-2.4.7-10 ro root=/dev/hda3
       initrd /boot/initrd-2.4.7-10.img 

For another operating system such as Windows, you would use the root option to specify where Windows is installed. Use the “imakeative” and “chain-loader+1” options to allow GRUB to access it. Windows systems will all want to boot from the first partition on the first disk. This becomes a problem if you want to install several versions of Windows on different partitions or install Windows on a partition other than the first one. GRUB lets you work around this by letting you hide other partitions inline and then unhidden the one you want, making it appear to be the first partition. Use the rootnoverify command to allow the system to boot. 

A sample grub.conf file follows with entries for both Linux and Windows. Notice that kernel parameters are listed in the kernel option as arguments to the kernel.
/etc/g rub.conf
------------------------------------------------------------------------------------------------------
# grub.conf generated by anaconda
#
#boot=/dev/hda
default=0
timeout=30
splashimage=(hd0,2)/boot/grub/splash.xpm.gz
title Ubuntu 11.04
root (hd0,2)
kernel /boot/vmlinuz-2.4.7-10 ro root=/dev/hda3 hdc=ide-scsi
initrd /boot/initrd-2.4.7-10.img
title Windows XP
root (hd0,0)
imakeactive
chainloader +1 

No comments:

Post a Comment