GRUB - The structure of configuration file

December 2016




The configuration file of GRUB

Introduction


The GRUB configuration file is located in /boot/grub/grub.conf ou /boot/grub/menu.lst

Example of a standard configuration


In general the structure of /boot/grub/grub.conf or /boot/grub/menu.lst is as follows (Don't take into account the existing comments).

default	N
timeout	sec
color 	color1 color2

# Configuration for the OS on which Grub is installed

title		The OS label 
root		(hd<disc>,<partition>) 
kernel		/boot/vmlinuz-2.x.x.xx root=/dev/hdLN options
initrd		/boot/initrd.img-2.x.x.xx
# From here to edit for other OS

# For GNU/Linux
# For each OS added in Grub add it to write the next block


title		The additional OS label 
root		(hd<disc>,<partition>) 
kernel		/boot/vmlinuz-2.x.x.xx root=/dev/hdLN options
initrd		/boot/initrd.img-2.x.x.xx
rootnoverify	(hd<disc>,<partition>) 

#For Windows 

title		The OS label 
root		(hd<disc>,<partition>)  
chainloader	+1

Defaults Parameters

  • default N - is the system that starts by default with the bootloader dual boot system
  • sec timeout - the timeout in seconds before the automatic startup
  • color color1 color2 - The background color

1. Addressing


<disc> and <partition>and are numbered from zero, so there is no hda, hda1, etc. ..

Example:
  • 1st partition of 1st disk (hd0, 0)
  • 2nd partition of 1st disk (hd0, 1)
  • First partition 2nd disk (hd1, 0)

2. Title

  • title - is a label that is displayed in the GRUB boot

Ex: Debian GNU/Linux, kernel 2.6.17.7

3. Root


root (hd<disc>,<partition>)

Activating a partition as boot partition.

4. Kernel


kernel /boot/vmlinuz-2.x.x.xx root=/dev/hdLN options

Loading the kernel:

- If the partition contains activated at startup contains / boot (thus a dedicated partition), use:
kernel /vmlinuz-2.x.x.xx root=/dev/hdLN options

the root=/dev/hdLN argument means the root system

L is a letter representing the disc (a for the first disk, b for second, etc. .., and N is the partition number)

Optional:

ro for read-only
mem = 'size'

Here is a link : www.tldp.org/HOWTO/BootPrompt-HOWTO.html

5. Initrd


initrd /boot/initrd.img-2.x.x.xx

The kernel mounts a temporary root system using a compressed image

- If the partition activated at startup contains / boot (thus a dedicated partition), use:
initrd /initrd.img-2.x.x.xx

6. Rootnoverify


rootnoverify (hd<disc>,<partition>)

Activation of the boot partition but without mounting it
Use it for the OS for which we must add the configuration file.

7. Chainloader


chainloader +1

Loading a file or blocks that act as secondary loader
Used to activate Windows.

Important notes


When partitioning the drive, note on a piece of paper all the manipulation performed. It can be used to edit the Grub configuration file later.

Some systems use vmlinuz to refer to the kernel. In fact it is a symbolic link to the kernel.
Similarly initrd will be a symbolic linkfor initrd.img-2.xxxx.
To know which version of the OS kernel :
uname -r


To see which kernel points to vmlinuz
ls -l /boot/vmlinuz


Grub also has a small shell that can be used to test the commands you want to put in the configuration file.
  • To find out about Grub commands at startup you must press the C button and type "help" in the mini shell.
  • To get help for any command you must type help + command
  • To edit the file make use of a text editor in graphics mode (gedit, kedit, kwrite, xemacs) or in console mode editor (vi, vim, emacs, mc)

Related :

This document entitled « GRUB - The structure of configuration file » from CCM (ccm.net) is made available under the Creative Commons license. You can copy, modify copies of this page, under the conditions stipulated by the license, as this note appears clearly.