Linux Boot Loader Configuration Files


GRUB Menu Configuration File

The configuration file (/boot/grub/grub.conf), which is used to create the list of operating systems to boot in GRUB's menu interface, essentially allows the user to select a pre-set group of commands to execute.

Configuration File Structure

The GRUB menu interface configuration file is /boot/grub/grub.conf. The commands to set the global preferences for the menu interface are placed at the top of the file, followed by stanzas for each operating kernel or operating system listed in the menu.

The following is a very basic GRUB menu configuration file designed to boot either red Hat Enterprise Linux or Microsoft Windows 2000:


default=0
timeout=10
splashimage=(hd0,0)/grub/splash.xpm.gz

# section to load Linux
title red Hat Enterprise Linux (2.4.21-1.ent)
        root (hd0,0)
        kernel /vmlinuz-2.4.21-1 ro root=/dev/sda2
        initrd /initrd-2.4.21-1.img

# section to load Windows
title Windows
        rootnoverify (hd0,0)
        chainloader +1

This file configures GRUB to build a menu with red Hat Enterprise Linux as the default operating system and sets it to autoboot after 10 seconds. Two sections are given, one for each operating system entry, with commands specific to the system disk partition table.

Note
 

Note that the default is specified as an integer. This refers to the first title line in the GRUB configuration file. For the Windows section to be set as the default in the previous example, change the default=0 to default=1.

Configuration File Directives

The following are directives commonly used in the GRUB menu configuration file:

  • chainloader </path/to/file> — Loads the specified file as a chain loader. Replace </path/to/file> with the absolute path to the chain loader. If the file is located on the first sector of the specified partition, use the blocklist notation, +1.

  • color <normal-color> <selected-color> — Allows specific colors to be used in the menu, where two colors are configured as the foreground and background. Use simple color names such as red/black. For example:

    color red/black green/blue
  • default=<integer> — Replace <integer> with the default entry title number to be loaded if the menu interface times out.

  • fallback=<integer> — Replace <integer> with the entry title number to try if the first attempt fails.

  • hiddenmenu — Prevents the GRUB menu interface from being displayed, loading the default entry when the timeout period expires. The user can see the standard GRUB menu by pressing the [Esc] key.

  • initrd </path/to/initrd> — Enables users to specify an initial RAM disk to use when booting. Replace </path/to/initrd> with the absolute path to the initial RAM disk.

  • kernel </path/to/kernel> <option-1> <option-N> — Specifies the kernel file to load when booting the operating system. Replace </path/to/kernel> with an absolute path from the partition specified by the root directive. Multiple options can be passed to the kernel when it is loaded.

  • password=<password> — Prevents a user who does not know the password from editing the entries for this menu option.

    Optionally, it is possible to specify an alternate menu configuration file after the password=<password> directive. In this case, GRUB restarts the second stage boot loader and uses the specified alternate configuration file to build the menu. If an alternate menu configuration file is left out of the command, a user who knows the password is allowed to edit the current configuration file.

    For more information about securing GRUB, refer to the chapter titled Workstation Security in the red Hat Enterprise Linux Security Guide.

  • root (<device-type> <device-number>, <partition>) — Configures the root partition for GRUB, such as (hd0,0), and mounts the partition.

  • rootnoverify (<device-type> <device-number>, <partition>) — Configures the root partition for GRUB, just like the root command, but does not mount the partition.

  • timeout=<integer> — Specifies the interval, in seconds, that GRUB waits before loading the entry designated in the default command.

  • splashimage=<path-to-image> — Specifies the location of the splash screen image to be used when GRUB boots.

  • title group-title — Specifies a title to be used with a particular group of commands used to load a kernel or operating system.

