The Boot Manager Grub

Managers boot are software able to start the process loading of operating systems on a computer. For several reasons, it is common to find machines that have more an operating system installed. In these cases, the managers boot have a very important role, because it’s up to them to task allow the user the loading of one system or another. This the article will present and cover the main characteristics the GRUBa boot manager each time more used, mainly in installations that involve Linux.

THE GRUB

GRUB is the acronym for GRand Unifield Bootloader. This is a boot loader originally developed by Erich Stefan Boleyn, made available as software GNU. Among its key features is the ability to work with various operating systems, such as Linux, Windows, and the versions BSD, and consequently support for several file systems, as the ext2, ext3, reiserfs, FAT, FFS, etc.

One of the reasons most obvious to the GRUB being used is your ability to allow the user to choose one of the operating systems installed on your computer. In other words, GRUB is able to working with “multiboot”. In addition, this manager it is also able to “boot” systems on disks SCSI or even upload them through the available images in the network.

Installation of GRUB

Many Linux distributions allow the addition the GRUB on the computer during the installation of the system. In however, if you already have Linux installed on your machine, the installation of GRUB is not complicated (and usually should be done by a user with administrator privileges administrator).

Assuming that your system tell you with the feature of apt-get, give the following command:

apt-get install grub

When this process is complete, create a folder name grub in /boot , and then give the command update-grubto that the file menu.lst is created:

mkdir /boot/grub
update-grub

Done this, add the grub to the MBR (Master Boot Record) through the following command (be aware that the content the MBR will be erased if there is something already installed, for example, LILO):

grub-install /dev/hda

An alternative: the installation package of the GRUB also is available in the format tar.gz in ftp://alpha.gnu.org/gnu/grub. Assuming you downloaded the package grub-0.97.tar.gzyour installation it is done in the following manner:

tar xzvf grub-0.97.tar.gz

Then, in the directory where the package was unpacked (in this example, the grub-0.97) and type the commands:

./configure
make
make install

The next step is to type in grub in your terminal and the following command:

install (hd0,2)/boot/grub/stage1 (hd0) (hd0,2)/boot/grub/stage2 p (hd0,2)/boot/grub/menu.lst

It is convenient to check on the official website of your distribution or even in the documentation of this, guidelines about the installation of GRUB, as there may be details about this manager that will change according to the distribution.

The GRUB configuration

Generally, GRUB makes use of the file /boot/grub/menu.lstto define and load its configuration (an important detail: depending on the distribution, the GRUB can use another directory and another file name, such as grub.conf or menu.conf). In it, the first thing that catches your attention is your form working with hard disks of the computer. Instead refer to these devices as /dev/hda1, /dev/hda2, etc, he does so through the terms (hd0,0), (hd0,1) and so on. Note the table below for a better understanding:

GRUB calls the main hard drive of the computer hd0 (while the Linux the calls of hda). A secondary disk receives the name of hd1 (the Linux call it hdb), and so the following. For working with the partitions of the HD, the GRUB the references through a number inserted after a comma. Thus, the first partition has the number 0 (zero) – hd0,0 -, to the second partition is assigned the number 1 – hd0,1 – , and so on. It is important to to highlight that, in this case, GRUB does not distinguish between IDE and SCSI disks.

Now that you already know how GRUB treats disks in the machine, below follows, as an example, the content of a file menu.lst:

default 0
timeout 5
fallback 1
splashimage=(hd0,1)/grub/splash.xpm.gz

title Fedora Core (2.6.9-1.667)
root (hd0,1)
kernel /boot/vmlinuz-2.6.9-1.667 ro root=/dev/hda2
initrd /boot/initrd-2.6.9-1.667.img

title Windows XP
rootnoverify (hd0,0)
makeactive
chainloader +1

The first line – default 0 – tells GRUB which operating system initialize if the user does not make any choice. In the example, it will “boot” Fedora Linux, as the number 0 references to the first system listed in the file. If the Windows XP had to be loaded by default, you just need to change the line in question to default 1, since in the file this system is the second to be listed (note that the GRUB makes the list starting at zero).

