Grub v2 manual

The pages contributed here (FranklinPiat/*) were an attempt to write some documentation for Grub2. This documentation isn't updated anymore (since grub2-1.96+20080203 approximately)

This work, and (any further contribution), has copyright attribution to FSF. It's dual licensed under GPLv1 or later and GFDL.

#language en


grub.cfg(5) - grub v2 boot-time configuration file.

NAME

DESCRIPTION

grub.cfg isn't really a configuration file, it's actually a bash-like script file executed by grub2 bootloader. The various instructions are either built-in, or implemented as external modules, which has to be loaded before use.

The menu structure is actually declared by the command menuentry. A menu entry is a kind of function, which is invoked when the user select it.

On most distributions, the file /boot/grub/grub.cfg is built and updated by update-grub, based on the content of /etc/defaults/grub  and /etc/grub.d/*. Read (8)update-grub for more information.

You should not modify grub.cfg directly.

FORMAT

PATHNAMES

In the grub environment, a file path is written as (hd0,1)/path/to/filename.

A typical disk drive specified with (hd0,1) is "the first partition of the first hard-disk", as seen by the computer's firmware (This is similar, but not always identical, to /dev/hda1, /dev/sda1, "C:" or PC-BIOS' drive "80"). note: The partition numbering scheme starts at 1 (like linux' hda1) where grub-v1 used to start counting partition at 0.

The path /path/to/filename is just the regular pathname, according to the partition's filesystem.

note: The appropriate diskaccess, partitioning and filesystem module must be loaded in order to be able to access such file. (typically, biosdisk+pc+ext2 on a legacy PC. read appropriate section below.)

If the disk (drive,partition) is not specified then the path is prefixed with the content of the variable root.

Some well known disk names :

COMMANDS

reminder : Most commands are only available when the corresponding module is loaded (except built-ins commands).

Convention : In this document, when a command is implemented by a loadable module, the module name is written like [mymodule].

BUILT-COMMANDS

Handling modules

insmod [modulename|filename] 

lsmod

rmmod [modulename] 

read the (7)grub_modules page.

Menu Entries

menuentry "Sample Menu-entry title" { COMMAND-LINES }  A menu entry is a kind of subroutine, declared with the command menuentry. The list of commands to be executed when the user press "enter" on the selected menu-entry are listed between curly brackets. check the #sample section at the bottom of the page.

To navigate the menu, depending on th system, you may have to use: Left-arrow, Right-arrow, Down-arrow, Up-arrow, or <, >, v and ^ (For non-US, ^ is obtained by pressing Shift+6), or Ctrl-b, Ctrl-f, Ctrl-n, Ctrl-p.

Environment variables

Grub bootloader has some environment variables, that can be use with $. (like echo $root). note that variable names are case sensitives.

set

set var=value

unset

export var

read VAR

Remarkable variables : root variable

Rescue mode

rescue

OS Loaders commands

linux FILE [ARGS...]

initrd FILE

multiboot FILE [ARGS...]

module FILE [ARGS...]

chainloader [-f|--force] FILE

boot

freebsd FILE [OPTS] [ARGS...]

freebsd_loadenv FILE

freebsd_module [FILE [type=module_type] [ARGS...]]

netbsd FILE [OPTS] [ARGS...]

openbsd FILE [OPTS] [ARGS...]

Scripting commands

if [expression] then [command] else [command] fi

[ string=string ]

test string=string

while

function

configfile FILE

source FILE

. FILE

search [-f|-l] [[-s|--set]] NAME

search [-f|--file] NAME

search [-l|--label]] NAME

echo [-e] [-n] FILE

sleep [-v] [-i] NUMBER_OF_SECONDS

cmp FILE1 FILE2

[ EXPRESSION ]

test EXPRESSION

Tools

help [PATTERN ...]

ls [-l|-h|-a] [FILE] List devices and files. [ls]

hello

hexdump [ -s offset ] [-n length] { FILE | (mem) } 

cat FILE

cpuid

lspci

halt [-n]

reboot

suspend

blocklist FILE

loopback [-d|-p] DEVICENAME FILE

play FILE

Terminal

terminal [TERM...]

serial [OPTIONS...]

font FILE...

background_image FILE

terminfo [TERM]

videotest

vbeinfo

vbetest

Menu colors can be set with the following variables :

set menu_color_normal FG/BG

set menu_color_highlight FG/BG

where FB and BG can be one of :

If your terminal has graphic capabilities, you can load a background image.

Supported platforms/firmware

SAMPLE

AUTHOR

Program Written by Yoshinori K. Okuji, Robert Millan, Marco Gerards and others (see AUTHORS file).

Manpage Written by Franklin Piat.

BUGS

Report bugs to <bug-grub@gnu.org>.

COPYRIGHT

Copyright © 2008 Free Software Foundation, Inc.

This is free software. You may redistribute copies of it under the terms of the GNU General Public License <http://www.gnu.org/licenses/gpl.html>. There is NO WARRANTY, to the extent permitted by law.

SEE ALSO

grub2-1.96+20080209

January 2008

(5)GRUB.CFG


LICENCE

This page is dual licensed under GPL + GFDL.

GrubWiki: FranklinPiat/grub.cfg.manpage (last edited 2009-04-10 22:15:47 by FranklinPiat)