To add human-readable comments to the menu configuration file, begin the line with the hash mark character (#).

Hard Disk and Partition Designations

Please note that Grub uses its own designations for hard disks and partitions instead of the common Linux device designations (such as /dev/hda1). The floppy disk drive is designated as fd0, all hard disks are designated as hd0, hd1, and so on. The partition designation is appended, separated by a comma: hd0,0 is the first partition on the first hard disk. Important: the device and partition numbering starts with zero.

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

Menu File Example

The following example shows the structure of the menu file /boot/grub/menu.lst. In this example, /dev/hda5 is the Linux boot partition, /dev/hda7 is the root partition, and /dev/hda1 contains a Windows operating system.


gfxmenu (hd0,4)/message
color white/green black/light-gray
default 0
timeout 10

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:

  • As you can easily guess, the first two lines cover the configuration of the splash menu: the background image is located in /dev/hda5 and has the name "message". Foreground: white, background: green, selection: black, background of the selection: light gray.

  • The entry "default 0" in the third line indicates that the first menu entry ("title linux") is the default selection for booting.

  • Line 4: The timeout is 10 seconds.

Regarding the entries of the operating systems that can be booted:

  • The first entry ("title linux") boots Linux.

  • The Linux kernel is located in the first logical partition of the first hard disk (hd0,4) (the boot partition in this example); the file name is vmlinuz. Kernel parameters (such as the specification of the root partition, vga, etc.) are appended directly. Attention: The root partition must be specified as a Linux device name, since it is sent to the Linux kernel as a parameter.

  • Information on the position of the initrd: The initrd is also located in the first logical partition on the first hard disk.

  • The next section starts Windows from the first partition of the hard disk (hd0,0). To be on the safe side, the option "makeactive" is set in the following line, as Windows can only be started from a visible partition that is set active.

  • The entry "chainloader +1" causes the first sector of the indicated partition to be read and executed. The subsequent section can be used to start an operating system from a floppy disk without performing any changes in the BIOS.

  • The final section starts Linux in the failsafe mode. As stated above, changes to this menu will be adopted automatically the next time the system is booted.


The LILO Configuration File

The LILO configuration file is /etc/lilo.conf. The /sbin/lilo commands uses this file to determine what information to write to the MBR.

warning
 

Before editing /etc/lilo.conf, be sure to make a backup copy of the file. Also, have a working boot disk available so that changes can be made to the MBR if there is a problem. Refer To the man page for mkbootdisk for more information on creating a boot disk.

The /etc/lilo.conf file is used by the /sbin/lilo command to determine which operating system or kernel to load and where it should be installed.

Sample /etc/lilo.conf

The following is a sample /etc/lilo.conf for a system configured to boot two operating systems, red Hat Enterprise Linux and DOS:


boot=/dev/hda
map=/boot/map
install=/boot/boot.b
prompt
timeout=50
message=/boot/message
lba32
default=linux

image=/boot/vmlinuz-2.4.0-0.43.6
	label=linux
	initrd=/boot/initrd-2.4.0-0.43.6.img
	read-only
	root=/dev/hda5

other=/dev/hda1
	label=dos

The following is a more detailed look at the lines of this file:

  • boot=/dev/hda — Instructs LILO to be installed on the first hard disk of the first IDE controller.

  • map=/boot/map — Locates the map file. In normal use, this should not be modified.

  • install=/boot/boot.b — Instructs LILO to install the specified file as the new boot sector. In normal use, this should not be altered. If the install line is missing, LILO assumes a default of /boot/boot.b as the file to be used.

  • prompt — Instructs LILO to show you whatever is referenced in the message line. While it is not recommended that you remove the prompt line, if you do remove it, you can still access a prompt by holding down the [Shift] key while your machine starts to boot.

  • timeout=50 — Sets the amount of time that LILO waits for user input before proceeding with booting the default line entry. This is measured in tenths of a second, with 50 as the default.

  • message=/boot/message — Refers to the screen that LILO displays to let you select the operating system or kernel to boot.

  • lba32 — Describes the hard disk geometry to LILO. Another common entry here is linear. You should not change this line unless you are very aware of what you are doing. Otherwise, you could put your system in an unbootable state.

  • default=linux — Refers to the default operating system for LILO to boot as seen in the options listed below this line. The name linux refers to the label line below in each of the boot options.

  • image=/boot/vmlinuz-2.4.0-0.43.6 — Specifies which Linux kernel to boot with this particular boot option.

  • label=linux — names the operating system option in the LILO screen. In this case, it is also the name referred to by the default line.

  • initrd=/boot/initrd-2.4.0-0.43.6.img — Refers to the initial ram disk image that is used at boot time to initialize and start the devices that makes booting the kernel possible. The initial ram disk is a collection of machine-specific drivers necessary to operate a SCSI card, hard drive, or any other device needed to load the kernel. You should never try to share initial ram disks between machines.

  • read-only — Specifies that the root partition (refer to the root line below) is read-only and cannot be altered during the boot process.

  • root=/dev/hda5 — Specifies which disk partition to use as the root partition.

  • other=/dev/hda1 — Specifies the partition containing DOS.

© MAK 2004
End of Document