The line filled with timeout 5 determines the time (in seconds) the user will have to choose an operating system to boot. So that the GRUB “comes into action”, it shows on the screen a list of installed operating systems. The user you may choose a switching-through of the arrow keys of the keyboard and pressing the Enter button when the choice is made. In the case of this example, the timeout receives the value 5. This means the user will have 5 seconds to choose a system. If no option is chosen, after the 5 seconds, GRUB will load the default system, as defined through the of the first line.

In turn, the third line (not always used) – fallback 1 – tells GRUB which system to boot if the loading of the first option fails for any reason. This feature is especially useful when there are more than two operating systems installed on the computer.

The fourth line simply contains information for to load the graphical settings (such as image fund) for when the GRUB display the operating system options available.

Notice that in the file menu.lst the list of operating systems is shown after the fourth-line setting.The first system in the list is Fedora Linux:

title Fedora Core (2.6.9-1.667)
root (hd0,1)
kernel /boot/vmlinuz-2.6.9-1.667 ro root=/dev/hda2
initrd /boot/initrd-2.6.9-1.667.img

The first line above shows the information that the system receives in GRUB. It is this name that will be displayed when GRUB show the list of operating systems that the user can choose. You can use any phrase after the title. Of course, tell something related to the operating system in question.

The second line is – root (hd0,1) – tells GRUB where the system the operating is installed. In the example, it is on the second HD partition. The word root has the function indicate that that is the primary system partition (or the partition-root) and that, therefore, should be mounted.

The third and the fourth line tell GRUB the kernel to be loaded and possible parameters. In this case, ro indicates that the partition should be mounted initially with permissions read-only.

In the part of the file that comes from Windows XP, the syntax is the same. However, the second line receives the parameter rootnoverify instead of root, since the mounting of the partition does not apply to Windows. The rootnoverify is used because this parameter does not try to do any assembly.

title Windows XP
rootnoverify (hd0,0)
makeactive
chainloader +1

How Windows works differently than Linux, the option loading the kernel also does not apply to the system of Microsoft. In place of this parameter, it is usually used chainloader +1, that “calls” the boot loader of the Windows, leaving to this the task of starting the system. Note that in our example, there are a parameter in the line above chainloader +1, makeactive. This has the function of setting the partition in question as active.

There is a parameter called map that allows you to upload Windows when this is not installed on the first HD (mandatory rule in Windows 9x, for example). Your use it is made in the following way (assuming Windows is on the second disk):

map (hd0) (hd1)
map (hd1) (hd0)

Other options

You must have already noticed that, basically, GRUB is divided into two parts: the first contains the settings general concerning the GRUB and the second part contains the list of operating systems installed on the machine. You it should also be noted that the filling of the information the second part will change according to the system.

In the first part, it is possible to add other parameters, among them, the password and the hidden menu. The first requests a password set by you for access to certain resources, as the command-line option in the GRUB syntax ( password password). The second simply hides the list of operating systems when the GRUB is loaded. This list can be visible by pressing the ESC key on the keyboard.

If you want to allow access to a specific system operating only through a password, simply enter the word lock after the line title for the system in question. In however, for this, it is necessary that the option password has been entered in the first part, as it is this password that will be requested:

title Windows XP
lock
rootnoverify (hd0,0)
(…)

If the use of another password is required, simply insert the field password password below the line title. In this case, the password request will only be made if the operating system in question is chosen:

title Windows XP
password abbreviationfinder
rootnoverify (hd0,0)
(…)

One last detail: is it possible to insert comments in the GRUB configuration file. To do this, simply add the character # before the comment line, for example:

#GRUB configuration file
default 0
timeout 5
fallback 1
(…)

Command line of GRUB

GRUB has a feature that is very interesting (and useful, especially to resolve problems in the loading of the operating system): a line of commands that can be accessed as soon as the GRUB is loaded.To do this, when GRUB is available, you can tighten a certain key (usually the C button) or choose this option in the list of operating systems. It all depends on the way the GRUB was set (GRUB usually invokes the command-line when not find the list of operating systems).

There are a number of resources that can be used on the line command of GRUB. When you are in it, press the Tab key of your the keyboard two times in a row to get the full list. For details about a specific command, type help command, for example:

help cmp

Ending

GRUB is a software capable of working with different systems operating, contains many resources and is even considered as a replacement for LILO.

The Boot Manager Grub 1