SuSE Linux: Versions since 8.1
The main difference from LILO is that Grub directly supports several file systems
(including all file systems that can be used in SuSE Linux as well as vfat). Therefore it
is not necessary to reinstall Grub after the Grub configuration file is modified.
When the system is booted, Grub reads the contents of the menu file.
Even if a new kernel (/boot/vmlinuz) is installed or the initial ramdisk (/boot/initrd) is modified,
Grub will be able to find them by itself. Grub does not care about the physical position of the
kernel, as long as the partition and the path of the kernel to be booted is specified correctly
in the menu file. Therefore, the boot loader does not need to be reinstalled after procedures
such as the compilation of the kernel.
Another major advantage of Grub is the possibility to edit all boot parameters prior to booting. This is very useful in case errors crept into the menu file.
Furthermore, it is even possible to enter the boot commands in a sort of prompt. Thus, even operating systems for which no entry was made in the boot menu can be booted. Grub enables the specification of the position and the name of the kernel and the initrd prior to booting.
The following section provides a short summary of the Grub boot process and the configuration with YaST2. Additionally, the structure of the actual configuration file (the file /boot/grub/menu.lst) is explained. Furthermore, attention is drawn to the file /boot/grub/device.map, which contains the mapping of the mass storage devices to the BIOS device names, and the file /etc/grub.conf, which is mainly used by YaST2. The manual installation of Grub is also touched on briefly. The last part describes the possibilities of the Grub boot menu.
Following the installation of SuSE Linux, the first stage of Grub is saved in the MBR, in the boot sector of a hard disk partition, or in the boot sector of a floppy disk. The first stage must be very small, since the MBR or the boot sectors only have limited space. Therefore, the only task of this component is to load the second stage of Grub.
The second stage of Grub provides the actual boot loader functions, including the selection menu (as well as the hidden Grub shell; see below) and the program code that transfers the system control to the operating system. In SuSE Linux, the stage 2 file is located under /boot/grub/stage2. When the boot loader is installed, the physical location of stage 2 on the hard disk is entered in the stage 1 file.
Usually, the parameters only need to be modified in the event of an emergency, for instance if an operating system can not be booted. The modifications only apply this time and will not be adopted permanently.
In order to edit a menu entry, first press ESC. Then select the entry you want to modify with the cursor keys and press "e". If, for example, you selected the "Linux" entry, the following lines will be displayed:
kernel (hd0,4)/vmlinuz root=/dev/hda7 vga=791 initrd (hd0,4)/initrdSelect a line with the cursor keys. Press "e" once more to edit the line. In this way you can correct things such as the partition and path specifications. Press Enter to return to the menu, from where you can boot the entry with "b". Additional possibilities are displayed in a help text at the bottom of the screen.
Another possibility for experts, which however is only needed once in a while: by pressing "c" (for "command line"), you can enter the Grub shell, which is a kind of input prompt. Enter "help" to view a list of available commands. Press "ESC" to return to the boot menu.
Using the Grub shell, you can boot operating systems that are not included in the Grub menu. This option is very useful if you want to test a self-compiled kernel for which no entry was made in the Grub menu.
In order to boot a system with the Grub Shell, commands such as the following can be entered manually (in this example for booting a Linux system with the boot partition /dev/hda5 and the root partition /dev/hda7):
grub> kernel (hd0,4)/vmlinuz root=/dev/hda7 vga=791 [Linux-bzImage, setup=0x1400, size=0xe9a45] grub> initrd (hd0,4)/initrd [Linux-initrd @ 0x369000, 0x863c9 bytes] grub> bootThe syntax can be seen in the file /boot/grub/menu.lst on your system. More information is provided in the section "The Menu File" further below. Important: When you are finished, do not forget to enter "boot" to start the system.
A practical hint: Since Grub can directly access the Linux file system when booting the system, the TAB key can be used to autocomplete file names (as in the bash). This is quite useful e.g. if you do not know the exact file name. Another useful feature: If you do not know in which partition the Linux kernel is located, you can search for the kernel with the following commands:
find /boot/vmlinuzor
find /vmlinuzIn our example, these commands would produce the following output:
(hd0,4)Of course you can also use the command find to search for any other file (such as the initrd).
Furthermore, you can even view the contents of individual files with the command cat. For example, you can view the contents of a Grub configuration file or any other file. Even files that cannot be accessed in the running system by Linux users without root permissions can be viewed!
Since this is not always desirable from the security standpoint, a password can be set in the file /boot/grub/menu.lst. In this way, operating systems can still be booted from the menu, but the interactive options ("e" and "c") are protected against unauthorized use. These will only be released after pressing "p" and entering the password. In order to set a password, please refer to the section Configuring Grub with YaST2.
Press Next to proceed to a dialog that enables you to configure the timeout for the boot prompt and set a password for Grub. Please note that this password protects the execution of special Grub commands at the boot prompt. It does not affect the selection of operating systems (more information on special Grub commands at the boot prompt is presented in the section "Possibilities of the Grub Boot Menu" further below in this article).
Additional options are available under Expert settings.
Press Next to proceed to the configuration of the sections table. Each section represents an entry in the boot menu. You can add or delete sections and determine a default section. Press Edit to rename a section or modify kernel parameters (under Expert settings).
Press Next to return to the configuration of the sections.
Select Save current configuration and press Finish in order to save the modifications to the hard disk.
Under Expert manual configuration, you can manually edit the Grub configuration files /boot/grub/menu.lst and /etc/grub.conf. More information on this issue is presented in the following sections.
Select Restore original configuration in order to restore the settings proposed during the installation.
Examples:
(fd0) Floppy disk drive (hd0) First hard disk in the system (the boot hard disk) (hd1) Second hard disk (hd0,0) First partition on the first hard disk
The partition numbers 0 to 3 represent the four primary partitions. Logical partitions are numbered from 4:
(hd0,0) First primary partition on the first hard disk (hd0,1) Second primary partition (hd0,2) Third primary partition (hd0,3) Extended partition (hd0,4) First logical partition (hd0,5) Second logical partition (hd0,6) Third logical partition etc.
Another important point: When assigning hard disk labels, Grub does not distinguish between IDE, SCSI, or other devices. All hard disks detected by the BIOS or other controllers (SCSI, RAID, etc.) are numbered according to the boot sequence. (hd0,0) is always the first hard disk in the boot sequence set in the BIOS, regardless of the type (IDE, SCSI, or RAID).
Example: In a system with two IDE hard disks and two SCSI hard disks, the boot sequence in the BIOS is set as "IDE before SCSI". Thus, Grub will use the following labels:
(hd0) First IDE hard disk (hd1) Second IDE hard disk (hd2) First SCSI hard disk (hd3) Second SCSI hard disk
For more details please refer to the section "The Map File".
gfxmenu (hd0,4)/message color white/green black/light-gray default 0 timeout 8 title linux kernel (hd0,4)/vmlinuz root=/dev/hda7 vga=791 initrd (hd0,4)/initrd title windows root (hd0,0) makeactive chainloader +1 title floppy root (fd0) chainloader +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 entries have the following meaning:
For more specific information on booting DOS/Windows operating systems please refer to the articles "Booting Windows from the Second HD" (http://sdb.suse.de/en/sdb/html/fhassel_grub_win1.html) and "Booting Multiple Windows Installations from One Hard Disk" (http://sdb.suse.de/en/sdb/html/fhassel_grub_win2.html).
Let us return to the subject of how Grub numbers the hard disks in a mixed system. In a system in which hard disks are connected to different controllers (e.g. if both IDE hard disks and SCSI hard disks are used), Grub attempts to determine the boot sequence with a special procedure (as Grub is not able to peer into the BIOS). Instead, Grub must calculate whether the system is booted from the IDE hard disk or the SCSI hard disk.
Grub saves the result to a file called /boot/grub/device.map. In our example, this file has the following content (the boot sequence in the BIOS being "IDE before SCSI"):
(fd0) /dev/fd0 (hd0) /dev/hda (hd1) /dev/hdb (hd2) /dev/sda (hd3) /dev/sdb
Important: If the file content is edited manually (due to boot problems), you must subsequently execute
grub --batch --device-map=/boot/grub/device.map </etc/grub.conf
in order to reinstall Grub. The parameter --device-map specifies that Grub is to interpret the existing map file. The other commands are to be adopted from the file /etc/grub.conf, which is introduced in the following section.
root (hd0,4) install /grub/stage1 d (hd0) /grub/stage2 0x8000 (hd0,4)/grub/menu.lst quit
The entry root mounts the partition containing the Grub files. The command install causes Grub to be installed. In this example, the stage 1 file is installed in the MBR of the first hard disk (d (hd0)). The stage 2 file is to be loaded to the memory address 0x8000 (/grub/stage2 0x8000). The entry (hd0,4)/grub/menu.lst indicates the position of the menu file.