by pbharris (Transferred from the wiki by Peter)

Updated March 30, 2004

This Plain English Tutorial(PET) will give a bit of a background on GRUB, how to install it and most of all how to boot into a certain mode (e.g. single user mode) when the arises. Ths PET will assume you have your OSes install on the first hard drive in an IDE system, e.g. /dev/hda, although it should not matter what device you have it installed on.

What is GRUB?? Well it is certainly not a larve hanging out on your hard drive, GRUB is GNU's GRand Unified Bootloader which has a few advantages over over bootloaders, it can read file systems like ext2 and when changing something you can edit a single file and have not have to issue any commands. GRUB has its own commands mode, you enter commands at the GRUB prompt and can get some information.

Getting Grub Okay! You have not even installed the binaries for GRUB!! If you have already installed GRUB by some method, like during the install of a distrution which includes GRUB then you can skip to Step Two, else go ahead install GRUB, you should be able to find a binary package for debian or redhat based systems. If source is the way for you to go grab off the code from here and install the software. To open the package do a tar -zxvf grub-x.xx.tar.gz and check out the documentation in the new grub-x.xx directory. Install GRUB and lets get going.

Installing GRUB Alrightty, you have installed GRUB and you are ready to have it be your new bootloader, for this PET lets assume the files needed have been installed into the directory /boot/grub. There should be several files which are in the GRUB directory, of these the one which will determine what GRUB will boot up, this is the file grub.conf. There may be a link from a file called menu.lst to grub.conf, this provides a menu for GRUB. Here is an example grub.conf file from a RedHat 7.3 machine, the menu.lst file also exists simply as a link to grub.conf:
# grub.conf generated by anaconda
# Note that you do not have to rerun grub after making changes to this file
# NOTICE: You do not have a /boot partition. This means that
# all kernel and initrd paths are relative to /, eg.
# root (hd1,0)
# kernel /boot/vmlinuz-version ro root=/dev/hdb1
# initrd /boot/initrd-version.img
title 2.4.18
root (hd1,0)
kernel /boot2418/vmlinuz ro root=/dev/hdb1 hdd=ide-scsi hdc=ide-scsi
initrd /boot2418/initrd-2.4.18.img
title Red Hat Linux (2.4.18-3)
root (hd1,0)
kernel /boot/vmlinuz-2.4.18-3 ro root=/dev/hdb1 hdd=ide-scsi hdc=ide-scsi
initrd /boot/initrd-2.4.18-3.img
title win
rootnoverify (hd0,0)
chainloader +1
This file will boot three differnt systems, a custom linux kernel, the default Red Hat linux kernel and another operating system. , in this case Microsoft Windows 95. Here the hard drive designations are different from other systems you may have encountered, here is a table of designations:

Drive GRUB Linux Microsoft Master on primary IDE channel (hd0) /dev/hda C:\ Slave on primary IDE Channel (hd1) /dev/hda C:\ Master on secondary IDE Channel (hd2) /dev/hdc E:\ Slave on secondary IDE channel (hd3) /dev/hdd F:\ Floppy Drive (fd0) /dev/fd0 A:\
This assumes for Microsoft based systems there is only one parition per drive. Also, for those of you with SCSI drives there is no special designation between IDE or SCSI device, if you have a SCSI drive the first drive would be hd0 also.

This example also has options passed to the kernel, unlike LILO which requires the word append GRUB simply has options listed after the kernel listed - but on the same line. The line in the example GRUB file has the options to use SCSI emulation for two hard drives.
kernel /boot/vmlinuz-2.4.18-3 ro root=/dev/hdb1 hdd=ide-scsi hdc=ide-scsi
Okay, it is time to install it. Lets install grub to the MBR of the first hard drive. Lets asssume that there is a and operating system to be loaded on the first hard drive one the first partition, this will be (hd0,0). Okay, lets say there is another operating system on the second hard drive's and for some reason it is located on the 3rd partition, it would be labeled like (hd1,2). The bootloader, i.e. grub, is to be installed on the MBR (Main Boot Record) of the drive thats boots up, in this case and most case this is hd0. The grub.conf and menu.lst files are in the directory /boot/grub We would type:
grub-install --root-directory=/boot/grub /dev/hda
If we want to make an boot floppy with grub on it we would do a:
grub-install /dev/fd0
There are many more options for GRUB installations. An excellent read installed on you computer already if you have GRUB installed is
info grub

Using GRUB! Okay - you have an option of booting two operating systems. They appear in the menu and all seems well. But you wish to pass in certian parameters to the kernel or perhaps you need to but into another run level. To boot into sigle user mode select the image you wish to boot from the grub boot menu and type e for edit. You will then need to add the word single or the number 1 after the name of the kernel you wish to boot with the other parameters to be passed in. If wish to boot to another runlevel then add the number of the runlevel you wish to boot to, e.g. 3 Then type b and you will be booted into the runlevel you specify.

Command Mode To get into command mode hit c when the grub menu shows up You will be taken to the grun command prompt. From here you have many options to choose from. Some of the more frequently used ones are: kernel With this command you can select a boot image.
boot Boot the aforementioned image.
help Get help on the commnads that can be used in GRUB.

Much more inforation on grub can be found here:

Any comments, errors or additions can be be emailed to me or feel free to private message me.