GRUB (Grand Unified Bootloader) comprises two stages. stage1 consists of 512 bytes and its only task is to load the second stage of the boot loader. Subsequently, stage2 is loaded. This stage contains the main part of the boot loader.
In some configurations, an intermediate stage 1.5 can be used, which locates and loads stage 2 from an appropriate file system. If possible, this method is chosen by default on installation or when initially setting up GRUB with YaST.
stage2 is able to access many file systems. Currently, Ext2, Ext3, ReiserFS,
Minix, and the DOS FAT file system used by Windows are supported. To a
certain extent, JFS, XFS, and UFS and FFS used by BSD systems are also
supported. Since version 0.95, GRUB is also able to boot from a CD or DVD
containing an ISO 9660 standard file system pursuant to the “El
Torito” specification. Even before the system is booted, GRUB can
access file systems of supported BIOS disk devices (floppy disks or hard
disks, CD drives, and DVD drives detected by the BIOS). Therefore, changes
to the GRUB configuration file (
menu.lst) do not
require a reinstallation of the boot manager. When the system is booted,
GRUB reloads the menu file with the valid paths and partition data of the
kernel or the initial RAM disk (
initrd) and locates these
The actual configuration of GRUB is based on three files that are described below:
This file contains all information about partitions or operating systems that can be booted with GRUB. Without this information, the GRUB command line prompts the user for how to proceed (see Section 18.104.22.168, “Editing Menu Entries during the Boot Procedure” for details).
This file translates device names from the GRUB and BIOS notation to Linux device names.
This file contains the commands, parameters, and options the GRUB shell needs for installing the boot loader correctly.
GRUB can be controlled in various ways. Boot entries from an existing
configuration can be selected from the graphical menu (splash screen). The
configuration is loaded from the file
In GRUB, all boot parameters can be changed prior to booting. For example,
errors made when editing the menu file can be corrected in this way. Boot
commands can also be entered interactively at a kind of input prompt (see
Section 22.214.171.124, “Editing Menu Entries during the Boot Procedure”). GRUB offers the possibility of
determining the location of the kernel and the
prior to booting. In this way, you can even boot an installed operating
system for which no entry exists in the boot loader configuration.
GRUB actually exists in two versions: as a boot loader and as a normal
Linux program in
/usr/sbin/grub. This program is
referred to as the GRUB shell. It provides an
emulation of GRUB in the installed system and can be used to install
GRUB or test new settings before applying them. The functionality to
install GRUB as the boot loader on a hard disk or floppy disk is integrated in
GRUB in the form of the commands install and
setup. This is available in the GRUB shell when Linux
The graphical splash screen with the boot menu is based on the GRUB
/boot/grub/menu.lst, which contains
all information about all partitions or operating systems that can be
booted by the menu.
Every time the system is booted, GRUB loads the menu file from the file system. For this reason, GRUB does not need to be reinstalled after every change to the file. Use the YaST boot loader to modify the GRUB configuration as described in Section 9.3, “Configuring the Boot Loader with YaST”.
The menu file contains commands. The syntax is very simple. Every line
contains a command followed by optional parameters separated by spaces like
in the shell. For historical reasons, some commands permit an
= in front of the first parameter. Comments are
introduced by a hash (
To identify the menu items in the menu overview, set a
title for every entry. The text (including any spaces)
following the keyword
title is displayed as a selectable
option in the menu. All commands up to the next
are executed when this menu item is selected.
The simplest case is the redirection to boot loaders of other operating
systems. The command is
chainloader and the argument is
usually the boot block of another partition in GRUB block notation. For
The device names in GRUB are explained in Section 126.96.36.199, “Naming Conventions for Hard Disks and Partitions”. This example specifies the first block of the fourth partition of the first hard disk.
Use the command
kernel to specify a kernel image. The
first argument is the path to the kernel image in a partition. The other
arguments are passed to the kernel on its command line.
If the kernel does not have built-in drivers for access to the root
partition or a recent Linux system with advanced hotplug features is used,
initrd must be specified with a separate GRUB
command whose only argument is the path to the
file. Because the loading address of the
written to the loaded kernel image, the command
must follow immediately after the
root simplifies the specification of kernel
and initrd files. The only argument of
root is a device
or a partition. This device is used for all kernel,
initrd, or other file paths for which no device is
explicitly specified until the next
boot command is implied at the end of every menu
entry, so it does not need to be written into the menu file. However, if
you use GRUB interactively for booting, you must enter the
boot command at the end. The command itself has no
arguments. It merely boots the loaded kernel image or the specified chain
After writing all menu entries, define one of them as the
default entry. Otherwise, the first one (entry
0) is used. You can also specify a time-out in seconds
after which the default entry should boot.
default usually precede the menu entries. An example
file is described in Section 188.8.131.52, “An Example Menu File”.
The naming conventions GRUB uses for hard disks and partitions differ
from those used for normal Linux devices. In GRUB, the numbering of the
partitions starts with zero. This means that (
is the first partition of the first hard disk. On a common desktop machine
with a hard disk connected as primary master, the corresponding Linux
device name is
The four possible primary partitions are assigned the partition numbers
3. The logical partitions are
(hd0,0) first primary partition of the first hard disk (hd0,1) second primary partition (hd0,2) third primary partition (hd0,3) fourth primary partition (usually an extended partition) (hd0,4) first logical partition (hd0,5) second logical partition
Being dependent on BIOS devices, GRUB does not distinguish between IDE, SATA, SCSI, and hardware RAID devices. All hard disks recognized by the BIOS or other controllers are numbered according to the boot sequence preset in the BIOS.
Unfortunately, it is often not possible to map the Linux device names to
BIOS device names exactly. It generates this mapping with the help of an
algorithm and saves it to the file
can be edited if necessary. Information about the file
device.map is available in Section 9.2.2, “The File device.map”.
A complete GRUB path consists of a device name written in parentheses and the path to the file in the file system in the specified partition. The path begins with a slash. For example, the bootable kernel could be specified as follows on a system with a single IDE hard disk containing Linux in its first partition:
The following example shows the structure of a GRUB menu file. The
example installation has a Linux boot partition under
/dev/hda5, a root partition under
/dev/hda7, and a Windows installation under
gfxmenu (hd0,4)/message color white/blue black/light-gray default 0 timeout 8 title linux kernel (hd0,4)/vmlinuz root=/dev/hda7 vga=791 initrd (hd0,4)/initrd title windows chainloader(hd0,0)+1 title floppy chainloader(fd0)+1 title failsafe kernel (hd0,4)/vmlinuz.shipped root=/dev/hda7 ide=nodma \ apm=off acpi=off vga=normal nosmp maxcpus=0 3 initrd (hd0,4)/initrd.shipped
The first block defines the configuration of the splash screen:
The background image
message is located in
Color scheme: white (foreground), blue (background), black (selection), and light gray (background of the selection). The color scheme has no effect on the splash screen, only on the customizable GRUB menu that you can access by exiting the splash screen with Esc.
The first menu entry
title linux is the one to boot
After eight seconds without any user input, GRUB automatically boots
the default entry. To deactivate automatic boot, delete the
timeout line. If you set
0, GRUB boots the default entry immediately.
The second and largest block lists the various bootable operating systems.
The sections for the individual operating systems are introduced by
The first entry (
title linux) is responsible for
booting SUSE Linux. The kernel (
vmlinuz) is located
in the first logical partition (the boot partition) of the first hard
disk. Kernel parameters, such as the root partition and VGA mode, are
appended here. The root partition is specified according to the Linux
naming convention (
/dev/hda7/), because this
information is read by the kernel and has nothing to do with GRUB. The
initrd is also located in the first logical partition
of the first hard disk.
The second entry is responsible for loading Windows. Windows is booted
from the first partition of the first hard disk
hd0,0). The command
+1 causes GRUB to read and execute the first sector of the
The next entry enables booting from floppy disk without modifying the BIOS settings.
The boot option
failsafe starts Linux with a
selection of kernel parameters that enables Linux to boot even on
The menu file can be changed whenever necessary. GRUB then uses the modified settings during the next boot. Edit the file permanently using YaST or an editor of your choice. Alternatively, make temporary changes interactively using the edit function of GRUB. See Section 184.108.40.206, “Editing Menu Entries during the Boot Procedure”.
In the graphical boot menu, select the operating system to boot with the arrow keys. If you select a Linux system, you can enter additional boot parameters at the boot prompt. To edit individual menu entries directly, press Esc to exit the splash screen and get to the GRUB text-based menu then press E. Changes made in this way only apply to the current boot and are not adopted permanently.
|Keyboard Layout during the Boot Procedure|
The US keyboard layout is the only one available when booting.
Editing menu entries facilitates the repair of a defective system that can no longer be booted, because the faulty configuration file of the boot loader can be circumvented by manually entering parameters. Manually entering parameters during the boot procedure is also useful for testing new settings without impairing the native system.
After activating the editing mode, use the arrow keys to select the menu entry of the configuration to edit. To make the configuration editable, press E again. In this way, edit incorrect partitions or path specifications before they have a negative effect on the boot process. Press Enter to exit the editing mode and return to the menu. Then press B to boot this entry. Further possible actions are displayed in the help text at the bottom.
To enter changed boot options permanently and pass them to the kernel,
open the file
menu.lst as the user
root and append the respective kernel
parameters to the existing line, separated by spaces:
title linux kernel (hd0,0)/vmlinuz root=/dev/hda3 additional parameter initrd (hd0,0)/initrd
GRUB automatically adopts the new parameters the next time the system is booted. Alternatively, this change can also be made with the YaST boot loader module. Append the new parameters to the existing line, separated by spaces.
device.map maps GRUB and BIOS device names to
Linux device names. In a mixed system containing IDE and SCSI hard disks,
GRUB must try to determine the boot sequence by a special procedure,
because GRUB may not have access to the BIOS information on the boot
sequence. GRUB saves the result of this analysis in the file
/boot/grub/device.map. For a system on which the boot
sequence in the BIOS is set to IDE before SCSI, the file
device.map could appear as follows:
(fd0) /dev/fd0 (hd0) /dev/hda (hd1) /dev/sda
Because the order of IDE, SCSI, and other hard disks depends on various
factors and Linux is not able to identify the mapping, the sequence in the
device.map can be set manually. If you encounter
problems when booting, check if the sequence in this file corresponds to
the sequence in the BIOS and use the GRUB prompt to modify it temporarily
if necessary. After the Linux system has booted, the file
device.map can be edited permanently with the YaST
boot loader module or an editor of your choice.
Depending on the controller, SATA disks are either recognized as IDE
After manually changing
device.map, execute the
following command to reinstall GRUB. This command causes the file
device.map to be reloaded and the commands listed in
grub.conf to be executed:
grub --batch < /etc/grub.conf
The third most important GRUB configuration file after
/etc/grub.conf. This file contains the commands,
parameters, and options the GRUB shell needs for installing the boot
root (hd0,4) install /grub/stage1 (hd0,3) /grub/stage2 0x8000 (hd0,4)/grub/menu.lst quit
Meaning of the individual entries:
This command tells GRUB to apply the following commands to the first logical partition of the first hard disk (the location of the boot files).
The command grub should be run with the parameter
stage1 of the boot
loader should be installed in the the extended partition container
should be loaded to the memory address 0x8000 (
0x8000). The last entry
(hd0,4)/grub/menu.lst) tells GRUB where to look
for the menu file.
Even before the operating system is booted, GRUB enables access to file systems. Users without root permissions can access files in your Linux system to which they have no access once the system is booted. To block this kind of access or prevent users from booting certain operating systems, set a boot password.
|Boot Password and Splash Screen|
If you use a boot password for GRUB, the usual splash screen is not displayed.
As the user
root, proceed as follows to set a boot
At the root prompt, enter grub.
Encrypt the password in the GRUB shell:
grub> md5crypt Password: **** Encrypted: $1$lS2dv/$JOYcdxIn7CJk9xShzzJVw/
Paste the encrypted string into the global section of the file
gfxmenu (hd0,4)/message color white/blue black/light-gray default 0 timeout 8 password --md5 $1$lS2dv/$JOYcdxIn7CJk9xShzzJVw/
Now GRUB commands can only be executed at the boot prompt after pressing P and entering the password. However, users can still boot all operating systems from the boot menu.
To prevent one or several operating systems from being booted from the
boot menu, add the entry
lock to every section in
menu.lst that should not be bootable without
entering a password. For example:
title linux kernel (hd0,4)/vmlinuz root=/dev/hda7 vga=791 initrd (hd0,4)/initrd lock
After rebooting the system and selecting the Linux entry from the boot menu, the following error message is displayed:
Error 32: Must be authenticated
Press Enter to enter the menu. Then press P to get a password prompt. After entering the password and pressing Enter, the selected operating system (Linux in this case) should boot.