Upgraded GRUB2 to 2.00 release.
[AROS.git] / arch / all-pc / boot / grub2-aros / docs / grub.texi
blobb5954da826dc59e68b91220143357afaf241029a
1 \input texinfo
2 @c -*-texinfo-*-
3 @c %**start of header
4 @setfilename grub.info
5 @include version.texi
6 @settitle GNU GRUB Manual @value{VERSION}
7 @c Unify all our little indices for now.
8 @syncodeindex fn cp
9 @syncodeindex vr cp
10 @syncodeindex ky cp
11 @syncodeindex pg cp
12 @syncodeindex tp cp
13 @c %**end of header
15 @footnotestyle separate
16 @paragraphindent 3
17 @finalout
19 @copying
20 This manual is for GNU GRUB (version @value{VERSION},
21 @value{UPDATED}).
23 Copyright @copyright{} 1999,2000,2001,2002,2004,2006,2008,2009,2010,2011,2012 Free Software Foundation, Inc.
25 @quotation
26 Permission is granted to copy, distribute and/or modify this document
27 under the terms of the GNU Free Documentation License, Version 1.2 or
28 any later version published by the Free Software Foundation; with no
29 Invariant Sections.
30 @end quotation
31 @end copying
33 @dircategory Kernel
34 @direntry
35 * GRUB: (grub).                 The GRand Unified Bootloader
36 * grub-install: (grub)Invoking grub-install.    Install GRUB on your drive
37 * grub-mkconfig: (grub)Invoking grub-mkconfig.  Generate GRUB configuration
38 * grub-mkpasswd-pbkdf2: (grub)Invoking grub-mkpasswd-pbkdf2.
39 * grub-mkrescue: (grub)Invoking grub-mkrescue.  Make a GRUB rescue image
40 * grub-probe: (grub)Invoking grub-probe.        Probe device information
41 @end direntry
43 @setchapternewpage odd
45 @titlepage
46 @sp 10
47 @title the GNU GRUB manual
48 @subtitle The GRand Unified Bootloader, version @value{VERSION}, @value{UPDATED}.
49 @author Gordon Matzigkeit
50 @author Yoshinori K. Okuji
51 @author Colin Watson
52 @author Colin D. Bennett
53 @c The following two commands start the copyright page.
54 @page
55 @vskip 0pt plus 1filll
56 @insertcopying
57 @end titlepage
59 @c Output the table of contents at the beginning.
60 @contents
62 @finalout
63 @headings double
65 @ifnottex
66 @node Top
67 @top GNU GRUB manual
69 This is the documentation of GNU GRUB, the GRand Unified Bootloader,
70 a flexible and powerful boot loader program for a wide range of
71 architectures.
73 This edition documents version @value{VERSION}.
75 @insertcopying
76 @end ifnottex
78 @menu
79 * Introduction::                Capturing the spirit of GRUB
80 * Naming convention::           Names of your drives in GRUB
81 * Installation::                Installing GRUB on your drive
82 * Booting::                     How to boot different operating systems
83 * Configuration::               Writing your own configuration file
84 * Theme file format::           Format of GRUB theme files
85 * Network::                     Downloading OS images from a network
86 * Serial terminal::             Using GRUB via a serial line
87 * Vendor power-on keys::        Changing GRUB behaviour on vendor power-on keys
88 * Images::                      GRUB image files
89 * Filesystem::                  Filesystem syntax and semantics
90 * Interface::                   The menu and the command-line
91 * Environment::                 GRUB environment variables
92 * Commands::                    The list of available builtin commands
93 * Internationalisation::        Topics relating to language support
94 * Security::                    Authentication and authorisation
95 * Platform limitations::        The list of platform-specific limitations
96 * Platform-specific operations:: Platform-specific operations
97 * Supported kernels::           The list of supported kernels
98 * Troubleshooting::             Error messages produced by GRUB
99 * Invoking grub-install::       How to use the GRUB installer
100 * Invoking grub-mkconfig::      Generate a GRUB configuration file
101 * Invoking grub-mkpasswd-pbkdf2::
102                                 Generate GRUB password hashes
103 * Invoking grub-mkrescue::      Make a GRUB rescue image
104 * Invoking grub-probe::         Probe device information for GRUB
105 * Obtaining and Building GRUB:: How to obtain and build GRUB
106 * Reporting bugs::              Where you should send a bug report
107 * Future::                      Some future plans on GRUB
108 * Copying This Manual::         Copying This Manual
109 * Index::
110 @end menu
113 @node Introduction
114 @chapter Introduction to GRUB
116 @menu
117 * Overview::                    What exactly GRUB is and how to use it
118 * History::                     From maggot to house fly
119 * Changes from GRUB Legacy::    Differences from previous versions
120 * Features::                    GRUB features
121 * Role of a boot loader::       The role of a boot loader
122 @end menu
125 @node Overview
126 @section Overview
128 Briefly, a @dfn{boot loader} is the first software program that runs when
129 a computer starts.  It is responsible for loading and transferring
130 control to an operating system @dfn{kernel} software (such as Linux or
131 GNU Mach).  The kernel, in turn, initializes the rest of the operating
132 system (e.g. a GNU system).
134 GNU GRUB is a very powerful boot loader, which can load a wide variety
135 of free operating systems, as well as proprietary operating systems with
136 chain-loading@footnote{@dfn{chain-load} is the mechanism for loading
137 unsupported operating systems by loading another boot loader. It is
138 typically used for loading DOS or Windows.}. GRUB is designed to
139 address the complexity of booting a personal computer; both the
140 program and this manual are tightly bound to that computer platform,
141 although porting to other platforms may be addressed in the future.
143 One of the important features in GRUB is flexibility; GRUB understands
144 filesystems and kernel executable formats, so you can load an arbitrary
145 operating system the way you like, without recording the physical
146 position of your kernel on the disk. Thus you can load the kernel
147 just by specifying its file name and the drive and partition where the
148 kernel resides.
150 When booting with GRUB, you can use either a command-line interface
151 (@pxref{Command-line interface}), or a menu interface (@pxref{Menu
152 interface}). Using the command-line interface, you type the drive
153 specification and file name of the kernel manually. In the menu
154 interface, you just select an OS using the arrow keys. The menu is
155 based on a configuration file which you prepare beforehand
156 (@pxref{Configuration}). While in the menu, you can switch to the
157 command-line mode, and vice-versa. You can even edit menu entries
158 before using them.
160 In the following chapters, you will learn how to specify a drive, a
161 partition, and a file name (@pxref{Naming convention}) to GRUB, how to
162 install GRUB on your drive (@pxref{Installation}), and how to boot your
163 OSes (@pxref{Booting}), step by step.
166 @node History
167 @section History of GRUB
169 GRUB originated in 1995 when Erich Boleyn was trying to boot the GNU
170 Hurd with the University of Utah's Mach 4 microkernel (now known as GNU
171 Mach).  Erich and Brian Ford designed the Multiboot Specification
172 (@pxref{Top, Multiboot Specification, Motivation, multiboot, The Multiboot
173 Specification}), because they were determined not to add to the large
174 number of mutually-incompatible PC boot methods.
176 Erich then began modifying the FreeBSD boot loader so that it would
177 understand Multiboot. He soon realized that it would be a lot easier
178 to write his own boot loader from scratch than to keep working on the
179 FreeBSD boot loader, and so GRUB was born.
181 Erich added many features to GRUB, but other priorities prevented him
182 from keeping up with the demands of its quickly-expanding user base. In
183 1999, Gordon Matzigkeit and Yoshinori K. Okuji adopted GRUB as an
184 official GNU package, and opened its development by making the latest
185 sources available via anonymous CVS. @xref{Obtaining and Building
186 GRUB}, for more information.
188 Over the next few years, GRUB was extended to meet many needs, but it
189 quickly became clear that its design was not keeping up with the extensions
190 being made to it, and we reached the point where it was very difficult to
191 make any further changes without breaking existing features.  Around 2002,
192 Yoshinori K. Okuji started work on PUPA (Preliminary Universal Programming
193 Architecture for GNU GRUB), aiming to rewrite the core of GRUB to make it
194 cleaner, safer, more robust, and more powerful.  PUPA was eventually renamed
195 to GRUB 2, and the original version of GRUB was renamed to GRUB Legacy.
196 Small amounts of maintenance continued to be done on GRUB Legacy, but the
197 last release (0.97) was made in 2005 and at the time of writing it seems
198 unlikely that there will be another.
200 By around 2007, GNU/Linux distributions started to use GRUB 2 to limited
201 extents, and by the end of 2009 multiple major distributions were installing
202 it by default.
205 @node Changes from GRUB Legacy
206 @section Differences from previous versions
208 GRUB 2 is a rewrite of GRUB (@pxref{History}), although it shares many
209 characteristics with the previous version, now known as GRUB Legacy.  Users
210 of GRUB Legacy may need some guidance to find their way around this new
211 version.
213 @itemize @bullet
214 @item
215 The configuration file has a new name (@file{grub.cfg} rather than
216 @file{menu.lst} or @file{grub.conf}), new syntax (@pxref{Configuration}) and
217 many new commands (@pxref{Commands}).  Configuration cannot be copied over
218 directly, although most GRUB Legacy users should not find the syntax too
219 surprising.
221 @item
222 @file{grub.cfg} is typically automatically generated by
223 @command{grub-mkconfig} (@pxref{Simple configuration}).  This makes it
224 easier to handle versioned kernel upgrades.
226 @item
227 Partition numbers in GRUB device names now start at 1, not 0 (@pxref{Naming
228 convention}).
230 @item
231 The configuration file is now written in something closer to a full
232 scripting language: variables, conditionals, and loops are available.
234 @item
235 A small amount of persistent storage is available across reboots, using the
236 @command{save_env} and @command{load_env} commands in GRUB and the
237 @command{grub-editenv} utility.  This is not available in all configurations
238 (@pxref{Environment block}).
240 @item
241 GRUB 2 has more reliable ways to find its own files and those of target
242 kernels on multiple-disk systems, and has commands (@pxref{search}) to find
243 devices using file system labels or Universally Unique Identifiers (UUIDs).
245 @item
246 GRUB 2 is available for several other types of system in addition to the PC
247 BIOS systems supported by GRUB Legacy: PC EFI, PC coreboot, PowerPC, SPARC,
248 and MIPS Lemote Yeeloong are all supported.
250 @item
251 Many more file systems are supported, including but not limited to ext4,
252 HFS+, and NTFS.
254 @item
255 GRUB 2 can read files directly from LVM and RAID devices.
257 @item
258 A graphical terminal and a graphical menu system are available.
260 @item
261 GRUB 2's interface can be translated, including menu entry names.
263 @item
264 The image files (@pxref{Images}) that make up GRUB have been reorganised;
265 Stage 1, Stage 1.5, and Stage 2 are no more.
267 @item
268 GRUB 2 puts many facilities in dynamically loaded modules, allowing the core
269 image to be smaller, and allowing the core image to be built in more
270 flexible ways.
271 @end itemize
274 @node Features
275 @section GRUB features
277 The primary requirement for GRUB is that it be compliant with the
278 @dfn{Multiboot Specification}, which is described in @ref{Top, Multiboot
279 Specification, Motivation, multiboot, The Multiboot Specification}.
281 The other goals, listed in approximate order of importance, are:
283 @itemize @bullet{}
284 @item
285 Basic functions must be straightforward for end-users.
287 @item
288 Rich functionality to support kernel experts and designers.
290 @item
291 Backward compatibility for booting FreeBSD, NetBSD, OpenBSD, and
292 Linux. Proprietary kernels (such as DOS, Windows NT, and OS/2) are
293 supported via a chain-loading function.
294 @end itemize
296 Except for specific compatibility modes (chain-loading and the Linux
297 @dfn{piggyback} format), all kernels will be started in much the same
298 state as in the Multiboot Specification. Only kernels loaded at 1 megabyte
299 or above are presently supported. Any attempt to load below that
300 boundary will simply result in immediate failure and an error message
301 reporting the problem.
303 In addition to the requirements above, GRUB has the following features
304 (note that the Multiboot Specification doesn't require all the features
305 that GRUB supports):
307 @table @asis
308 @item Recognize multiple executable formats
309 Support many of the @dfn{a.out} variants plus @dfn{ELF}. Symbol
310 tables are also loaded.
312 @item Support non-Multiboot kernels
313 Support many of the various free 32-bit kernels that lack Multiboot
314 compliance (primarily FreeBSD, NetBSD, OpenBSD, and
315 Linux). Chain-loading of other boot loaders is also supported.
317 @item Load multiples modules
318 Fully support the Multiboot feature of loading multiple modules.
320 @item Load a configuration file
321 Support a human-readable text configuration file with preset boot
322 commands. You can also load another configuration file dynamically and
323 embed a preset configuration file in a GRUB image file. The list of
324 commands (@pxref{Commands}) are a superset of those supported on the
325 command-line. An example configuration file is provided in
326 @ref{Configuration}.
328 @item Provide a menu interface
329 A menu interface listing preset boot commands, with a programmable
330 timeout, is available. There is no fixed limit on the number of boot
331 entries, and the current implementation has space for several hundred.
333 @item Have a flexible command-line interface
334 A fairly flexible command-line interface, accessible from the menu,
335 is available to edit any preset commands, or write a new boot command
336 set from scratch. If no configuration file is present, GRUB drops to
337 the command-line.
339 The list of commands (@pxref{Commands}) are a subset of those supported
340 for configuration files. Editing commands closely resembles the Bash
341 command-line (@pxref{Command Line Editing, Bash, Command Line Editing,
342 features, Bash Features}), with @key{TAB}-completion of commands,
343 devices, partitions, and files in a directory depending on context.
345 @item Support multiple filesystem types
346 Support multiple filesystem types transparently, plus a useful explicit
347 blocklist notation. The currently supported filesystem types are @dfn{Amiga
348 Fast FileSystem (AFFS)}, @dfn{AtheOS fs}, @dfn{BeFS},
349 @dfn{BtrFS} (including raid0, raid1, raid10, gzip and lzo),
350 @dfn{cpio} (little- and big-endian bin, odc and newc variants),
351 @dfn{Linux ext2/ext3/ext4}, @dfn{DOS FAT12/FAT16/FAT32}, @dfn{exFAT}, @dfn{HFS},
352 @dfn{HFS+}, @dfn{ISO9660} (including Joliet, Rock-ridge and multi-chunk files),
353 @dfn{JFS}, @dfn{Minix fs} (versions 1, 2 and 3), @dfn{nilfs2},
354 @dfn{NTFS} (including compression), @dfn{ReiserFS}, @dfn{ROMFS},
355 @dfn{Amiga Smart FileSystem (SFS)}, @dfn{Squash4}, @dfn{tar}, @dfn{UDF},
356 @dfn{BSD UFS/UFS2}, @dfn{XFS}, and @dfn{ZFS} (including lzjb, gzip,
357 zle, mirror, stripe, raidz1/2/3 and encryption in AES-CCM and AES-GCM).
358 @xref{Filesystem}, for more information.
360 @item Support automatic decompression
361 Can decompress files which were compressed by @command{gzip} or
362 @command{xz}@footnote{Only CRC32 data integrity check is supported (xz default
363 is CRC64 so one should use --check=crc32 option). LZMA BCJ filters are
364 supported.}. This function is both automatic and transparent to the user
365 (i.e. all functions operate upon the uncompressed contents of the specified
366 files). This greatly reduces a file size and loading time, a
367 particularly great benefit for floppies.@footnote{There are a few
368 pathological cases where loading a very badly organized ELF kernel might
369 take longer, but in practice this never happen.}
371 It is conceivable that some kernel modules should be loaded in a
372 compressed state, so a different module-loading command can be specified
373 to avoid uncompressing the modules.
375 @item Access data on any installed device
376 Support reading data from any or all floppies or hard disk(s) recognized
377 by the BIOS, independent of the setting of the root device.
379 @item Be independent of drive geometry translations
380 Unlike many other boot loaders, GRUB makes the particular drive
381 translation irrelevant. A drive installed and running with one
382 translation may be converted to another translation without any adverse
383 effects or changes in GRUB's configuration.
385 @item Detect all installed @sc{ram}
386 GRUB can generally find all the installed @sc{ram} on a PC-compatible
387 machine. It uses an advanced BIOS query technique for finding all
388 memory regions. As described on the Multiboot Specification (@pxref{Top,
389 Multiboot Specification, Motivation, multiboot, The Multiboot
390 Specification}), not all kernels make use of this information, but GRUB
391 provides it for those who do.
393 @item Support Logical Block Address mode
394 In traditional disk calls (called @dfn{CHS mode}), there is a geometry
395 translation problem, that is, the BIOS cannot access over 1024
396 cylinders, so the accessible space is limited to at least 508 MB and to
397 at most 8GB. GRUB can't universally solve this problem, as there is no
398 standard interface used in all machines. However, several newer machines
399 have the new interface, Logical Block Address (@dfn{LBA}) mode. GRUB
400 automatically detects if LBA mode is available and uses it if
401 available. In LBA mode, GRUB can access the entire disk.
403 @item Support network booting
404 GRUB is basically a disk-based boot loader but also has network
405 support. You can load OS images from a network by using the @dfn{TFTP}
406 protocol.
408 @item Support remote terminals
409 To support computers with no console, GRUB provides remote terminal
410 support, so that you can control GRUB from a remote host. Only serial
411 terminal support is implemented at the moment.
412 @end table
415 @node Role of a boot loader
416 @section The role of a boot loader
418 The following is a quotation from Gordon Matzigkeit, a GRUB fanatic:
420 @quotation
421 Some people like to acknowledge both the operating system and kernel when
422 they talk about their computers, so they might say they use
423 ``GNU/Linux'' or ``GNU/Hurd''.  Other people seem to think that the
424 kernel is the most important part of the system, so they like to call
425 their GNU operating systems ``Linux systems.''
427 I, personally, believe that this is a grave injustice, because the
428 @emph{boot loader} is the most important software of all. I used to
429 refer to the above systems as either ``LILO''@footnote{The LInux LOader,
430 a boot loader that everybody uses, but nobody likes.} or ``GRUB''
431 systems.
433 Unfortunately, nobody ever understood what I was talking about; now I
434 just use the word ``GNU'' as a pseudonym for GRUB.
436 So, if you ever hear people talking about their alleged ``GNU'' systems,
437 remember that they are actually paying homage to the best boot loader
438 around@dots{} GRUB!
439 @end quotation
441 We, the GRUB maintainers, do not (usually) encourage Gordon's level of
442 fanaticism, but it helps to remember that boot loaders deserve
443 recognition.  We hope that you enjoy using GNU GRUB as much as we did
444 writing it.
447 @node Naming convention
448 @chapter Naming convention
450 The device syntax used in GRUB is a wee bit different from what you may
451 have seen before in your operating system(s), and you need to know it so
452 that you can specify a drive/partition.
454 Look at the following examples and explanations:
456 @example
457 (fd0)
458 @end example
460 First of all, GRUB requires that the device name be enclosed with
461 @samp{(} and @samp{)}. The @samp{fd} part means that it is a floppy
462 disk. The number @samp{0} is the drive number, which is counted from
463 @emph{zero}. This expression means that GRUB will use the whole floppy
464 disk.
466 @example
467 (hd0,msdos2)
468 @end example
470 Here, @samp{hd} means it is a hard disk drive. The first integer
471 @samp{0} indicates the drive number, that is, the first hard disk,
472 the string @samp{msdos} indicates the partition scheme, while
473 the second integer, @samp{2}, indicates the partition number (or the
474 @sc{pc} slice number in the BSD terminology). The partition numbers are
475 counted from @emph{one}, not from zero (as was the case in previous
476 versions of GRUB). This expression means the second partition of the
477 first hard disk drive. In this case, GRUB uses one partition of the
478 disk, instead of the whole disk.
480 @example
481 (hd0,msdos5)
482 @end example
484 This specifies the first @dfn{extended partition} of the first hard disk
485 drive. Note that the partition numbers for extended partitions are
486 counted from @samp{5}, regardless of the actual number of primary
487 partitions on your hard disk.
489 @example
490 (hd1,msdos1,bsd1)
491 @end example
493 This means the BSD @samp{a} partition on first @sc{pc} slice number
494 of the second hard disk.
496 Of course, to actually access the disks or partitions with GRUB, you
497 need to use the device specification in a command, like @samp{set
498 root=(fd0)} or @samp{parttool (hd0,msdos3) hidden-}. To help you find out
499 which number specifies a partition you want, the GRUB command-line
500 (@pxref{Command-line interface}) options have argument
501 completion. This means that, for example, you only need to type
503 @example
504 set root=(
505 @end example
507 followed by a @key{TAB}, and GRUB will display the list of drives,
508 partitions, or file names. So it should be quite easy to determine the
509 name of your target partition, even with minimal knowledge of the
510 syntax.
512 Note that GRUB does @emph{not} distinguish IDE from SCSI - it simply
513 counts the drive numbers from zero, regardless of their type. Normally,
514 any IDE drive number is less than any SCSI drive number, although that
515 is not true if you change the boot sequence by swapping IDE and SCSI
516 drives in your BIOS.
518 Now the question is, how to specify a file? Again, consider an
519 example:
521 @example
522 (hd0,msdos1)/vmlinuz
523 @end example
525 This specifies the file named @samp{vmlinuz}, found on the first
526 partition of the first hard disk drive. Note that the argument
527 completion works with file names, too.
529 That was easy, admit it. Now read the next chapter, to find out how to
530 actually install GRUB on your drive.
533 @node Installation
534 @chapter Installation
536 In order to install GRUB as your boot loader, you need to first
537 install the GRUB system and utilities under your UNIX-like operating
538 system (@pxref{Obtaining and Building GRUB}). You can do this either
539 from the source tarball, or as a package for your OS.
541 After you have done that, you need to install the boot loader on a
542 drive (floppy or hard disk) by using the utility
543 @command{grub-install} (@pxref{Invoking grub-install}) on a UNIX-like OS.
545 GRUB comes with boot images, which are normally put in the directory
546 @file{/usr/lib/grub/<cpu>-<platform>} (for BIOS-based machines
547 @file{/usr/lib/grub/i386-pc}). Hereafter, the directory where GRUB images are
548 initially placed (normally @file{/usr/lib/grub/<cpu>-<platform>}) will be
549 called the @dfn{image directory}, and the directory where the boot
550 loader needs to find them (usually @file{/boot}) will be called
551 the @dfn{boot directory}.
553 @menu
554 * Installing GRUB using grub-install::
555 * Making a GRUB bootable CD-ROM::
556 * Device map::
557 * BIOS installation::
558 @end menu
561 @node Installing GRUB using grub-install
562 @section Installing GRUB using grub-install
564 For information on where GRUB should be installed on PC BIOS platforms,
565 @pxref{BIOS installation}.
567 In order to install GRUB under a UNIX-like OS (such
568 as @sc{gnu}), invoke the program @command{grub-install} (@pxref{Invoking
569 grub-install}) as the superuser (@dfn{root}).
571 The usage is basically very simple. You only need to specify one
572 argument to the program, namely, where to install the boot loader. The
573 argument has to be either a device file (like @samp{/dev/hda}).
574 For example, under Linux the following will install GRUB into the MBR
575 of the first IDE disk:
577 @example
578 # @kbd{grub-install /dev/hda}
579 @end example
581 Likewise, under GNU/Hurd, this has the same effect:
583 @example
584 # @kbd{grub-install /dev/hd0}
585 @end example
587 But all the above examples assume that GRUB should put images under
588 the @file{/boot} directory. If you want GRUB to put images under a directory
589 other than @file{/boot}, you need to specify the option
590 @option{--boot-directory}. The typical usage is that you create a GRUB
591 boot floppy with a filesystem. Here is an example:
593 @example
594 @group
595 # @kbd{mke2fs /dev/fd0}
596 # @kbd{mount -t ext2 /dev/fd0 /mnt}
597 # @kbd{mkdir /mnt/boot}
598 # @kbd{grub-install --boot-directory=/mnt/boot /dev/fd0}
599 # @kbd{umount /mnt}
600 @end group
601 @end example
603 Some BIOSes have a bug of exposing the first partition of a USB drive as a
604 floppy instead of exposing the USB drive as a hard disk (they call it
605 ``USB-FDD'' boot). In such cases, you need to install like this:
607 @example
608 # @kbd{losetup /dev/loop0 /dev/sdb1}
609 # @kbd{mount /dev/loop0 /mnt/usb}
610 # @kbd{grub-install --boot-directory=/mnt/usb/bugbios --force --allow-floppy /dev/loop0}
611 @end example
613 This install doesn't conflict with standard install as long as they are in
614 separate directories.
616 Note that @command{grub-install} is actually just a shell script and the
617 real task is done by @command{grub-mkimage} and @command{grub-setup}.
618 Therefore, you may run those commands directly to install GRUB, without
619 using @command{grub-install}. Don't do that, however, unless you are very
620 familiar with the internals of GRUB. Installing a boot loader on a running
621 OS may be extremely dangerous.
623 @node Making a GRUB bootable CD-ROM
624 @section Making a GRUB bootable CD-ROM
626 GRUB supports the @dfn{no emulation mode} in the El Torito
627 specification@footnote{El Torito is a specification for bootable CD
628 using BIOS functions.}. This means that you can use the whole CD-ROM
629 from GRUB and you don't have to make a floppy or hard disk image file,
630 which can cause compatibility problems.
632 For booting from a CD-ROM, GRUB uses a special image called
633 @file{cdboot.img}, which is concatenated with @file{core.img}. The
634 @file{core.img} used for this should be built with at least the
635 @samp{iso9660} and @samp{biosdisk} modules. Your bootable CD-ROM will
636 usually also need to include a configuration file @file{grub.cfg} and some
637 other GRUB modules.
639 To make a simple generic GRUB rescue CD, you can use the
640 @command{grub-mkrescue} program (@pxref{Invoking grub-mkrescue}):
642 @example
643 $ @kbd{grub-mkrescue -o grub.iso}
644 @end example
646 You will often need to include other files in your image. To do this, first
647 make a top directory for the bootable image, say, @samp{iso}:
649 @example
650 $ @kbd{mkdir iso}
651 @end example
653 Make a directory for GRUB:
655 @example
656 $ @kbd{mkdir -p iso/boot/grub}
657 @end example
659 If desired, make the config file @file{grub.cfg} under @file{iso/boot/grub}
660 (@pxref{Configuration}), and copy any files and directories for the disc to the
661 directory @file{iso/}.
663 Finally, make the image:
665 @example
666 $ @kbd{grub-mkrescue -o grub.iso iso}
667 @end example
669 This produces a file named @file{grub.iso}, which then can be burned
670 into a CD (or a DVD), or written to a USB mass storage device.
672 The root device will be set up appropriately on entering your
673 @file{grub.cfg} configuration file, so you can refer to file names on the CD
674 without needing to use an explicit device name. This makes it easier to
675 produce rescue images that will work on both optical drives and USB mass
676 storage devices.
679 @node Device map
680 @section The map between BIOS drives and OS devices
682 If the device map file exists, the GRUB utilities (@command{grub-probe},
683 @command{grub-setup}, etc.) read it to map BIOS drives to OS devices.  This
684 file consists of lines like this:
686 @example
687 (@var{device}) @var{file}
688 @end example
690 @var{device} is a drive specified in the GRUB syntax (@pxref{Device
691 syntax}), and @var{file} is an OS file, which is normally a device file.
693 Historically, the device map file was used because GRUB device names had to
694 be used in the configuration file, and they were derived from BIOS drive
695 numbers.  The map between BIOS drives and OS devices cannot always be
696 guessed correctly: for example, GRUB will get the order wrong if you
697 exchange the boot sequence between IDE and SCSI in your BIOS.
699 Unfortunately, even OS device names are not always stable.  Modern versions
700 of the Linux kernel may probe drives in a different order from boot to boot,
701 and the prefix (@file{/dev/hd*} versus @file{/dev/sd*}) may change depending
702 on the driver subsystem in use.  As a result, the device map file required
703 frequent editing on some systems.
705 GRUB avoids this problem nowadays by using UUIDs or file system labels when
706 generating @file{grub.cfg}, and we advise that you do the same for any
707 custom menu entries you write.  If the device map file does not exist, then
708 the GRUB utilities will assume a temporary device map on the fly.  This is
709 often good enough, particularly in the common case of single-disk systems.
711 However, the device map file is not entirely obsolete yet, and it is
712 used for overriding when current environment is different from the one on boot.
713 Most common case is if you use a partition or logical volume as a disk for
714 virtual machine.  You can put any comments in the file if needed,
715 as the GRUB utilities assume that a line is just a comment if
716 the first character is @samp{#}.
719 @node BIOS installation
720 @section BIOS installation
722 @heading MBR
724 The partition table format traditionally used on PC BIOS platforms is called
725 the Master Boot Record (MBR) format; this is the format that allows up to
726 four primary partitions and additional logical partitions.  With this
727 partition table format, there are two ways to install GRUB: it can be
728 embedded in the area between the MBR and the first partition (called by
729 various names, such as the "boot track", "MBR gap", or "embedding area", and
730 which is usually at least 31 KiB), or the core image can be installed in a
731 file system and a list of the blocks that make it up can be stored in the
732 first sector of that partition.
734 Each of these has different problems.  There is no way to reserve space in
735 the embedding area with complete safety, and some proprietary software is
736 known to use it to make it difficult for users to work around licensing
737 restrictions; and systems are sometimes partitioned without leaving enough
738 space before the first partition.  On the other hand, installing to a
739 filesystem means that GRUB is vulnerable to its blocks being moved around by
740 filesystem features such as tail packing, or even by aggressive fsck
741 implementations, so this approach is quite fragile; and this approach can
742 only be used if the @file{/boot} filesystem is on the same disk that the
743 BIOS boots from, so that GRUB does not have to rely on guessing BIOS drive
744 numbers.
746 The GRUB development team generally recommends embedding GRUB before the
747 first partition, unless you have special requirements.  You must ensure that
748 the first partition starts at least 31 KiB (63 sectors) from the start of
749 the disk; on modern disks, it is often a performance advantage to align
750 partitions on larger boundaries anyway, so the first partition might start 1
751 MiB from the start of the disk.
753 @heading GPT
755 Some newer systems use the GUID Partition Table (GPT) format.  This was
756 specified as part of the Extensible Firmware Interface (EFI), but it can
757 also be used on BIOS platforms if system software supports it; for example,
758 GRUB and GNU/Linux can be used in this configuration.  With this format, it
759 is possible to reserve a whole partition for GRUB, called the BIOS Boot
760 Partition.  GRUB can then be embedded into that partition without the risk
761 of being overwritten by other software and without being contained in a
762 filesystem which might move its blocks around.
764 When creating a BIOS Boot Partition on a GPT system, you should make sure
765 that it is at least 31 KiB in size.  (GPT-formatted disks are not usually
766 particularly small, so we recommend that you make it larger than the bare
767 minimum, such as 1 MiB, to allow plenty of room for growth.)  You must also
768 make sure that it has the proper partition type.  Using GNU Parted, you can
769 set this using a command such as the following:
771 @example
772 # @kbd{parted /dev/@var{disk} set @var{partition-number} bios_grub on}
773 @end example
775 If you are using gdisk, set the partition type to @samp{0xEF02}.  With
776 partitioning programs that require setting the GUID directly, it should be
777 @samp{21686148-6449-6e6f-744e656564454649}.
779 @strong{Caution:} Be very careful which partition you select!  When GRUB
780 finds a BIOS Boot Partition during installation, it will automatically
781 overwrite part of it.  Make sure that the partition does not contain any
782 other data.
785 @node Booting
786 @chapter Booting
788 GRUB can load Multiboot-compliant kernels in a consistent way,
789 but for some free operating systems you need to use some OS-specific
790 magic.
792 @menu
793 * General boot methods::        How to boot OSes with GRUB generally
794 * Loopback booting::            Notes on booting from loopbacks
795 * OS-specific notes::           Notes on some operating systems
796 @end menu
799 @node General boot methods
800 @section How to boot operating systems
802 GRUB has two distinct boot methods. One of the two is to load an
803 operating system directly, and the other is to chain-load another boot
804 loader which then will load an operating system actually. Generally
805 speaking, the former is more desirable, because you don't need to
806 install or maintain other boot loaders and GRUB is flexible enough to
807 load an operating system from an arbitrary disk/partition. However,
808 the latter is sometimes required, since GRUB doesn't support all the
809 existing operating systems natively.
811 @menu
812 * Loading an operating system directly::
813 * Chain-loading::
814 @end menu
817 @node Loading an operating system directly
818 @subsection How to boot an OS directly with GRUB
820 Multiboot (@pxref{Top, Multiboot Specification, Motivation, multiboot,
821 The Multiboot Specification}) is the native format supported by GRUB.
822 For the sake of convenience, there is also support for Linux, FreeBSD,
823 NetBSD and OpenBSD. If you want to boot other operating systems, you
824 will have to chain-load them (@pxref{Chain-loading}).
826 FIXME: this section is incomplete.
828 @enumerate
829 @item
830 Run the command @command{boot} (@pxref{boot}).
831 @end enumerate
833 However, DOS and Windows have some deficiencies, so you might have to
834 use more complicated instructions. @xref{DOS/Windows}, for more
835 information.
838 @node Chain-loading
839 @subsection Chain-loading an OS
841 Operating systems that do not support Multiboot and do not have specific
842 support in GRUB (specific support is available for Linux, FreeBSD, NetBSD
843 and OpenBSD) must be chain-loaded, which involves loading another boot
844 loader and jumping to it in real mode.
846 The @command{chainloader} command (@pxref{chainloader}) is used to set this
847 up.  It is normally also necessary to load some GRUB modules and set the
848 appropriate root device.  Putting this together, we get something like this,
849 for a Windows system on the first partition of the first hard disk:
851 @verbatim
852 menuentry "Windows" {
853         insmod chain
854         insmod ntfs
855         set root=(hd0,1)
856         chainloader +1
858 @end verbatim
859 @c FIXME: document UUIDs.
861 On systems with multiple hard disks, an additional workaround may be
862 required.  @xref{DOS/Windows}.
864 Chain-loading is only supported on PC BIOS and EFI platforms.
866 @node Loopback booting
867 @section Loopback booting
868 GRUB is able to read from an image (be it one of CD or HDD) stored on
869 any of its accessible storages (refer to @pxref{loopback} command).
870 However the OS itself should be able to find its root. This usually
871 involves running a userspace program running before the real root
872 is discovered. This is achieved by GRUB loading a specially made
873 small image and passing it as ramdisk to the kernel. This is achieved
874 by commands @command{kfreebsd_module}, @command{knetbsd_module_elf},
875 @command{kopenbsd_ramdisk}, @command{initrd} (@pxref{initrd}),
876 @command{initrd16} (@pxref{initrd}), @command{multiboot_module},
877 @command{multiboot2_module} or @command{xnu_ramdisk}
878 depending on the loader. Note that for knetbsd the image must be put
879 inside miniroot.kmod and the whole miniroot.kmod has to be loaded. In
880 kopenbsd payload this is disabled by default. Aditionally behaviour of
881 initial ramdisk depends on command line options. Several distributors provide
882 the image for this purpose or it's integrated in their standard ramdisk and
883 activated by special option. Consult your kernel and distribution manual for
884 more details. Other loaders like appleloader, chainloader (BIOS, EFI, coreboot),
885 freedos, ntldr and plan9 provide no possibility of loading initial ramdisk and
886 as far as author is aware the payloads in question don't support either initial
887 ramdisk or discovering loopback boot in other way and as such not bootable this
888 way. Please consider alternative boot methods like copying all files
889 from the image to actual partition. Consult your OS documentation for
890 more details
892 @node OS-specific notes
893 @section Some caveats on OS-specific issues
895 Here, we describe some caveats on several operating systems.
897 @menu
898 * GNU/Hurd::
899 * GNU/Linux::
900 * DOS/Windows::
901 @end menu
904 @node GNU/Hurd
905 @subsection GNU/Hurd
907 Since GNU/Hurd is Multiboot-compliant, it is easy to boot it; there is
908 nothing special about it. But do not forget that you have to specify a
909 root partition to the kernel.
911 @enumerate
912 @item
913 Set GRUB's root device to the same drive as GNU/Hurd's.  The command
914 @code{search --set=root --file /boot/gnumach.gz} or similar may help you
915 (@pxref{search}).
917 @item 
918 Load the kernel and the modules, like this:
920 @example
921 @group
922 grub> @kbd{multiboot /boot/gnumach.gz root=device:hd0s1}
923 grub> @kbd{module  /hurd/ext2fs.static ext2fs --readonly \
924                    --multiboot-command-line='$@{kernel-command-line@}' \
925                    --host-priv-port='$@{host-port@}' \
926                    --device-master-port='$@{device-port@}' \
927                    --exec-server-task='$@{exec-task@}' -T typed '$@{root@}' \
928                    '$(task-create)' '$(task-resume)'}
929 grub> @kbd{module /lib/ld.so.1 exec /hurd/exec '$(exec-task=task-create)'}
930 @end group
931 @end example
933 @item
934 Finally, run the command @command{boot} (@pxref{boot}).
935 @end enumerate
938 @node GNU/Linux
939 @subsection GNU/Linux
941 It is relatively easy to boot GNU/Linux from GRUB, because it somewhat
942 resembles to boot a Multiboot-compliant OS.
944 @enumerate
945 @item
946 Set GRUB's root device to the same drive as GNU/Linux's.  The command
947 @code{search --set=root --file /vmlinuz} or similar may help you
948 (@pxref{search}).
950 @item
951 Load the kernel using the command @command{linux} (@pxref{linux}):
953 @example
954 grub> @kbd{linux /vmlinuz root=/dev/sda1}
955 @end example
957 If you need to specify some kernel parameters, just append them to the
958 command.  For example, to set @option{acpi} to @samp{off}, do this:
960 @example
961 grub> @kbd{linux /vmlinuz root=/dev/sda1 acpi=off}
962 @end example
964 See the documentation in the Linux source tree for complete information on
965 the available options.
967 With @command{linux} GRUB uses 32-bit protocol. Some BIOS services like APM
968 or EDD aren't available with this protocol. In this case you need to use
969 @command{linux16}
971 @example
972 grub> @kbd{linux16 /vmlinuz root=/dev/sda1 acpi=off}
973 @end example 
975 @item
976 If you use an initrd, execute the command @command{initrd} (@pxref{initrd})
977 after @command{linux}:
979 @example
980 grub> @kbd{initrd /initrd}
981 @end example
983 If you used @command{linux16} you need to use @command{initrd16}:
985 @example
986 grub> @kbd{initrd16 /initrd}
987 @end example
989 @item
990 Finally, run the command @command{boot} (@pxref{boot}).
991 @end enumerate
993 @strong{Caution:} If you use an initrd and specify the @samp{mem=}
994 option to the kernel to let it use less than actual memory size, you
995 will also have to specify the same memory size to GRUB. To let GRUB know
996 the size, run the command @command{uppermem} @emph{before} loading the
997 kernel. @xref{uppermem}, for more information.
1000 @node DOS/Windows
1001 @subsection DOS/Windows
1003 GRUB cannot boot DOS or Windows directly, so you must chain-load them
1004 (@pxref{Chain-loading}). However, their boot loaders have some critical
1005 deficiencies, so it may not work to just chain-load them. To overcome
1006 the problems, GRUB provides you with two helper functions.
1008 If you have installed DOS (or Windows) on a non-first hard disk, you
1009 have to use the disk swapping technique, because that OS cannot boot
1010 from any disks but the first one. The workaround used in GRUB is the
1011 command @command{drivemap} (@pxref{drivemap}), like this:
1013 @example
1014 drivemap -s (hd0) (hd1)
1015 @end example
1017 This performs a @dfn{virtual} swap between your first and second hard
1018 drive.
1020 @strong{Caution:} This is effective only if DOS (or Windows) uses BIOS
1021 to access the swapped disks. If that OS uses a special driver for the
1022 disks, this probably won't work.
1024 Another problem arises if you installed more than one set of DOS/Windows
1025 onto one disk, because they could be confused if there are more than one
1026 primary partitions for DOS/Windows. Certainly you should avoid doing
1027 this, but there is a solution if you do want to do so. Use the partition
1028 hiding/unhiding technique.
1030 If GRUB @dfn{hides} a DOS (or Windows) partition (@pxref{parttool}), DOS (or
1031 Windows) will ignore the partition. If GRUB @dfn{unhides} a DOS (or Windows)
1032 partition, DOS (or Windows) will detect the partition. Thus, if you have
1033 installed DOS (or Windows) on the first and the second partition of the
1034 first hard disk, and you want to boot the copy on the first partition, do
1035 the following:
1037 @example
1038 @group
1039 parttool (hd0,1) hidden-
1040 parttool (hd0,2) hidden+
1041 set root=(hd0,1)
1042 chainloader +1
1043 parttool @verb{'${root}'} boot+
1044 boot
1045 @end group
1046 @end example
1049 @node Configuration
1050 @chapter Writing your own configuration file
1052 GRUB is configured using @file{grub.cfg}, usually located under
1053 @file{/boot/grub}.  This file is quite flexible, but most users will not
1054 need to write the whole thing by hand.
1056 @menu
1057 * Simple configuration::        Recommended for most users
1058 * Shell-like scripting::        For power users and developers
1059 * Multi-boot manual config::    For non-standard multi-OS scenarios
1060 * Embedded configuration::      Embedding a configuration file into GRUB
1061 @end menu
1064 @node Simple configuration
1065 @section Simple configuration handling
1067 The program @command{grub-mkconfig} (@pxref{Invoking grub-mkconfig})
1068 generates @file{grub.cfg} files suitable for most cases.  It is suitable for
1069 use when upgrading a distribution, and will discover available kernels and
1070 attempt to generate menu entries for them.
1072 @command{grub-mkconfig} does have some limitations.  While adding extra
1073 custom menu entries to the end of the list can be done by editing
1074 @file{/etc/grub.d/40_custom} or creating @file{/boot/grub/custom.cfg},
1075 changing the order of menu entries or changing their titles may require
1076 making complex changes to shell scripts stored in @file{/etc/grub.d/}.  This
1077 may be improved in the future.  In the meantime, those who feel that it
1078 would be easier to write @file{grub.cfg} directly are encouraged to do so
1079 (@pxref{Booting}, and @ref{Shell-like scripting}), and to disable any system
1080 provided by their distribution to automatically run @command{grub-mkconfig}.
1082 The file @file{/etc/default/grub} controls the operation of
1083 @command{grub-mkconfig}.  It is sourced by a shell script, and so must be
1084 valid POSIX shell input; normally, it will just be a sequence of
1085 @samp{KEY=value} lines, but if the value contains spaces or other special
1086 characters then it must be quoted.  For example:
1088 @example
1089 GRUB_TERMINAL_INPUT="console serial"
1090 @end example
1092 Valid keys in @file{/etc/default/grub} are as follows:
1094 @table @samp
1095 @item GRUB_DEFAULT
1096 The default menu entry.  This may be a number, in which case it identifies
1097 the Nth entry in the generated menu counted from zero, or the title of a
1098 menu entry, or the special string @samp{saved}.  Using the title may be
1099 useful if you want to set a menu entry as the default even though there may
1100 be a variable number of entries before it.
1102 For example, if you have:
1104 @verbatim
1105 menuentry 'Example GNU/Linux distribution' --class gnu-linux {
1106         ...
1108 @end verbatim
1110 then you can make this the default using:
1112 @example
1113 GRUB_DEFAULT='Example GNU/Linux distribution'
1114 @end example
1116 If you set this to @samp{saved}, then the default menu entry will be that
1117 saved by @samp{GRUB_SAVEDEFAULT}, @command{grub-set-default}, or
1118 @command{grub-reboot}.
1120 The default is @samp{0}.
1122 @item GRUB_SAVEDEFAULT
1123 If this option is set to @samp{true}, then, when an entry is selected, save
1124 it as a new default entry for use by future runs of GRUB.  This is only
1125 useful if @samp{GRUB_DEFAULT=saved}; it is a separate option because
1126 @samp{GRUB_DEFAULT=saved} is useful without this option, in conjunction with
1127 @command{grub-set-default} or @command{grub-reboot}.  Unset by default.
1128 This option relies on the environment block, which may not be available in
1129 all situations (@pxref{Environment block}).
1131 @item GRUB_TIMEOUT
1132 Boot the default entry this many seconds after the menu is displayed, unless
1133 a key is pressed.  The default is @samp{5}.  Set to @samp{0} to boot
1134 immediately without displaying the menu, or to @samp{-1} to wait
1135 indefinitely.
1137 @item GRUB_HIDDEN_TIMEOUT
1138 Wait this many seconds for a key to be pressed before displaying the menu.
1139 If no key is pressed during that time, display the menu for the number of
1140 seconds specified in GRUB_TIMEOUT before booting the default entry. We expect
1141 that most people who use GRUB_HIDDEN_TIMEOUT will want to have GRUB_TIMEOUT set 
1142 to @samp{0} so that the menu is not displayed at all unless a key is pressed.
1143 Unset by default.
1145 @item GRUB_HIDDEN_TIMEOUT_QUIET
1146 In conjunction with @samp{GRUB_HIDDEN_TIMEOUT}, set this to @samp{true} to
1147 suppress the verbose countdown while waiting for a key to be pressed before
1148 displaying the menu.  Unset by default.
1150 @item GRUB_DEFAULT_BUTTON
1151 @itemx GRUB_TIMEOUT_BUTTON
1152 @itemx GRUB_HIDDEN_TIMEOUT_BUTTON
1153 @itemx GRUB_BUTTON_CMOS_ADDRESS
1154 Variants of the corresponding variables without the @samp{_BUTTON} suffix,
1155 used to support vendor-specific power buttons.  @xref{Vendor power-on keys}.
1157 @item GRUB_DISTRIBUTOR
1158 Set by distributors of GRUB to their identifying name.  This is used to
1159 generate more informative menu entry titles.
1161 @item GRUB_TERMINAL_INPUT
1162 Select the terminal input device.  You may select multiple devices here,
1163 separated by spaces.
1165 Valid terminal input names depend on the platform, but may include
1166 @samp{console} (PC BIOS and EFI consoles), @samp{serial} (serial terminal),
1167 @samp{ofconsole} (Open Firmware console), @samp{at_keyboard} (PC AT
1168 keyboard, mainly useful with Coreboot), or @samp{usb_keyboard} (USB keyboard
1169 using the HID Boot Protocol, for cases where the firmware does not handle
1170 this).
1172 The default is to use the platform's native terminal input.
1174 @item GRUB_TERMINAL_OUTPUT
1175 Select the terminal output device.  You may select multiple devices here,
1176 separated by spaces.
1178 Valid terminal output names depend on the platform, but may include
1179 @samp{console} (PC BIOS and EFI consoles), @samp{serial} (serial terminal),
1180 @samp{gfxterm} (graphics-mode output), @samp{ofconsole} (Open Firmware
1181 console), or @samp{vga_text} (VGA text output, mainly useful with Coreboot).
1183 The default is to use the platform's native terminal output.
1185 @item GRUB_TERMINAL
1186 If this option is set, it overrides both @samp{GRUB_TERMINAL_INPUT} and
1187 @samp{GRUB_TERMINAL_OUTPUT} to the same value.
1189 @item GRUB_SERIAL_COMMAND
1190 A command to configure the serial port when using the serial console.
1191 @xref{serial}.  Defaults to @samp{serial}.
1193 @item GRUB_CMDLINE_LINUX
1194 Command-line arguments to add to menu entries for the Linux kernel.
1196 @item GRUB_CMDLINE_LINUX_DEFAULT
1197 Unless @samp{GRUB_DISABLE_RECOVERY} is set to @samp{true}, two menu
1198 entries will be generated for each Linux kernel: one default entry and one
1199 entry for recovery mode.  This option lists command-line arguments to add
1200 only to the default menu entry, after those listed in
1201 @samp{GRUB_CMDLINE_LINUX}.
1203 @item GRUB_CMDLINE_NETBSD
1204 @itemx GRUB_CMDLINE_NETBSD_DEFAULT
1205 As @samp{GRUB_CMDLINE_LINUX} and @samp{GRUB_CMDLINE_LINUX_DEFAULT}, but for
1206 NetBSD.
1208 @item GRUB_CMDLINE_GNUMACH
1209 As @samp{GRUB_CMDLINE_LINUX}, but for GNU Mach.
1211 @item GRUB_CMDLINE_XEN
1212 @itemx GRUB_CMDLINE_XEN_DEFAULT
1213 The values of these options are appended to the values of
1214 @samp{GRUB_CMDLINE_LINUX} and @samp{GRUB_CMDLINE_LINUX_DEFAULT} for Linux
1215 and Xen menu entries.
1217 @item GRUB_CMDLINE_LINUX_XEN_REPLACE
1218 @item GRUB_CMDLINE_LINUX_XEN_REPLACE_DEFAULT
1219 The values of these options replace the values of @samp{GRUB_CMDLINE_LINUX}
1220 and @samp{GRUB_CMDLINE_LINUX_DEFAULT} for Linux and Xen menu entries.
1222 @item GRUB_DISABLE_LINUX_UUID
1223 Normally, @command{grub-mkconfig} will generate menu entries that use
1224 universally-unique identifiers (UUIDs) to identify the root filesystem to
1225 the Linux kernel, using a @samp{root=UUID=...} kernel parameter.  This is
1226 usually more reliable, but in some cases it may not be appropriate.  To
1227 disable the use of UUIDs, set this option to @samp{true}.
1229 @item GRUB_DISABLE_RECOVERY
1230 If this option is set to @samp{true}, disable the generation of recovery
1231 mode menu entries.
1233 @item GRUB_VIDEO_BACKEND
1234 If graphical video support is required, either because the @samp{gfxterm}
1235 graphical terminal is in use or because @samp{GRUB_GFXPAYLOAD_LINUX} is set,
1236 then @command{grub-mkconfig} will normally load all available GRUB video
1237 drivers and use the one most appropriate for your hardware.  If you need to
1238 override this for some reason, then you can set this option.
1240 After @command{grub-install} has been run, the available video drivers are
1241 listed in @file{/boot/grub/video.lst}.
1243 @item GRUB_GFXMODE
1244 Set the resolution used on the @samp{gfxterm} graphical terminal.  Note that
1245 you can only use modes which your graphics card supports via VESA BIOS
1246 Extensions (VBE), so for example native LCD panel resolutions may not be
1247 available.  The default is @samp{auto}, which tries to select a preferred
1248 resolution.  @xref{gfxmode}.
1250 @item GRUB_BACKGROUND
1251 Set a background image for use with the @samp{gfxterm} graphical terminal.
1252 The value of this option must be a file readable by GRUB at boot time, and
1253 it must end with @file{.png}, @file{.tga}, @file{.jpg}, or @file{.jpeg}.
1254 The image will be scaled if necessary to fit the screen.
1256 @item GRUB_THEME
1257 Set a theme for use with the @samp{gfxterm} graphical terminal.
1259 @item GRUB_GFXPAYLOAD_LINUX
1260 Set to @samp{text} to force the Linux kernel to boot in normal text mode,
1261 @samp{keep} to preserve the graphics mode set using @samp{GRUB_GFXMODE},
1262 @samp{@var{width}x@var{height}}[@samp{x@var{depth}}] to set a particular
1263 graphics mode, or a sequence of these separated by commas or semicolons to
1264 try several modes in sequence.  @xref{gfxpayload}.
1266 Depending on your kernel, your distribution, your graphics card, and the
1267 phase of the moon, note that using this option may cause GNU/Linux to suffer
1268 from various display problems, particularly during the early part of the
1269 boot sequence.  If you have problems, set this option to @samp{text} and
1270 GRUB will tell Linux to boot in normal text mode.
1272 @item GRUB_DISABLE_OS_PROBER
1273 Normally, @command{grub-mkconfig} will try to use the external
1274 @command{os-prober} program, if installed, to discover other operating
1275 systems installed on the same system and generate appropriate menu entries
1276 for them.  Set this option to @samp{true} to disable this.
1278 @item GRUB_INIT_TUNE
1279 Play a tune on the speaker when GRUB starts.  This is particularly useful
1280 for users unable to see the screen.  The value of this option is passed
1281 directly to @ref{play}.
1283 @item GRUB_BADRAM
1284 If this option is set, GRUB will issue a @ref{badram} command to filter
1285 out specified regions of RAM.
1287 @item GRUB_PRELOAD_MODULES
1288 This option may be set to a list of GRUB module names separated by spaces.
1289 Each module will be loaded as early as possible, at the start of
1290 @file{grub.cfg}.
1292 @end table
1294 For more detailed customisation of @command{grub-mkconfig}'s output, you may
1295 edit the scripts in @file{/etc/grub.d} directly.
1296 @file{/etc/grub.d/40_custom} is particularly useful for adding entire custom
1297 menu entries; simply type the menu entries you want to add at the end of
1298 that file, making sure to leave at least the first two lines intact.
1301 @node Shell-like scripting
1302 @section Writing full configuration files directly
1304 @c Some of this section is derived from the GNU Bash manual page, also
1305 @c copyrighted by the FSF.
1307 @file{grub.cfg} is written in GRUB's built-in scripting language, which has
1308 a syntax quite similar to that of GNU Bash and other Bourne shell
1309 derivatives.
1311 @heading Words
1313 A @dfn{word} is a sequence of characters considered as a single unit by
1314 GRUB.  Words are separated by @dfn{metacharacters}, which are the following
1315 plus space, tab, and newline:
1317 @example
1318 @{ @} | & $ ; < >
1319 @end example
1321 Quoting may be used to include metacharacters in words; see below.
1323 @heading Reserved words
1325 Reserved words have a special meaning to GRUB.  The following words are
1326 recognised as reserved when unquoted and either the first word of a simple
1327 command or the third word of a @code{for} command:
1329 @example
1330 ! [[ ]] @{ @}
1331 case do done elif else esac fi for function
1332 if in menuentry select then time until while
1333 @end example
1335 Not all of these reserved words have a useful purpose yet; some are reserved
1336 for future expansion.
1338 @heading Quoting
1340 Quoting is used to remove the special meaning of certain characters or
1341 words.  It can be used to treat metacharacters as part of a word, to prevent
1342 reserved words from being recognised as such, and to prevent variable
1343 expansion.
1345 There are three quoting mechanisms: the escape character, single quotes, and
1346 double quotes.
1348 A non-quoted backslash (\) is the @dfn{escape character}.  It preserves the
1349 literal value of the next character that follows, with the exception of
1350 newline.
1352 Enclosing characters in single quotes preserves the literal value of each
1353 character within the quotes.  A single quote may not occur between single
1354 quotes, even when preceded by a backslash.
1356 Enclosing characters in double quotes preserves the literal value of all
1357 characters within the quotes, with the exception of @samp{$} and @samp{\}.
1358 The @samp{$} character retains its special meaning within double quotes.
1359 The backslash retains its special meaning only when followed by one of the
1360 following characters: @samp{$}, @samp{"}, @samp{\}, or newline.  A
1361 backslash-newline pair is treated as a line continuation (that is, it is
1362 removed from the input stream and effectively ignored@footnote{Currently a
1363 backslash-newline pair within a variable name is not handled properly, so
1364 use this feature with some care.}).  A double quote may be quoted within
1365 double quotes by preceding it with a backslash.
1367 @heading Variable expansion
1369 The @samp{$} character introduces variable expansion.  The variable name to
1370 be expanded may be enclosed in braces, which are optional but serve to
1371 protect the variable to be expanded from characters immediately following it
1372 which could be interpreted as part of the name.
1374 Normal variable names begin with an alphabetic character, followed by zero
1375 or more alphanumeric characters.  These names refer to entries in the GRUB
1376 environment (@pxref{Environment}).
1378 Positional variable names consist of one or more digits.  They represent
1379 parameters passed to function calls, with @samp{$1} representing the first
1380 parameter, and so on.
1382 The special variable name @samp{?} expands to the exit status of the most
1383 recently executed command.  When positional variable names are active, other
1384 special variable names @samp{@@}, @samp{*} and @samp{#} are defined and they
1385 expand to all positional parameters with necessary quoting, positional
1386 parameters without any quoting, and positional parameter count respectively.
1388 @heading Comments
1390 A word beginning with @samp{#} causes that word and all remaining characters
1391 on that line to be ignored.
1393 @heading Simple commands
1395 A @dfn{simple command} is a sequence of words separated by spaces or tabs
1396 and terminated by a semicolon or a newline.  The first word specifies the
1397 command to be executed.  The remaining words are passed as arguments to the
1398 invoked command.
1400 The return value of a simple command is its exit status.  If the reserved
1401 word @code{!} precedes the command, then the return value is instead the
1402 logical negation of the command's exit status.
1404 @heading Compound commands
1406 A @dfn{compound command} is one of the following:
1408 @table @asis
1409 @item for @var{name} in @var{word} @dots{}; do @var{list}; done
1410 The list of words following @code{in} is expanded, generating a list of
1411 items.  The variable @var{name} is set to each element of this list in turn,
1412 and @var{list} is executed each time.  The return value is the exit status
1413 of the last command that executes.  If the expansion of the items following
1414 @code{in} results in an empty list, no commands are executed, and the return
1415 status is 0.
1417 @item if @var{list}; then @var{list}; [elif @var{list}; then @var{list};] @dots{} [else @var{list};] fi
1418 The @code{if} @var{list} is executed.  If its exit status is zero, the
1419 @code{then} @var{list} is executed.  Otherwise, each @code{elif} @var{list}
1420 is executed in turn, and if its exit status is zero, the corresponding
1421 @code{then} @var{list} is executed and the command completes.  Otherwise,
1422 the @code{else} @var{list} is executed, if present.  The exit status is the
1423 exit status of the last command executed, or zero if no condition tested
1424 true.
1426 @item while @var{cond}; do @var{list}; done
1427 @itemx until @var{cond}; do @var{list}; done
1428 The @code{while} command continuously executes the @code{do} @var{list} as
1429 long as the last command in @var{cond} returns an exit status of zero.  The
1430 @code{until} command is identical to the @code{while} command, except that
1431 the test is negated; the @code{do} @var{list} is executed as long as the
1432 last command in @var{cond} returns a non-zero exit status.  The exit status
1433 of the @code{while} and @code{until} commands is the exit status of the last
1434 @code{do} @var{list} command executed, or zero if none was executed.
1436 @item function @var{name} @{ @var{command}; @dots{} @}
1437 This defines a function named @var{name}.  The @dfn{body} of the function is
1438 the list of commands within braces, each of which must be terminated with a
1439 semicolon or a newline.  This list of commands will be executed whenever
1440 @var{name} is specified as the name of a simple command.  Function
1441 definitions do not affect the exit status in @code{$?}.  When executed, the
1442 exit status of a function is the exit status of the last command executed in
1443 the body.
1445 @item menuentry @var{title} [@option{--class=class} @dots{}] [@option{--users=users}] [@option{--unrestricted}] [@option{--hotkey=key}] @{ @var{command}; @dots{} @}
1446 @xref{menuentry}.
1447 @end table
1449 @heading Built-in Commands
1451 Some built-in commands are also provided by GRUB script to help script
1452 writers perform actions that are otherwise not possible.  For example, these
1453 include commands to jump out of a loop without fully completing it, etc.
1455 @table @asis
1456 @item break [@code{n}]
1457 Exit from within a @code{for}, @code{while}, or @code{until} loop.  If
1458 @code{n} is specified, break @code{n} levels.  @code{n} must be greater than
1459 or equal to 1.  If @code{n} is greater than the number of enclosing loops,
1460 all enclosing loops are exited.  The return value is 0 unless @code{n} is
1461 not greater than or equal to 1.
1463 @item continue [@code{n}]
1464 Resume the next iteration of the enclosing @code{for}, @code{while} or
1465 @code{until} loop.  If @code{n} is specified, resume at the @code{n}th
1466 enclosing loop.  @code{n} must be greater than or equal to 1.  If @code{n}
1467 is greater than the number of enclosing loops, the last enclosing loop (the
1468 @dfn{top-level} loop) is resumed.  The return value is 0 unless @code{n} is
1469 not greater than or equal to 1.
1471 @item return [@code{n}]
1472 Causes a function to exit with the return value specified by @code{n}.  If
1473 @code{n} is omitted, the return status is that of the last command executed
1474 in the function body.  If used outside a function the return status is
1475 false.
1477 @item shift [@code{n}]
1478 The positional parameters from @code{n}+1 @dots{} are renamed to
1479 @code{$1}@dots{}.  Parameters represented by the numbers @code{$#} down to
1480 @code{$#}-@code{n}+1 are unset.  @code{n} must be a non-negative number less
1481 than or equal to @code{$#}.  If @code{n} is 0, no parameters are changed.
1482 If @code{n} is not given, it is assumed to be 1.  If @code{n} is greater
1483 than @code{$#}, the positional parameters are not changed.  The return
1484 status is greater than zero if @code{n} is greater than @code{$#} or less
1485 than zero; otherwise 0.
1487 @end table
1489 @node Multi-boot manual config
1490 @section Multi-boot manual config
1492 Currently autogenerating config files for multi-boot environments depends on
1493 os-prober and has several shortcomings. While fixing it is scheduled for the
1494 next release, meanwhile you can make use of the power of GRUB syntax and do it
1495 yourself. A possible configuration is detailed here, feel free to adjust to your
1496 needs.
1498 First create a separate GRUB partition, big enough to hold GRUB. Some of the
1499 following entries show how to load OS installer images from this same partition,
1500 for that you obviously need to make the partition large enough to hold those
1501 images as well.
1502 Mount this partition on/mnt/boot and disable GRUB in all OSes and manually
1503 install self-compiled latest GRUB with:
1505 @code{grub-install --boot-directory=/mnt/boot /dev/sda}
1507 In all the OSes install GRUB tools but disable installing GRUB in bootsector,
1508 so you'll have menu.lst and grub.cfg available for use. Also disable os-prober
1509 use by setting:
1511 @code{GRUB_DISABLE_OS_PROBER=true}
1513 in /etc/default/grub
1515 Then write a grub.cfg (/mnt/boot/grub/grub.cfg):
1517 @example
1519 menuentry "OS using grub2" @{
1520    insmod xfs
1521    search --set=root --label OS1 --hint hd0,msdos8
1522    configfile /boot/grub/grub.cfg
1525 menuentry "OS using grub2-legacy" @{
1526    insmod ext2
1527    search --set=root --label OS2 --hint hd0,msdos6
1528    legacy_configfile /boot/grub/menu.lst
1531 menuentry "Windows XP" @{
1532    insmod ntfs
1533    search --set=root --label WINDOWS_XP --hint hd0,msdos1
1534    ntldr /ntldr
1537 menuentry "Windows 7" @{
1538    insmod ntfs
1539    search --set=root --label WINDOWS_7 --hint hd0,msdos2
1540    ntldr /bootmgr
1543 menuentry "FreeBSD" @{
1544           insmod zfs
1545           search --set=root --label freepool --hint hd0,msdos7
1546           kfreebsd /freebsd@@/boot/kernel/kernel
1547           kfreebsd_module_elf /freebsd@@/boot/kernel/opensolaris.ko
1548           kfreebsd_module_elf /freebsd@@/boot/kernel/zfs.ko
1549           kfreebsd_module /freebsd@@/boot/zfs/zpool.cache type=/boot/zfs/zpool.cache
1550           set kFreeBSD.vfs.root.mountfrom=zfs:freepool/freebsd
1551           set kFreeBSD.hw.psm.synaptics_support=1
1554 menuentry "experimental GRUB" @{
1555           search --set=root --label GRUB --hint hd0,msdos5
1556           multiboot /experimental/grub/i386-pc/core.img
1559 menuentry "Fedora 16 installer" @{
1560           search --set=root --label GRUB --hint hd0,msdos5
1561           linux /fedora/vmlinuz lang=en_US keymap=sg resolution=1280x800
1562           initrd /fedora/initrd.img
1565 menuentry "Fedora rawhide installer" @{
1566           search --set=root --label GRUB --hint hd0,msdos5
1567           linux /fedora/vmlinuz repo=ftp://mirror.switch.ch/mirror/fedora/linux/development/rawhide/x86_64 lang=en_US keymap=sg resolution=1280x800
1568           initrd /fedora/initrd.img
1571 menuentry "Debian sid installer" @{
1572           search --set=root --label GRUB --hint hd0,msdos5
1573           linux /debian/dists/sid/main/installer-amd64/current/images/hd-media/vmlinuz
1574           initrd /debian/dists/sid/main/installer-amd64/current/images/hd-media/initrd.gz
1577 @end example
1579 Notes:
1580 @itemize
1581 @item Argument to search after --label is FS LABEL. You can also use UUIDs with --fs-uuid UUID instead of --label LABEL. You could also use direct @code{root=hd0,msdosX} but this is not recommened due to device name instability.
1582 @end itemize
1584 @node Embedded configuration
1585 @section Embedding a configuration file into GRUB
1587 GRUB supports embedding a configuration file directly into the core image,
1588 so that it is loaded before entering normal mode.  This is useful, for
1589 example, when it is not straightforward to find the real configuration file,
1590 or when you need to debug problems with loading that file.
1591 @command{grub-install} uses this feature when it is not using BIOS disk
1592 functions or when installing to a different disk from the one containing
1593 @file{/boot/grub}, in which case it needs to use the @command{search}
1594 command (@pxref{search}) to find @file{/boot/grub}.
1596 To embed a configuration file, use the @option{-c} option to
1597 @command{grub-mkimage}.  The file is copied into the core image, so it may
1598 reside anywhere on the file system, and may be removed after running
1599 @command{grub-mkimage}.
1601 After the embedded configuration file (if any) is executed, GRUB will load
1602 the @samp{normal} module (@pxref{normal}), which will then read the real
1603 configuration file from @file{$prefix/grub.cfg}.  By this point, the
1604 @code{root} variable will also have been set to the root device name.  For
1605 example, @code{prefix} might be set to @samp{(hd0,1)/boot/grub}, and
1606 @code{root} might be set to @samp{hd0,1}.  Thus, in most cases, the embedded
1607 configuration file only needs to set the @code{prefix} and @code{root}
1608 variables, and then drop through to GRUB's normal processing.  A typical
1609 example of this might look like this:
1611 @example
1612 @group
1613 search.fs_uuid 01234567-89ab-cdef-0123-456789abcdef root
1614 set prefix=($root)/boot/grub
1615 @end group
1616 @end example
1618 (The @samp{search_fs_uuid} module must be included in the core image for this
1619 example to work.)
1621 In more complex cases, it may be useful to read other configuration files
1622 directly from the embedded configuration file.  This allows such things as
1623 reading files not called @file{grub.cfg}, or reading files from a directory
1624 other than that where GRUB's loadable modules are installed.  To do this,
1625 include the @samp{configfile} and @samp{normal} modules in the core image,
1626 and embed a configuration file that uses the @command{configfile} command to
1627 load another file.  The following example of this also requires the
1628 @command{echo}, @command{search_label}, and @command{test} modules to be
1629 included in the core image:
1631 @example
1632 @group
1633 search.fs_label grub root
1634 if [ -e /boot/grub/example/test1.cfg ]; then
1635     set prefix=($root)/boot/grub
1636     configfile /boot/grub/example/test1.cfg
1637 else
1638     if [ -e /boot/grub/example/test2.cfg ]; then
1639         set prefix=($root)/boot/grub
1640         configfile /boot/grub/example/test2.cfg
1641     else
1642         echo "Could not find an example configuration file!"
1643     fi
1645 @end group
1646 @end example
1648 The embedded configuration file may not contain menu entries directly, but
1649 may only read them from elsewhere using @command{configfile}.
1651 @node Theme file format
1652 @chapter Theme file format
1653 @section Introduction
1654 The GRUB graphical menu supports themes that can customize the layout and
1655 appearance of the GRUB boot menu.  The theme is configured through a plain
1656 text file that specifies the layout of the various GUI components (including
1657 the boot menu, timeout progress bar, and text messages) as well as the
1658 appearance using colors, fonts, and images. Example is available in docs/example_theme.txt
1660 @section Theme Elements
1661 @subsection Colors
1663 Colors can be specified in several ways:
1665 @itemize
1666 @item HTML-style ``#RRGGBB'' or ``#RGB'' format, where *R*, *G*, and *B* are hexadecimal digits (e.g., ``#8899FF'')
1667 @item as comma-separated decimal RGB values (e.g., ``128, 128, 255'')
1668 @item with ``SVG 1.0 color names'' (e.g., ``cornflowerblue'') which must be specified in lowercase.
1669 @end itemize
1670 @subsection Fonts
1671 The fonts GRUB uses ``PFF2 font format'' bitmap fonts.  Fonts are specified
1672 with full font names.  Currently there is no
1673 provision for a preference list of fonts, or deriving one font from another.
1674 Fonts are loaded with the ``loadfont'' command in GRUB.  To see the list of
1675 loaded fonts, execute the ``lsfonts'' command.  If there are too many fonts to
1676 fit on screen, do ``set pager=1'' before executing ``lsfonts''.
1679 @subsection Progress Bar
1681 @float Figure, Pixmap-styled progress bar
1682 @c @image{Theme_progress_bar,,,,png}
1683 @end float
1685 @float Figure, Plain progress bar, drawn with solid color.
1686 @c @image{Theme_progress_bar_filled,,,,png}
1687 @end float
1689 Progress bars are used to display the remaining time before GRUB boots the
1690 default menu entry.  To create a progress bar that will display the remaining
1691 time before automatic boot, simply create a ``progress_bar'' component with
1692 the id ``__timeout__''.  This indicates to GRUB that the progress bar should
1693 be updated as time passes, and it should be made invisible if the countdown to
1694 automatic boot is interrupted by the user.
1696 Progress bars may optionally have text displayed on them.  This text is
1697 controlled by variable ``text'' which contains a printf template with the
1698 only argument %d is the number of seconds remaining. Additionally special
1699 values ``@@TIMEOUT_NOTIFICATION_SHORT@@'', ``@@TIMEOUT_NOTIFICATION_MIDDLE@@'',
1700 ``@@TIMEOUT_NOTIFICATION_LONG@@'' are replaced with standard and translated
1701 templates.
1703 @subsection Circular Progress Indicator
1705 @c @image{Theme_circular_progress,,,,.png}
1707 The circular progress indicator functions similarly to the progress bar.  When
1708 given an id of ``__timeout__'', GRUB updates the circular progress indicator's
1709 value to indicate the time remaining.  For the circular progress indicator,
1710 there are two images used to render it:  the *center* image, and the *tick*
1711 image.  The center image is rendered in the center of the component, while the
1712 tick image is used to render each mark along the circumference of the
1713 indicator.
1716 @subsection Labels
1718 Text labels can be placed on the boot screen.  The font, color, and horizontal
1719 alignment can be specified for labels.  If a label is given the id
1720 ``__timeout__'', then the ``text'' property for that label is also updated
1721 with a message informing the user of the number of seconds remaining until
1722 automatic boot.  This is useful in case you want the text displayed somewhere
1723 else instead of directly on the progress bar.
1726 @subsection Boot Menu
1728 @c @image{Theme_boot_menu,,,,.png}
1730 The boot menu where GRUB displays the menu entries from the ``grub.cfg'' file.
1731 It is a list of items, where each item has a title and an optional icon.  The
1732 icon is selected based on the *classes* specified for the menu entry.  If
1733 there is a PNG file named ``myclass.png'' in the ``grub/themes/icons''
1734 directory, it will be displayed for items which have the class *myclass*.  The
1735 boot menu can be customized in several ways, such as the font and color used
1736 for the menu entry title, and by specifying styled boxes for the menu itself
1737 and for the selected item highlight.
1740 @subsection Styled Boxes
1742 One of the most important features for customizing the layout is the use of
1743  *styled boxes*.  A styled box is composed of 9 rectangular (and potentially
1744 empty) regions, which are used to seamlessly draw the styled box on screen:
1746 @multitable @columnfractions 0.3 0.3 0.3
1747 @item Northwest (nw) @tab North (n)  @tab Northeast (ne)
1748 @item West (w)       @tab Center (c) @tab East (e)
1749 @item Southwest (sw) @tab South (s)  @tab Southeast (se)
1750 @end multitable
1752 To support any size of box on screen, the center slice and the slices for the
1753 top, bottom, and sides are all scaled to the correct size for the component on
1754 screen, using the following rules:
1756 @enumerate
1757 @item The edge slices (north, south, east, and west) are scaled in the direction of the edge they are adjacent to.  For instance, the west slice is scaled vertically.
1758 @item The corner slices (northwest, northeast, southeast, and southwest) are not scaled.
1759 @item The center slice is scaled to fill the remaining space in the middle.
1760 @end enumerate
1762 As an example of how an image might be sliced up, consider the styled box
1763 used for a terminal view.
1765 @float Figure, An example of the slices (in red) used for a terminal window. This drawing was created and sliced in Inkscape_, as the next section explains.
1766 @c @image{Box_slice_example_terminal,,,,.png}
1767 @end float
1768    
1769 @subsection Creating Styled Box Images
1771 The Inkscape_ scalable vector graphics editor is a very useful tool for
1772 creating styled box images.  One process that works well for slicing a drawing
1773 into the necessary image slices is:
1775 @enumerate
1776 @item Create or open the drawing you'd like use.
1777 @item Create a new layer on the top of the layer stack.  Make it visible.  Select this layer as the current layer.
1778 @item Draw 9 rectangles on your drawing where you'd like the slices to be.  Clear the fill option, and set the stroke to 1 pixel wide solid stroke.  The corners of the slices must meet precisely; if it is off by a single pixel, it will probably be evident when the styled box is rendered in the GRUB menu.  You should probably go to File | Document Properties | Grids and enable a grid or create a guide (click on one of the rulers next to the drawing and drag over the drawing; release the mouse button to place the guide) to help place the rectangles precisely.
1779 @item Right click on the center slice rectangle and choose Object Properties. Change the "Id" to ``slice_c`` and click Set.  Repeat this for the remaining 8 rectangles, giving them Id values of ``slice_n``, ``slice_ne``, ``slice_e``, and so on according to the location.
1780 @item Save the drawing.
1781 @item Select all the slice rectangles.  With the slice layer selected, you can simply press Ctrl+A to select all rectangles.  The status bar should indicate that 9 rectangles are selected.
1782 @item Click the layer hide icon for the slice layer in the layer palette.  The rectangles will remain selected, even though they are hidden.
1783 @item Choose File | Export Bitmap and check the *Batch export 9 selected objects* box.  Make sure that *Hide all except selected* is unchecked. click *Export*.  This will create PNG files in the same directory as the drawing, named after the slices.  These can now be used for a styled box in a GRUB theme.
1784 @end enumerate
1786 @section Theme File Manual
1788 The theme file is a plain text file.  Lines that begin with ``#`` are ignored
1789 and considered comments.  (Note: This may not be the case if the previous line
1790 ended where a value was expected.)
1792 The theme file contains two types of statements:
1793 @enumerate
1794 @item Global properties.
1795 @item Component construction.
1796 @end enumerate
1798 @subsection Global Properties
1800 @subsection Format
1802 Global properties are specified with the simple format:
1803 @itemize
1804 @item name1: value1
1805 @item name2: "value which may contain spaces"
1806 @item name3: #88F
1807 @end itemize
1809 In this example, name3 is assigned a color value.
1812 @subsection Global Property List
1814 @multitable @columnfractions 0.3 0.6
1815 @item title-text @tab Specifies the text to display at the top center of the screen as a title.
1816 @item title-font @tab Defines the font used for the title message at the top of the screen.
1817 @item title-color @tab Defines the color of the title message.
1818 @item message-font @tab Defines the font used for messages, such as when GRUB is unable to automatically boot an entry.
1819 @item message-color @tab Defines the color of the message text.
1820 @item message-bg-color @tab Defines the background color of the message text area.
1821 @item desktop-image @tab Specifies the image to use as the background.  It will be scaled to fit the screen size.
1822 @item desktop-color @tab Specifies the color for the background if *desktop-image* is not specified.
1823 @item terminal-box @tab Specifies the file name pattern for the styled box slices used for the command line terminal window.  For example, ``terminal-box: terminal_*.png'' will use the images ``terminal_c.png`` as the center area, ``terminal_n.png`` as the north (top) edge, ``terminal_nw.png`` as the northwest (upper left) corner, and so on.  If the image for any slice is not found, it will simply be left empty.
1824 @end multitable
1827 @subsection Component Construction
1829 Greater customizability comes is provided by components.  A tree of components
1830 forms the user interface.  *Containers* are components that can contain other
1831 components, and there is always a single root component which is an instance
1832 of a *canvas* container.
1834 Components are created in the theme file by prefixing the type of component
1835 with a '+' sign:
1837 @code{   + label @{ text="GRUB" font="aqui 11" color="#8FF" @} }
1839 properties of a component are specified as "name = value" (whitespace
1840 surrounding tokens is optional and is ignored) where *value* may be:
1841 @itemize
1842 @item a single word (e.g., ``align = center``, ``color = #FF8080``),
1843 @item a quoted string (e.g., ``text = "Hello, World!"``), or
1844 @item a tuple (e.g., ``preferred_size = (120, 80)``).
1845 @end itemize
1847 @subsection Component List
1849 The following is a list of the components and the properties they support.
1851 @itemize
1852 @item label
1853    A label displays a line of text.
1854    
1855    Properties:
1856    @multitable @columnfractions 0.2 0.7
1857    @item text @tab The text to display.
1858    @item font @tab The font to use for text display.
1859    @item color @tab The color of the text.
1860    @item align @tab The horizontal alignment of the text within the component. Options are ``left``, ``center``, and ``right``.
1861    @end multitable
1863 @item image
1864    A component that displays an image.  The image is scaled to fit the
1865    component, although the preferred size defaults to the image's original
1866    size unless the ``preferred_size`` property is explicitly set.
1868    Properties:
1870    @multitable @columnfractions 0.2 0.7
1871    @item file @tab The full path to the image file to load.
1872    @end multitable
1874 @item progress_bar
1875    Displays a horizontally oriented progress bar.  It can be rendered using
1876    simple solid filled rectangles, or using a pair of pixmap styled boxes.
1878    Properties:
1880    @multitable @columnfractions 0.2 0.7
1881    @item fg_color @tab The foreground color for plain solid color rendering.
1882    @item bg_color @tab The background color for plain solid color rendering.
1883    @item border_color @tab The border color for plain solid color rendering.
1884    @item text_color @tab The text color.
1885    @item show_text @tab Boolean value indicating whether or not text should be displayed on the progress bar.  If set to *false*, then no text will be displayed on the bar.  If set to any other value, text will be displayed on the bar.
1886    @item bar_style @tab The styled box specification for the frame of the progress bar. Example: ``progress_frame_*.png``
1887    @item highlight_style @tab The styled box specification for the highlighted region of the progress bar. This box will be used to paint just the highlighted region of the bar, and will be increased in size as the bar nears completion. Example: ``progress_hl_*.png``.
1888    @item text @tab The text to display on the progress bar.  If the progress bar's ID is set to ``__timeout__``, then GRUB will updated this property with an informative message as the timeout approaches.
1889    @item value @tab The progress bar current value.  Normally not set manually.
1890    @item start @tab The progress bar start value.  Normally not set manually.
1891    @item end @tab The progress bar end value.  Normally not set manually.
1892    @end multitable
1894 @item circular_progress
1895    Displays a circular progress indicator.  The appearance of this component
1896    is determined by two images:  the *center* image and the *tick* image.  The
1897    center image is generally larger and will be drawn in the center of the
1898    component.  Around the circumference of a circle within the component, the
1899    tick image will be drawn a certain number of times, depending on the
1900    properties of the component.
1902    Properties:
1904    @multitable @columnfractions 0.3 0.6
1905    @item center_bitmap
1906       @tab The file name of the image to draw in the center of the component.
1907    @item tick_bitmap
1908       @tab The file name of the image to draw for the tick marks.
1909    @item num_ticks
1910       @tab The number of ticks that make up a full circle.
1911    @item ticks_disappear
1912       @tab Boolean value indicating whether tick marks should progressively appear,
1913       or progressively disappear as *value* approaches *end*.  Specify
1914       ``true`` or ``false``.
1915    @item value
1916       @tab The progress indicator current value.  Normally not set manually.
1917    @item start
1918       @tab The progress indicator start value.  Normally not set manually.
1919    @item end
1920       @tab The progress indicator end value.  Normally not set manually.
1921    @end multitable
1922 @item boot_menu
1923    Displays the GRUB boot menu.  It allows selecting items and executing them.
1925    Properties:
1927    @multitable @columnfractions 0.4 0.5
1928    @item item_font
1929       @tab The font to use for the menu item titles.
1930    @item selected_item_font
1931       @tab The font to use for the selected menu item, or ``inherit`` (the default)
1932       to use ``item_font`` for the selected menu item as well.
1933    @item item_color
1934       @tab The color to use for the menu item titles.
1935    @item selected_item_color
1936       @tab The color to use for the selected menu item, or ``inherit`` (the default)
1937       to use ``item_color`` for the selected menu item as well.
1938    @item icon_width
1939       @tab The width of menu item icons.  Icons are scaled to the specified size.
1940    @item icon_height
1941       @tab The height of menu item icons.
1942    @item item_height
1943       @tab The height of each menu item in pixels.
1944    @item item_padding
1945       @tab The amount of space in pixels to leave on each side of the menu item
1946       contents.
1947    @item item_icon_space
1948       @tab The space between an item's icon and the title text, in pixels.
1949    @item item_spacing
1950       @tab The amount of space to leave between menu items, in pixels.
1951    @item menu_pixmap_style
1952       @tab The image file pattern for the menu frame styled box.
1953       Example:  ``menu_*.png`` (this will use images such as ``menu_c.png``,
1954       ``menu_w.png``, `menu_nw.png``, etc.)
1955    @item selected_item_pixmap_style
1956       @tab The image file pattern for the selected item highlight styled box.
1957    @item scrollbar
1958       @tab Boolean value indicating whether the scroll bar should be drawn if the
1959       frame and thumb styled boxes are configured.
1960    @item scrollbar_frame
1961       @tab The image file pattern for the entire scroll bar.
1962       Example:  ``scrollbar_*.png``
1963    @item scrollbar_thumb
1964       @tab The image file pattern for the scroll bar thumb (the part of the scroll
1965       bar that moves as scrolling occurs).
1966       Example:  ``scrollbar_thumb_*.png``
1967    @item max_items_shown
1968       @tab The maximum number of items to show on the menu.  If there are more than
1969       *max_items_shown* items in the menu, the list will scroll to make all
1970       items accessible.
1971    @end multitable
1973 @item canvas
1974    Canvas is a container that allows manual placement of components within it.
1975    It does not alter the positions of its child components.  It assigns all
1976    child components their preferred sizes.
1978 @item hbox
1979    The *hbox* container lays out its children from left to right, giving each
1980    one its preferred width.  The height of each child is set to the maximum of
1981    the preferred heights of all children.
1982    
1983 @item vbox
1984    The *vbox* container lays out its children from top to bottom, giving each
1985    one its preferred height.  The width of each child is set to the maximum of
1986    the preferred widths of all children.
1987 @end itemize
1990 @subsection Common properties
1992 The following properties are supported by all components:
1993 @table @samp
1994 @item left
1995      The distance from the left border of container to left border of the object in either of three formats:
1996         @multitable @columnfractions 0.2 0.7
1997              @item x @tab Value in pixels
1998              @item p% @tab Percentage
1999              @item p%+x @tab mixture of both
2000         @end multitable
2001 @item top
2002       The distance from the left border of container to left border of the object in same format.
2003 @item width
2004       The width of object in same format.
2005 @item height
2006       The height of object in same format.
2007 @item id 
2008    The identifier for the component.  This can be any arbitrary string.
2009    The ID can be used by scripts to refer to various components in the GUI
2010    component tree.  Currently, there is one special ID value that GRUB
2011    recognizes:
2013    @multitable @columnfractions 0.2 0.7
2014    @item ``__timeout__`` @tab Any component with this ID will have its *text*, *start*, *end*, *value*, and *visible* properties set by GRUB when it is counting down to an automatic boot of the default menu entry.
2015    @end multitable
2016 @end table
2020 @node Network
2021 @chapter Booting GRUB from the network
2023 The following instructions only work on PC BIOS systems where the Preboot
2024 eXecution Environment (PXE) is available.
2026 To generate a PXE boot image, run:
2028 @example
2029 @group
2030 grub-mkimage --format=i386-pc-pxe --output=grub.pxe --prefix='(pxe)/boot/grub' pxe pxecmd
2031 @end group
2032 @end example
2034 Copy @file{grub.pxe}, @file{/boot/grub/*.mod}, and @file{/boot/grub/*.lst}
2035 to the PXE (TFTP) server, ensuring that @file{*.mod} and @file{*.lst} are
2036 accessible via the @file{/boot/grub/} path from the TFTP server root.  Set
2037 the DHCP server configuration to offer @file{grub.pxe} as the boot file (the
2038 @samp{filename} option in ISC dhcpd).
2040 You can also use the @command{grub-mknetdir} utility to generate an image
2041 and a GRUB directory tree, rather than copying files around manually.
2043 After GRUB has started, files on the TFTP server will be accessible via the
2044 @samp{(pxe)} device.
2046 The server and gateway IP address can be controlled by changing the
2047 @samp{(pxe)} device name to @samp{(pxe:@var{server-ip})} or
2048 @samp{(pxe:@var{server-ip}:@var{gateway-ip})}.  Note that this should be
2049 changed both in the prefix and in any references to the device name in the
2050 configuration file.
2052 GRUB provides several environment variables which may be used to inspect or
2053 change the behaviour of the PXE device:
2055 @table @samp
2056 @item net_pxe_ip
2057 The IP address of this machine.  Read-only.
2059 @item net_pxe_mac
2060 The network interface's MAC address.  Read-only.
2062 @item net_pxe_hostname
2063 The client host name provided by DHCP.  Read-only.
2065 @item net_pxe_domain
2066 The client domain name provided by DHCP.  Read-only.
2068 @item net_pxe_rootpath
2069 The path to the client's root disk provided by DHCP.  Read-only.
2071 @item net_pxe_extensionspath
2072 The path to additional DHCP vendor extensions provided by DHCP.  Read-only.
2074 @item net_pxe_boot_file
2075 The boot file name provided by DHCP.  Read-only.
2077 @item net_pxe_dhcp_server_name
2078 The name of the DHCP server responsible for these boot parameters.
2079 Read-only.
2081 @item net_default_server
2082 The default server.  Read-write, although setting this is only useful
2083 before opening a network device.
2085 @end table
2088 @node Serial terminal
2089 @chapter Using GRUB via a serial line
2091 This chapter describes how to use the serial terminal support in GRUB.
2093 If you have many computers or computers with no display/keyboard, it
2094 could be very useful to control the computers through serial
2095 communications. To connect one computer with another via a serial line,
2096 you need to prepare a null-modem (cross) serial cable, and you may need
2097 to have multiport serial boards, if your computer doesn't have extra
2098 serial ports. In addition, a terminal emulator is also required, such as
2099 minicom. Refer to a manual of your operating system, for more
2100 information.
2102 As for GRUB, the instruction to set up a serial terminal is quite
2103 simple.  Here is an example:
2105 @example
2106 @group
2107 grub> @kbd{serial --unit=0 --speed=9600}
2108 grub> @kbd{terminal_input serial; terminal_output serial}
2109 @end group
2110 @end example
2112 The command @command{serial} initializes the serial unit 0 with the
2113 speed 9600bps. The serial unit 0 is usually called @samp{COM1}, so, if
2114 you want to use COM2, you must specify @samp{--unit=1} instead. This
2115 command accepts many other options, so please refer to @ref{serial},
2116 for more details.
2118 The commands @command{terminal_input} (@pxref{terminal_input}) and
2119 @command{terminal_output} (@pxref{terminal_output}) choose which type of
2120 terminal you want to use. In the case above, the terminal will be a
2121 serial terminal, but you can also pass @code{console} to the command,
2122 as @samp{terminal_input serial console}. In this case, a terminal in which
2123 you press any key will be selected as a GRUB terminal. In the example above,
2124 note that you need to put both commands on the same command line, as you
2125 will lose the ability to type commands on the console after the first
2126 command.
2128 However, note that GRUB assumes that your terminal emulator is
2129 compatible with VT100 by default. This is true for most terminal
2130 emulators nowadays, but you should pass the option @option{--dumb} to
2131 the command if your terminal emulator is not VT100-compatible or
2132 implements few VT100 escape sequences. If you specify this option then
2133 GRUB provides you with an alternative menu interface, because the normal
2134 menu requires several fancy features of your terminal.
2137 @node Vendor power-on keys
2138 @chapter Using GRUB with vendor power-on keys
2140 Some laptop vendors provide an additional power-on button which boots another
2141 OS.  GRUB supports such buttons with the @samp{GRUB_TIMEOUT_BUTTON},
2142 @samp{GRUB_DEFAULT_BUTTON}, @samp{GRUB_HIDDEN_TIMEOUT_BUTTON} and
2143 @samp{GRUB_BUTTON_CMOS_ADDRESS} variables in default/grub (@pxref{Simple
2144 configuration}).  @samp{GRUB_TIMEOUT_BUTTON}, @samp{GRUB_DEFAULT_BUTTON} and
2145 @samp{GRUB_HIDDEN_TIMEOUT_BUTTON} are used instead of the corresponding
2146 variables without the @samp{_BUTTON} suffix when powered on using the special
2147 button.  @samp{GRUB_BUTTON_CMOS_ADDRESS} is vendor-specific and partially
2148 model-specific.  Values known to the GRUB team are:
2150 @table @key
2151 @item Dell XPS M1530
2152 85:3
2153 @item Asus EeePC 1005PE 
2154 84:1 (unconfirmed)
2155 @end table
2157 To take full advantage of this function, install GRUB into the MBR
2158 (@pxref{Installing GRUB using grub-install}).
2160 If you have a laptop which has a similar feature and not in the above list
2161 could you figure your address and contribute?
2162 To discover the address do the following:
2163 @itemize
2164 @item boot normally
2165 @item
2166 @example
2167 sudo modprobe nvram
2168 sudo cat /dev/nvram | xxd > normal_button.txt
2169 @end example
2170 @item boot using vendor button
2171 @item
2172 @example
2173 sudo modprobe nvram
2174 sudo cat /dev/nvram | xxd > normal_vendor.txt
2175 @end example
2176 @end itemize
2178 Then compare these text files and find where a bit was toggled. E.g. in
2179 case of Dell XPS it was:
2180 @example
2181 byte 0x47: 20 --> 28
2182 @end example
2183 It's a bit number 3 as seen from following table:
2184 @multitable @columnfractions .2 .2
2185 @item 0 @tab 01
2186 @item 1 @tab 02
2187 @item 2 @tab 04
2188 @item 3 @tab 08
2189 @item 4 @tab 10
2190 @item 5 @tab 20
2191 @item 6 @tab 40
2192 @item 7 @tab 80
2193 @end multitable
2195 0x47 is decimal 71. Linux nvram implementation cuts first 14 bytes of
2196 CMOS. So the real byte address in CMOS is 71+14=85
2197 So complete address is 85:3
2199 @node Images
2200 @chapter GRUB image files
2202 @c FIXME: parts of this section are specific to PC BIOS right now.
2204 GRUB consists of several images: a variety of bootstrap images for starting
2205 GRUB in various ways, a kernel image, and a set of modules which are
2206 combined with the kernel image to form a core image.  Here is a short
2207 overview of them.
2209 @table @file
2210 @item boot.img
2211 On PC BIOS systems, this image is the first part of GRUB to start.  It is
2212 written to a master boot record (MBR) or to the boot sector of a partition.
2213 Because a PC boot sector is 512 bytes, the size of this image is exactly 512
2214 bytes.
2216 The sole function of @file{boot.img} is to read the first sector of the core
2217 image from a local disk and jump to it.  Because of the size restriction,
2218 @file{boot.img} cannot understand any file system structure, so
2219 @command{grub-setup} hardcodes the location of the first sector of the core
2220 image into @file{boot.img} when installing GRUB.
2222 @item diskboot.img
2223 This image is used as the first sector of the core image when booting from a
2224 hard disk.  It reads the rest of the core image into memory and starts the
2225 kernel.  Since file system handling is not yet available, it encodes the
2226 location of the core image using a block list format.
2228 @item cdboot.img
2229 This image is used as the first sector of the core image when booting from a
2230 CD-ROM drive.  It performs a similar function to @file{diskboot.img}.
2232 @item pxeboot.img
2233 This image is used as the start of the core image when booting from the
2234 network using PXE.  @xref{Network}.
2236 @item lnxboot.img
2237 This image may be placed at the start of the core image in order to make
2238 GRUB look enough like a Linux kernel that it can be booted by LILO using an
2239 @samp{image=} section.
2241 @item kernel.img
2242 This image contains GRUB's basic run-time facilities: frameworks for device
2243 and file handling, environment variables, the rescue mode command-line
2244 parser, and so on.  It is rarely used directly, but is built into all core
2245 images.
2247 @item core.img
2248 This is the core image of GRUB.  It is built dynamically from the kernel
2249 image and an arbitrary list of modules by the @command{grub-mkimage}
2250 program.  Usually, it contains enough modules to access @file{/boot/grub},
2251 and loads everything else (including menu handling, the ability to load
2252 target operating systems, and so on) from the file system at run-time.  The
2253 modular design allows the core image to be kept small, since the areas of
2254 disk where it must be installed are often as small as 32KB.
2256 @xref{BIOS installation}, for details on where the core image can be
2257 installed on PC systems.
2259 @item *.mod
2260 Everything else in GRUB resides in dynamically loadable modules.  These are
2261 often loaded automatically, or built into the core image if they are
2262 essential, but may also be loaded manually using the @command{insmod}
2263 command (@pxref{insmod}).
2264 @end table
2266 @heading For GRUB Legacy users
2268 GRUB 2 has a different design from GRUB Legacy, and so correspondences with
2269 the images it used cannot be exact.  Nevertheless, GRUB Legacy users often
2270 ask questions in the terms they are familiar with, and so here is a brief
2271 guide to how GRUB 2's images relate to that.
2273 @table @file
2274 @item stage1
2275 Stage 1 from GRUB Legacy was very similar to @file{boot.img} in GRUB 2, and
2276 they serve the same function.
2278 @item *_stage1_5
2279 In GRUB Legacy, Stage 1.5's function was to include enough filesystem code
2280 to allow the much larger Stage 2 to be read from an ordinary filesystem.  In
2281 this respect, its function was similar to @file{core.img} in GRUB 2.
2282 However, @file{core.img} is much more capable than Stage 1.5 was; since it
2283 offers a rescue shell, it is sometimes possible to recover manually in the
2284 event that it is unable to load any other modules, for example if partition
2285 numbers have changed.  @file{core.img} is built in a more flexible way,
2286 allowing GRUB 2 to support reading modules from advanced disk types such as
2287 LVM and RAID.
2289 GRUB Legacy could run with only Stage 1 and Stage 2 in some limited
2290 configurations, while GRUB 2 requires @file{core.img} and cannot work
2291 without it.
2293 @item stage2
2294 GRUB 2 has no single Stage 2 image.  Instead, it loads modules from
2295 @file{/boot/grub} at run-time.
2297 @item stage2_eltorito
2298 In GRUB 2, images for booting from CD-ROM drives are now constructed using
2299 @file{cdboot.img} and @file{core.img}, making sure that the core image
2300 contains the @samp{iso9660} module.  It is usually best to use the
2301 @command{grub-mkrescue} program for this.
2303 @item nbgrub
2304 There is as yet no equivalent for @file{nbgrub} in GRUB 2; it was used by
2305 Etherboot and some other network boot loaders.
2307 @item pxegrub
2308 In GRUB 2, images for PXE network booting are now constructed using
2309 @file{pxeboot.img} and @file{core.img}, making sure that the core image
2310 contains the @samp{pxe} and @samp{pxecmd} modules.  @xref{Network}.
2311 @end table
2314 @node Filesystem
2315 @chapter Filesystem syntax and semantics
2317 GRUB uses a special syntax for specifying disk drives which can be
2318 accessed by BIOS. Because of BIOS limitations, GRUB cannot distinguish
2319 between IDE, ESDI, SCSI, or others. You must know yourself which BIOS
2320 device is equivalent to which OS device. Normally, that will be clear if
2321 you see the files in a device or use the command @command{search}
2322 (@pxref{search}).
2324 @menu
2325 * Device syntax::               How to specify devices
2326 * File name syntax::            How to specify files
2327 * Block list syntax::           How to specify block lists
2328 @end menu
2331 @node Device syntax
2332 @section How to specify devices
2334 The device syntax is like this:
2336 @example
2337 @code{(@var{device}[,@var{partmap-name1}@var{part-num1}[,@var{partmap-name2}@var{part-num2}[,...]]])}
2338 @end example
2340 @samp{[]} means the parameter is optional. @var{device} depends on the disk
2341 driver in use. BIOS and EFI disks use either @samp{fd} or @samp{hd} followed
2342 by a digit, like @samp{fd0}, or @samp{cd}.
2343 AHCI, PATA (ata), crypto, USB use the name of driver followed by a number.
2344 Memdisk and host are limited to one disk and so it's refered just by driver
2345 name.
2346 RAID (md), ofdisk (ieee1275 and nand), LVM (lv), LDM and arcdisk (arc) use
2347 intrinsic name of disk prefixed by driver name. Additionally just ``nand''
2348 refers to the disk aliased as ``nand''.
2349 Conflicts are solved by suffixing a number if necessarry.
2350 Commas need to be escaped.
2351 Loopback uses whatever name specified to @command{loopback} command.
2352 Hostdisk uses names specified in device.map as long as it's of the form
2353 [fhc]d[0-9]* or hostdisk/<OS DEVICE>.
2354 For crypto and RAID (md) additionally you can use the syntax
2355 <driver name>uuid/<uuid>.
2357 @example
2358 (fd0)
2359 (hd0)
2360 (cd)
2361 (ahci0)
2362 (ata0)
2363 (crypto0)
2364 (usb0)
2365 (cryptouuid/123456789abcdef0123456789abcdef0)
2366 (mduuid/123456789abcdef0123456789abcdef0)
2367 (lv/system-root)
2368 (md/myraid)
2369 (md/0)
2370 (ieee1275/disk2)
2371 (ieee1275//pci@@1f\,0/ide@@d/disk@@2)
2372 (nand)
2373 (memdisk)
2374 (host)
2375 (myloop)
2376 (hostdisk//dev/sda)
2377 @end example
2379 @var{part-num} represents the partition number of @var{device}, starting
2380 from one. @var{partname} is optional but is recommended since disk may have
2381 several top-level partmaps. Specifying third and later component you can access
2382 to subpartitions.
2384 The syntax @samp{(hd0)} represents using the entire disk (or the
2385 MBR when installing GRUB), while the syntax @samp{(hd0,1)}
2386 represents using the first partition of the disk (or the boot sector
2387 of the partition when installing GRUB).
2389 @example
2390 (hd0,msdos1)
2391 (hd0,msdos1,msdos5)
2392 (hd0,msdos1,bsd3)
2393 (hd0,netbsd1)
2394 (hd0,gpt1)
2395 (hd0,1,3)
2396 @end example
2398 If you enabled the network support, the special drives @samp{(tftp)},
2399 @samp{(http)} and so on ars also available.
2400 Before using the network drive, you must initialize the network.
2401 @xref{Network}, for more information.
2403 If you boot GRUB from a CD-ROM, @samp{(cd)} is available. @xref{Making
2404 a GRUB bootable CD-ROM}, for details.
2407 @node File name syntax
2408 @section How to specify files
2410 There are two ways to specify files, by @dfn{absolute file name} and by
2411 @dfn{block list}.
2413 An absolute file name resembles a Unix absolute file name, using
2414 @samp{/} for the directory separator (not @samp{\} as in DOS). One
2415 example is @samp{(hd0,1)/boot/grub/grub.cfg}. This means the file
2416 @file{/boot/grub/grub.cfg} in the first partition of the first hard
2417 disk. If you omit the device name in an absolute file name, GRUB uses
2418 GRUB's @dfn{root device} implicitly. So if you set the root device to,
2419 say, @samp{(hd1,1)} by the command @samp{set root=(hd1,1)} (@pxref{set}),
2420 then @code{/boot/kernel} is the same as @code{(hd1,1)/boot/kernel}.
2423 @node Block list syntax
2424 @section How to specify block lists
2426 A block list is used for specifying a file that doesn't appear in the
2427 filesystem, like a chainloader. The syntax is
2428 @code{[@var{offset}]+@var{length}[,[@var{offset}]+@var{length}]@dots{}}.
2429 Here is an example:
2431 @example
2432 @code{0+100,200+1,300+300}
2433 @end example
2435 This represents that GRUB should read blocks 0 through 99, block 200,
2436 and blocks 300 through 599. If you omit an offset, then GRUB assumes
2437 the offset is zero.
2439 Like the file name syntax (@pxref{File name syntax}), if a blocklist
2440 does not contain a device name, then GRUB uses GRUB's @dfn{root
2441 device}. So @code{(hd0,2)+1} is the same as @code{+1} when the root
2442 device is @samp{(hd0,2)}.
2445 @node Interface
2446 @chapter GRUB's user interface
2448 GRUB has both a simple menu interface for choosing preset entries from a
2449 configuration file, and a highly flexible command-line for performing
2450 any desired combination of boot commands.
2452 GRUB looks for its configuration file as soon as it is loaded. If one
2453 is found, then the full menu interface is activated using whatever
2454 entries were found in the file. If you choose the @dfn{command-line} menu
2455 option, or if the configuration file was not found, then GRUB drops to
2456 the command-line interface.
2458 @menu
2459 * Command-line interface::      The flexible command-line interface
2460 * Menu interface::              The simple menu interface
2461 * Menu entry editor::           Editing a menu entry
2462 @end menu
2465 @node Command-line interface
2466 @section The flexible command-line interface
2468 The command-line interface provides a prompt and after it an editable
2469 text area much like a command-line in Unix or DOS. Each command is
2470 immediately executed after it is entered@footnote{However, this
2471 behavior will be changed in the future version, in a user-invisible
2472 way.}. The commands (@pxref{Command-line and menu entry commands}) are a
2473 subset of those available in the configuration file, used with exactly
2474 the same syntax.
2476 Cursor movement and editing of the text on the line can be done via a
2477 subset of the functions available in the Bash shell:
2479 @table @key
2480 @item C-f
2481 @itemx PC right key
2482 Move forward one character.
2484 @item C-b
2485 @itemx PC left key
2486 Move back one character.
2488 @item C-a
2489 @itemx HOME
2490 Move to the start of the line.
2492 @item C-e
2493 @itemx END
2494 Move the the end of the line.
2496 @item C-d
2497 @itemx DEL
2498 Delete the character underneath the cursor.
2500 @item C-h
2501 @itemx BS
2502 Delete the character to the left of the cursor.
2504 @item C-k
2505 Kill the text from the current cursor position to the end of the line.
2507 @item C-u
2508 Kill backward from the cursor to the beginning of the line.
2510 @item C-y
2511 Yank the killed text back into the buffer at the cursor.
2513 @item C-p
2514 @itemx PC up key
2515 Move up through the history list.
2517 @item C-n
2518 @itemx PC down key
2519 Move down through the history list.
2520 @end table
2522 When typing commands interactively, if the cursor is within or before
2523 the first word in the command-line, pressing the @key{TAB} key (or
2524 @key{C-i}) will display a listing of the available commands, and if the
2525 cursor is after the first word, the @kbd{@key{TAB}} will provide a
2526 completion listing of disks, partitions, and file names depending on the
2527 context. Note that to obtain a list of drives, one must open a
2528 parenthesis, as @command{root (}.
2530 Note that you cannot use the completion functionality in the TFTP
2531 filesystem. This is because TFTP doesn't support file name listing for
2532 the security.
2535 @node Menu interface
2536 @section The simple menu interface
2538 The menu interface is quite easy to use. Its commands are both
2539 reasonably intuitive and described on screen.
2541 Basically, the menu interface provides a list of @dfn{boot entries} to
2542 the user to choose from. Use the arrow keys to select the entry of
2543 choice, then press @key{RET} to run it.  An optional timeout is
2544 available to boot the default entry (the first one if not set), which is
2545 aborted by pressing any key.
2547 Commands are available to enter a bare command-line by pressing @key{c}
2548 (which operates exactly like the non-config-file version of GRUB, but
2549 allows one to return to the menu if desired by pressing @key{ESC}) or to
2550 edit any of the @dfn{boot entries} by pressing @key{e}.
2552 If you protect the menu interface with a password (@pxref{Security}),
2553 all you can do is choose an entry by pressing @key{RET}, or press
2554 @key{p} to enter the password.
2557 @node Menu entry editor
2558 @section Editing a menu entry
2560 The menu entry editor looks much like the main menu interface, but the
2561 lines in the menu are individual commands in the selected entry instead
2562 of entry names.
2564 If an @key{ESC} is pressed in the editor, it aborts all the changes made
2565 to the configuration entry and returns to the main menu interface.
2567 Each line in the menu entry can be edited freely, and you can add new lines
2568 by pressing @key{RET} at the end of a line.  To boot the edited entry, press
2569 @key{Ctrl-x}.
2571 Although GRUB unfortunately does not support @dfn{undo}, you can do almost
2572 the same thing by just returning to the main menu using @key{ESC}.
2575 @node Environment
2576 @chapter GRUB environment variables
2578 GRUB supports environment variables which are rather like those offered by
2579 all Unix-like systems.  Environment variables have a name, which is unique
2580 and is usually a short identifier, and a value, which is an arbitrary string
2581 of characters.  They may be set (@pxref{set}), unset (@pxref{unset}), or
2582 looked up (@pxref{Shell-like scripting}) by name.
2584 A number of environment variables have special meanings to various parts of
2585 GRUB.  Others may be used freely in GRUB configuration files.
2588 @menu
2589 * Special environment variables::
2590 * Environment block::
2591 @end menu
2594 @node Special environment variables
2595 @section Special environment variables
2597 These variables have special meaning to GRUB.
2599 @menu
2600 * biosnum::
2601 * chosen::
2602 * color_highlight::
2603 * color_normal::
2604 * debug::
2605 * default::
2606 * fallback::
2607 * gfxmode::
2608 * gfxpayload::
2609 * gfxterm_font::
2610 * icondir::
2611 * lang::
2612 * locale_dir::
2613 * menu_color_highlight::
2614 * menu_color_normal::
2615 * net_pxe_boot_file::
2616 * net_pxe_dhcp_server_name::
2617 * net_pxe_domain::
2618 * net_pxe_extensionspath::
2619 * net_pxe_hostname::
2620 * net_pxe_ip::
2621 * net_pxe_mac::
2622 * net_pxe_rootpath::
2623 * pager::
2624 * prefix::
2625 * pxe_blksize::
2626 * pxe_default_gateway::
2627 * pxe_default_server::
2628 * root::
2629 * superusers::
2630 * theme::
2631 * timeout::
2632 @end menu
2635 @node biosnum
2636 @subsection biosnum
2638 When chain-loading another boot loader (@pxref{Chain-loading}), GRUB may
2639 need to know what BIOS drive number corresponds to the root device
2640 (@pxref{root}) so that it can set up registers properly.  If the
2641 @var{biosnum} variable is set, it overrides GRUB's own means of guessing
2642 this.
2644 For an alternative approach which also changes BIOS drive mappings for the
2645 chain-loaded system, @pxref{drivemap}.
2648 @node chosen
2649 @subsection chosen
2651 When executing a menu entry, GRUB sets the @var{chosen} variable to the
2652 title of the entry being executed.
2654 If the menu entry is in one or more submenus, then @var{chosen} is set to
2655 the titles of each of the submenus starting from the top level followed by
2656 the title of the menu entry itself, separated by @samp{>}.
2659 @node color_highlight
2660 @subsection color_highlight
2662 This variable contains the ``highlight'' foreground and background terminal
2663 colors, separated by a slash (@samp{/}).  Setting this variable changes
2664 those colors.  For the available color names, @pxref{color_normal}.
2666 The default is @samp{black/white}.
2669 @node color_normal
2670 @subsection color_normal
2672 This variable contains the ``normal'' foreground and background terminal
2673 colors, separated by a slash (@samp{/}).  Setting this variable changes
2674 those colors.  Each color must be a name from the following list:
2676 @itemize @bullet
2677 @item black
2678 @item blue
2679 @item green
2680 @item cyan
2681 @item red
2682 @item magenta
2683 @item brown
2684 @item light-gray
2685 @item dark-gray
2686 @item light-blue
2687 @item light-green
2688 @item light-cyan
2689 @item light-red
2690 @item light-magenta
2691 @item yellow
2692 @item white
2693 @end itemize
2695 The default is @samp{white/black}.
2698 @node debug
2699 @subsection debug
2701 This variable may be set to enable debugging output from various components
2702 of GRUB.  The value is a list of debug facility names separated by
2703 whitespace or @samp{,}, or @samp{all} to enable all available debugging
2704 output.
2707 @node default
2708 @subsection default
2710 If this variable is set, it identifies a menu entry that should be selected
2711 by default, possibly after a timeout (@pxref{timeout}).  The entry may be
2712 identified by number or by title.
2714 If the entry is in a submenu, then it must be identified using the titles of
2715 each of the submenus starting from the top level followed by the number or
2716 title of the menu entry itself, separated by @samp{>}.  For example, take
2717 the following menu structure:
2719 @example
2720 Submenu 1
2721   Menu Entry 1
2722   Menu Entry 2
2723 Submenu 2
2724   Submenu 3
2725     Menu Entry 3
2726     Menu Entry 4
2727   Menu Entry 5
2728 @end example
2730 ``Menu Entry 3'' would then be identified as
2731 @samp{Submenu 2>Submenu 3>Menu Entry 3}.
2733 This variable is often set by @samp{GRUB_DEFAULT} (@pxref{Simple
2734 configuration}), @command{grub-set-default}, or @command{grub-reboot}.
2737 @node fallback
2738 @subsection fallback
2740 If this variable is set, it identifies a menu entry that should be selected
2741 if the default menu entry fails to boot.  Entries are identified in the same
2742 way as for @samp{default} (@pxref{default}).
2745 @node gfxmode
2746 @subsection gfxmode
2748 If this variable is set, it sets the resolution used on the @samp{gfxterm}
2749 graphical terminal.  Note that you can only use modes which your graphics
2750 card supports via VESA BIOS Extensions (VBE), so for example native LCD
2751 panel resolutions may not be available.  The default is @samp{auto}, which
2752 selects a platform-specific default that should look reasonable.
2754 The resolution may be specified as a sequence of one or more modes,
2755 separated by commas (@samp{,}) or semicolons (@samp{;}); each will be tried
2756 in turn until one is found.  Each mode should be either @samp{auto},
2757 @samp{@var{width}x@var{height}}, or
2758 @samp{@var{width}x@var{height}x@var{depth}}.
2761 @node gfxpayload
2762 @subsection gfxpayload
2764 If this variable is set, it controls the video mode in which the Linux
2765 kernel starts up, replacing the @samp{vga=} boot option (@pxref{linux}).  It
2766 may be set to @samp{text} to force the Linux kernel to boot in normal text
2767 mode, @samp{keep} to preserve the graphics mode set using @samp{gfxmode}, or
2768 any of the permitted values for @samp{gfxmode} to set a particular graphics
2769 mode (@pxref{gfxmode}).
2771 Depending on your kernel, your distribution, your graphics card, and the
2772 phase of the moon, note that using this option may cause GNU/Linux to suffer
2773 from various display problems, particularly during the early part of the
2774 boot sequence.  If you have problems, set this variable to @samp{text} and
2775 GRUB will tell Linux to boot in normal text mode.
2777 The default is platform-specific.  On platforms with a native text mode
2778 (such as PC BIOS platforms), the default is @samp{text}.  Otherwise the
2779 default may be @samp{auto} or a specific video mode.
2781 This variable is often set by @samp{GRUB_GFXPAYLOAD_LINUX} (@pxref{Simple
2782 configuration}).
2785 @node gfxterm_font
2786 @subsection gfxterm_font
2788 If this variable is set, it names a font to use for text on the
2789 @samp{gfxterm} graphical terminal.  Otherwise, @samp{gfxterm} may use any
2790 available font.
2793 @node icondir
2794 @subsection icondir
2796 If this variable is set, it names a directory in which the GRUB graphical
2797 menu should look for icons after looking in the theme's @samp{icons}
2798 directory.  @xref{Theme file format}.
2801 @node lang
2802 @subsection lang
2804 If this variable is set, it names the language code that the
2805 @command{gettext} command (@pxref{gettext}) uses to translate strings.  For
2806 example, French would be named as @samp{fr}, and Simplified Chinese as
2807 @samp{zh_CN}.
2809 @command{grub-mkconfig} (@pxref{Simple configuration}) will try to set a
2810 reasonable default for this variable based on the system locale.
2813 @node locale_dir
2814 @subsection locale_dir
2816 If this variable is set, it names the directory where translation files may
2817 be found (@pxref{gettext}), usually @file{/boot/grub/locale}.  Otherwise,
2818 internationalization is disabled.
2820 @command{grub-mkconfig} (@pxref{Simple configuration}) will set a reasonable
2821 default for this variable if internationalization is needed and any
2822 translation files are available.
2825 @node menu_color_highlight
2826 @subsection menu_color_highlight
2828 This variable contains the foreground and background colors to be used for
2829 the highlighted menu entry, separated by a slash (@samp{/}).  Setting this
2830 variable changes those colors.  For the available color names,
2831 @pxref{color_normal}.
2833 The default is the value of @samp{color_highlight}
2834 (@pxref{color_highlight}).
2837 @node menu_color_normal
2838 @subsection menu_color_normal
2840 This variable contains the foreground and background colors to be used for
2841 non-highlighted menu entries, separated by a slash (@samp{/}).  Setting this
2842 variable changes those colors.  For the available color names,
2843 @pxref{color_normal}.
2845 The default is the value of @samp{color_normal} (@pxref{color_normal}).
2848 @node net_pxe_boot_file
2849 @subsection net_pxe_boot_file
2851 @xref{Network}.
2854 @node net_pxe_dhcp_server_name
2855 @subsection net_pxe_dhcp_server_name
2857 @xref{Network}.
2860 @node net_pxe_domain
2861 @subsection net_pxe_domain
2863 @xref{Network}.
2866 @node net_pxe_extensionspath
2867 @subsection net_pxe_extensionspath
2869 @xref{Network}.
2872 @node net_pxe_hostname
2873 @subsection net_pxe_hostname
2875 @xref{Network}.
2878 @node net_pxe_ip
2879 @subsection net_pxe_ip
2881 @xref{Network}.
2884 @node net_pxe_mac
2885 @subsection net_pxe_mac
2887 @xref{Network}.
2890 @node net_pxe_rootpath
2891 @subsection net_pxe_rootpath
2893 @xref{Network}.
2896 @node pager
2897 @subsection pager
2899 If set to @samp{1}, pause output after each screenful and wait for keyboard
2900 input.  The default is not to pause output.
2903 @node prefix
2904 @subsection prefix
2906 The location of the @samp{/boot/grub} directory as an absolute file name
2907 (@pxref{File name syntax}).  This is normally set by GRUB at startup based
2908 on information provided by @command{grub-install}.  GRUB modules are
2909 dynamically loaded from this directory, so it must be set correctly in order
2910 for many parts of GRUB to work.
2913 @node pxe_blksize
2914 @subsection pxe_blksize
2916 @xref{Network}.
2919 @node pxe_default_gateway
2920 @subsection pxe_default_gateway
2922 @xref{Network}.
2925 @node pxe_default_server
2926 @subsection pxe_default_server
2928 @xref{Network}.
2931 @node root
2932 @subsection root
2934 The root device name (@pxref{Device syntax}).  Any file names that do not
2935 specify an explicit device name are read from this device.  The default is
2936 normally set by GRUB at startup based on the value of @samp{prefix}
2937 (@pxref{prefix}).
2939 For example, if GRUB was installed to the first partition of the first hard
2940 disk, then @samp{prefix} might be set to @samp{(hd0,msdos1)/boot/grub} and
2941 @samp{root} to @samp{hd0,msdos1}.
2944 @node superusers
2945 @subsection superusers
2947 This variable may be set to a list of superuser names to enable
2948 authentication support.  @xref{Security}.
2951 @node theme
2952 @subsection theme
2954 This variable may be set to a directory containing a GRUB graphical menu
2955 theme.  @xref{Theme file format}.
2957 This variable is often set by @samp{GRUB_THEME} (@pxref{Simple
2958 configuration}).
2961 @node timeout
2962 @subsection timeout
2964 If this variable is set, it specifies the time in seconds to wait for
2965 keyboard input before booting the default menu entry.  A timeout of @samp{0}
2966 means to boot the default entry immediately without displaying the menu; a
2967 timeout of @samp{-1} (or unset) means to wait indefinitely.
2969 This variable is often set by @samp{GRUB_TIMEOUT} or
2970 @samp{GRUB_HIDDEN_TIMEOUT} (@pxref{Simple configuration}).
2973 @node Environment block
2974 @section The GRUB environment block
2976 It is often useful to be able to remember a small amount of information from
2977 one boot to the next.  For example, you might want to set the default menu
2978 entry based on what was selected the last time.  GRUB deliberately does not
2979 implement support for writing files in order to minimise the possibility of
2980 the boot loader being responsible for file system corruption, so a GRUB
2981 configuration file cannot just create a file in the ordinary way.  However,
2982 GRUB provides an ``environment block'' which can be used to save a small
2983 amount of state.
2985 The environment block is a preallocated 1024-byte file, which normally lives
2986 in @file{/boot/grub/grubenv} (although you should not assume this).  At boot
2987 time, the @command{load_env} command (@pxref{load_env}) loads environment
2988 variables from it, and the @command{save_env} (@pxref{save_env}) command
2989 saves environment variables to it.  From a running system, the
2990 @command{grub-editenv} utility can be used to edit the environment block.
2992 For safety reasons, this storage is only available when installed on a plain
2993 disk (no LVM or RAID), using a non-checksumming filesystem (no ZFS), and
2994 using BIOS or EFI functions (no ATA, USB or IEEE1275).
2996 @command{grub-mkconfig} uses this facility to implement
2997 @samp{GRUB_SAVEDEFAULT} (@pxref{Simple configuration}).
3000 @node Commands
3001 @chapter The list of available commands
3003 In this chapter, we list all commands that are available in GRUB.
3005 Commands belong to different groups. A few can only be used in
3006 the global section of the configuration file (or ``menu''); most
3007 of them can be entered on the command-line and can be used either
3008 anywhere in the menu or specifically in the menu entries.
3010 In rescue mode, only the @command{insmod} (@pxref{insmod}), @command{ls}
3011 (@pxref{ls}), @command{set} (@pxref{set}), and @command{unset}
3012 (@pxref{unset}) commands are normally available.  If you end up in rescue
3013 mode and do not know what to do, then @pxref{GRUB only offers a rescue
3014 shell}.
3016 @menu
3017 * Menu-specific commands::
3018 * General commands::
3019 * Command-line and menu entry commands::
3020 @end menu
3023 @node Menu-specific commands
3024 @section The list of commands for the menu only
3026 The semantics used in parsing the configuration file are the following:
3028 @itemize @bullet
3029 @item
3030 The files @emph{must} be in plain-text format.
3032 @item
3033 @samp{#} at the beginning of a line in a configuration file means it is
3034 only a comment.
3036 @item
3037 Options are separated by spaces.
3039 @item
3040 All numbers can be either decimal or hexadecimal. A hexadecimal number
3041 must be preceded by @samp{0x}, and is case-insensitive.
3042 @end itemize
3044 These commands can only be used in the menu:
3046 @menu
3047 * menuentry::                   Start a menu entry
3048 * submenu::                     Group menu entries
3049 @end menu
3052 @node menuentry
3053 @subsection menuentry
3055 @deffn Command menuentry @var{title} @
3056  [@option{--class=class} @dots{}] [@option{--users=users}] @
3057  [@option{--unrestricted}] [@option{--hotkey=key}] @
3058  @{ @var{command}; @dots{} @}
3059 This defines a GRUB menu entry named @var{title}.  When this entry is
3060 selected from the menu, GRUB will set the @var{chosen} environment variable
3061 to @var{title}, execute the list of commands given within braces, and if the
3062 last command in the list returned successfully and a kernel was loaded it
3063 will execute the @command{boot} command.
3065 The @option{--class} option may be used any number of times to group menu
3066 entries into classes.  Menu themes may display different classes using
3067 different styles.
3069 The @option{--users} option grants specific users access to specific menu
3070 entries.  @xref{Security}.
3072 The @option{--unrestricted} option grants all users access to specific menu
3073 entries.  @xref{Security}.
3075 The @option{--hotkey} option associates a hotkey with a menu entry.
3076 @var{key} may be a single letter, or one of the aliases @samp{backspace},
3077 @samp{tab}, or @samp{delete}.
3078 @end deffn
3081 @node submenu
3082 @subsection submenu
3084 @deffn Command submenu @var{title} @
3085  [@option{--class=class} @dots{}] [@option{--users=users}] @
3086  [@option{--unrestricted}] [@option{--hotkey=key}] @
3087  @{ @var{menu entries} @dots{} @}
3088 This defines a submenu.  An entry called @var{title} will be added to the
3089 menu; when that entry is selected, a new menu will be displayed showing all
3090 the entries within this submenu.
3092 All options are the same as in the @command{menuentry} command
3093 (@pxref{menuentry}).
3094 @end deffn
3097 @node General commands
3098 @section The list of general commands
3100 Commands usable anywhere in the menu and in the command-line.
3102 @menu
3103 * serial::                      Set up a serial device
3104 * terminal_input::              Manage input terminals
3105 * terminal_output::             Manage output terminals
3106 * terminfo::                    Define terminal type
3107 @end menu
3110 @node serial
3111 @subsection serial
3113 @deffn Command serial [@option{--unit=unit}] [@option{--port=port}] [@option{--speed=speed}] [@option{--word=word}] [@option{--parity=parity}] [@option{--stop=stop}]
3114 Initialize a serial device. @var{unit} is a number in the range 0-3
3115 specifying which serial port to use; default is 0, which corresponds to
3116 the port often called COM1. @var{port} is the I/O port where the UART
3117 is to be found; if specified it takes precedence over @var{unit}.
3118 @var{speed} is the transmission speed; default is 9600. @var{word} and
3119 @var{stop} are the number of data bits and stop bits. Data bits must
3120 be in the range 5-8 and stop bits must be 1 or 2. Default is 8 data
3121 bits and one stop bit. @var{parity} is one of @samp{no}, @samp{odd},
3122 @samp{even} and defaults to @samp{no}.
3124 The serial port is not used as a communication channel unless the
3125 @command{terminal_input} or @command{terminal_output} command is used
3126 (@pxref{terminal_input}, @pxref{terminal_output}).
3128 See also @ref{Serial terminal}.
3129 @end deffn
3132 @node terminal_input
3133 @subsection terminal_input
3135 @deffn Command terminal_input [@option{--append}|@option{--remove}] @
3136  [terminal1] [terminal2] @dots{}
3137 List or select an input terminal.
3139 With no arguments, list the active and available input terminals.
3141 With @option{--append}, add the named terminals to the list of active input
3142 terminals; any of these may be used to provide input to GRUB.
3144 With @option{--remove}, remove the named terminals from the active list.
3146 With no options but a list of terminal names, make only the listed terminal
3147 names active.
3148 @end deffn
3151 @node terminal_output
3152 @subsection terminal_output
3154 @deffn Command terminal_output [@option{--append}|@option{--remove}] @
3155  [terminal1] [terminal2] @dots{}
3156 List or select an output terminal.
3158 With no arguments, list the active and available output terminals.
3160 With @option{--append}, add the named terminals to the list of active output
3161 terminals; all of these will receive output from GRUB.
3163 With @option{--remove}, remove the named terminals from the active list.
3165 With no options but a list of terminal names, make only the listed terminal
3166 names active.
3167 @end deffn
3170 @node terminfo
3171 @subsection terminfo
3173 @deffn Command terminfo [-a|-u|-v] [term]
3174 Define the capabilities of your terminal by giving the name of an entry in
3175 the terminfo database, which should correspond roughly to a @samp{TERM}
3176 environment variable in Unix.
3178 The currently available terminal types are @samp{vt100}, @samp{vt100-color},
3179 @samp{ieee1275}, and @samp{dumb}.  If you need other terminal types, please
3180 contact us to discuss the best way to include support for these in GRUB.
3182 The @option{-a} (@option{--ascii}), @option{-u} (@option{--utf8}), and
3183 @option{-v} (@option{--visual-utf8}) options control how non-ASCII text is
3184 displayed.  @option{-a} specifies an ASCII-only terminal; @option{-u}
3185 specifies logically-ordered UTF-8; and @option{-v} specifies
3186 "visually-ordered UTF-8" (in other words, arranged such that a terminal
3187 emulator without bidirectional text support will display right-to-left text
3188 in the proper order; this is not really proper UTF-8, but a workaround).
3190 If no option or terminal type is specified, the current terminal type is
3191 printed.
3192 @end deffn
3195 @node Command-line and menu entry commands
3196 @section The list of command-line and menu entry commands
3198 These commands are usable in the command-line and in menu entries.  If
3199 you forget a command, you can run the command @command{help}
3200 (@pxref{help}).
3202 @menu
3203 * acpi::                        Load ACPI tables
3204 * badram::                      Filter out bad regions of RAM
3205 * blocklist::                   Print a block list
3206 * boot::                        Start up your operating system
3207 * cat::                         Show the contents of a file
3208 * chainloader::                 Chain-load another boot loader
3209 * cmp::                         Compare two files
3210 * configfile::                  Load a configuration file
3211 * cpuid::                       Check for CPU features
3212 * crc::                         Calculate CRC32 checksums
3213 * date::                        Display or set current date and time
3214 * drivemap::                    Map a drive to another
3215 * echo::                        Display a line of text
3216 * export::                      Export an environment variable
3217 * false::                       Do nothing, unsuccessfully
3218 * gettext::                     Translate a string
3219 * gptsync::                     Fill an MBR based on GPT entries
3220 * halt::                        Shut down your computer
3221 * help::                        Show help messages
3222 * initrd::                      Load a Linux initrd
3223 * initrd16::                    Load a Linux initrd (16-bit mode)
3224 * insmod::                      Insert a module
3225 * keystatus::                   Check key modifier status
3226 * linux::                       Load a Linux kernel
3227 * linux16::                     Load a Linux kernel (16-bit mode)
3228 * list_env::                    List variables in environment block
3229 * load_env::                    Load variables from environment block
3230 * loopback::                    Make a device from a filesystem image
3231 * ls::                          List devices or files
3232 * normal::                      Enter normal mode
3233 * normal_exit::                 Exit from normal mode
3234 * parttool::                    Modify partition table entries
3235 * password::                    Set a clear-text password
3236 * password_pbkdf2::             Set a hashed password
3237 * play::                        Play a tune
3238 * pxe_unload::                  Unload the PXE environment
3239 * read::                        Read user input
3240 * reboot::                      Reboot your computer
3241 * save_env::                    Save variables to environment block
3242 * search::                      Search devices by file, label, or UUID
3243 * sendkey::                     Emulate keystrokes
3244 * set::                         Set an environment variable
3245 * true::                        Do nothing, successfully
3246 * unset::                       Unset an environment variable
3247 * uppermem::                    Set the upper memory size
3248 @end menu
3251 @node acpi
3252 @subsection acpi
3254 @deffn Command acpi [@option{-1}|@option{-2}] @
3255  [@option{--exclude=table1,@dots{}}|@option{--load-only=table1,@dots{}}] @
3256  [@option{--oemid=id}] [@option{--oemtable=table}] @
3257  [@option{--oemtablerev=rev}] [@option{--oemtablecreator=creator}] @
3258  [@option{--oemtablecreatorrev=rev}] [@option{--no-ebda}] @
3259  filename @dots{}
3260 Modern BIOS systems normally implement the Advanced Configuration and Power
3261 Interface (ACPI), and define various tables that describe the interface
3262 between an ACPI-compliant operating system and the firmware. In some cases,
3263 the tables provided by default only work well with certain operating
3264 systems, and it may be necessary to replace some of them.
3266 Normally, this command will replace the Root System Description Pointer
3267 (RSDP) in the Extended BIOS Data Area to point to the new tables. If the
3268 @option{--no-ebda} option is used, the new tables will be known only to
3269 GRUB, but may be used by GRUB's EFI emulation.
3270 @end deffn
3272 @node badram
3273 @subsection badram
3275 @deffn Command badram addr,mask[,addr,mask...]
3276 Filter out bad RAM.
3277 @end deffn
3279 This command notifies the memory manager that specified regions of
3280 RAM ought to be filtered out (usually, because they're damaged).  This
3281 remains in effect after a payload kernel has been loaded by GRUB, as
3282 long as the loaded kernel obtains its memory map from GRUB.  Kernels that
3283 support this include Linux, GNU Mach, the kernel of FreeBSD and Multiboot
3284 kernels in general.
3286 Syntax is the same as provided by the @uref{http://www.memtest.org/,
3287 Memtest86+ utility}: a list of address/mask pairs.  Given a page-aligned
3288 address and a base address / mask pair, if all the bits of the page-aligned
3289 address that are enabled by the mask match with the base address, it means
3290 this page is to be filtered.  This syntax makes it easy to represent patterns
3291 that are often result of memory damage, due to physical distribution of memory
3292 cells.
3294 @node blocklist
3295 @subsection blocklist
3297 @deffn Command blocklist file
3298 Print a block list (@pxref{Block list syntax}) for @var{file}.
3299 @end deffn
3302 @node boot
3303 @subsection boot
3305 @deffn Command boot
3306 Boot the OS or chain-loader which has been loaded. Only necessary if
3307 running the fully interactive command-line (it is implicit at the end of
3308 a menu entry).
3309 @end deffn
3312 @node cat
3313 @subsection cat
3315 @deffn Command cat [@option{--dos}] file
3316 Display the contents of the file @var{file}. This command may be useful
3317 to remind you of your OS's root partition:
3319 @example
3320 grub> @kbd{cat /etc/fstab}
3321 @end example
3323 If the @option{--dos} option is used, then carriage return / new line pairs
3324 will be displayed as a simple new line.  Otherwise, the carriage return will
3325 be displayed as a control character (@samp{<d>}) to make it easier to see
3326 when boot problems are caused by a file formatted using DOS-style line
3327 endings.
3328 @end deffn
3331 @node chainloader
3332 @subsection chainloader
3334 @deffn Command chainloader [@option{--force}] file
3335 Load @var{file} as a chain-loader. Like any other file loaded by the
3336 filesystem code, it can use the blocklist notation (@pxref{Block list
3337 syntax}) to grab the first sector of the current partition with @samp{+1}.
3338 If you specify the option @option{--force}, then load @var{file} forcibly,
3339 whether it has a correct signature or not. This is required when you want to
3340 load a defective boot loader, such as SCO UnixWare 7.1.
3341 @end deffn
3344 @node cmp
3345 @subsection cmp
3347 @deffn Command cmp file1 file2
3348 Compare the file @var{file1} with the file @var{file2}. If they differ
3349 in size, print the sizes like this:
3351 @example
3352 Differ in size: 0x1234 [foo], 0x4321 [bar]
3353 @end example
3355 If the sizes are equal but the bytes at an offset differ, then print the
3356 bytes like this:
3358 @example
3359 Differ at the offset 777: 0xbe [foo], 0xef [bar]
3360 @end example
3362 If they are completely identical, nothing will be printed.
3363 @end deffn
3366 @node configfile
3367 @subsection configfile
3369 @deffn Command configfile file
3370 Load @var{file} as a configuration file.  If @var{file} defines any menu
3371 entries, then show a menu containing them immediately.
3372 @end deffn
3375 @node cpuid
3376 @subsection cpuid
3378 @deffn Command cpuid [-l]
3379 Check for CPU features.  This command is only available on x86 systems.
3381 With the @option{-l} option, return true if the CPU supports long mode
3382 (64-bit).
3384 If invoked without options, this command currently behaves as if it had been
3385 invoked with @option{-l}.  This may change in the future.
3386 @end deffn
3389 @node crc
3390 @subsection crc
3392 @deffn Command crc file
3393 Display the CRC32 checksum of @var{file}.
3394 @end deffn
3397 @node date
3398 @subsection date
3400 @deffn Command date [[year-]month-day] [hour:minute[:second]]
3401 With no arguments, print the current date and time.
3403 Otherwise, take the current date and time, change any elements specified as
3404 arguments, and set the result as the new date and time.  For example, `date
3405 01-01' will set the current month and day to January 1, but leave the year,
3406 hour, minute, and second unchanged.
3407 @end deffn
3410 @node drivemap
3411 @subsection drivemap
3413 @deffn Command drivemap @option{-l}|@option{-r}|[@option{-s}] @
3414  from_drive to_drive
3415 Without options, map the drive @var{from_drive} to the drive @var{to_drive}.
3416 This is necessary when you chain-load some operating systems, such as DOS,
3417 if such an OS resides at a non-first drive.  For convenience, any partition
3418 suffix on the drive is ignored, so you can safely use @verb{'${root}'} as a
3419 drive specification.
3421 With the @option{-s} option, perform the reverse mapping as well, swapping
3422 the two drives.
3424 With the @option{-l} option, list the current mappings.
3426 With the @option{-r} option, reset all mappings to the default values.
3428 For example:
3430 @example
3431 drivemap -s (hd0) (hd1)
3432 @end example
3433 @end deffn
3436 @node echo
3437 @subsection echo
3439 @deffn Command echo [@option{-n}] [@option{-e}] string @dots{}
3440 Display the requested text and, unless the @option{-n} option is used, a
3441 trailing new line.  If there is more than one string, they are separated by
3442 spaces in the output.  As usual in GRUB commands, variables may be
3443 substituted using @samp{$@{var@}}.
3445 The @option{-e} option enables interpretation of backslash escapes.  The
3446 following sequences are recognised:
3448 @table @code
3449 @item \\
3450 backslash
3452 @item \a
3453 alert (BEL)
3455 @item \c
3456 suppress trailing new line
3458 @item \f
3459 form feed
3461 @item \n
3462 new line
3464 @item \r
3465 carriage return
3467 @item \t
3468 horizontal tab
3470 @item \v
3471 vertical tab
3472 @end table
3474 When interpreting backslash escapes, backslash followed by any other
3475 character will print that character.
3476 @end deffn
3479 @node export
3480 @subsection export
3482 @deffn Command export envvar
3483 Export the environment variable @var{envvar}. Exported variables are visible
3484 to subsidiary configuration files loaded using @command{configfile}.
3485 @end deffn
3488 @node false
3489 @subsection false
3491 @deffn Command false
3492 Do nothing, unsuccessfully.  This is mainly useful in control constructs
3493 such as @code{if} and @code{while} (@pxref{Shell-like scripting}).
3494 @end deffn
3497 @node gettext
3498 @subsection gettext
3500 @deffn Command gettext string
3501 Translate @var{string} into the current language.
3503 The current language code is stored in the @samp{lang} variable in GRUB's
3504 environment (@pxref{lang}).  Translation files in MO format are read from
3505 @samp{locale_dir} (@pxref{locale_dir}), usually @file{/boot/grub/locale}.
3506 @end deffn
3509 @node gptsync
3510 @subsection gptsync
3512 @deffn Command gptsync device [partition[+/-[type]]] @dots{}
3513 Disks using the GUID Partition Table (GPT) also have a legacy Master Boot
3514 Record (MBR) partition table for compatibility with the BIOS and with older
3515 operating systems.  The legacy MBR can only represent a limited subset of
3516 GPT partition entries.
3518 This command populates the legacy MBR with the specified @var{partition}
3519 entries on @var{device}.  Up to three partitions may be used.
3521 @var{type} is an MBR partition type code; prefix with @samp{0x} if you want
3522 to enter this in hexadecimal.  The separator between @var{partition} and
3523 @var{type} may be @samp{+} to make the partition active, or @samp{-} to make
3524 it inactive; only one partition may be active.  If both the separator and
3525 type are omitted, then the partition will be inactive.
3526 @end deffn
3529 @node halt
3530 @subsection halt
3532 @deffn Command halt @option{--no-apm}
3533 The command halts the computer. If the @option{--no-apm} option
3534 is specified, no APM BIOS call is performed. Otherwise, the computer
3535 is shut down using APM.
3536 @end deffn
3539 @node help
3540 @subsection help
3542 @deffn Command help [pattern @dots{}]
3543 Display helpful information about builtin commands. If you do not
3544 specify @var{pattern}, this command shows short descriptions of all
3545 available commands.
3547 If you specify any @var{patterns}, it displays longer information
3548 about each of the commands whose names begin with those @var{patterns}.
3549 @end deffn
3552 @node initrd
3553 @subsection initrd
3555 @deffn Command initrd file
3556 Load an initial ramdisk for a Linux kernel image, and set the appropriate
3557 parameters in the Linux setup area in memory.  This may only be used after
3558 the @command{linux} command (@pxref{linux}) has been run.  See also
3559 @ref{GNU/Linux}.
3560 @end deffn
3563 @node initrd16
3564 @subsection initrd16
3566 @deffn Command initrd16 file
3567 Load an initial ramdisk for a Linux kernel image to be booted in 16-bit
3568 mode, and set the appropriate parameters in the Linux setup area in memory.
3569 This may only be used after the @command{linux16} command (@pxref{linux16})
3570 has been run.  See also @ref{GNU/Linux}.
3572 This command is only available on x86 systems.
3573 @end deffn
3576 @node insmod
3577 @subsection insmod
3579 @deffn Command insmod module
3580 Insert the dynamic GRUB module called @var{module}.
3581 @end deffn
3584 @node keystatus
3585 @subsection keystatus
3587 @deffn Command keystatus [@option{--shift}] [@option{--ctrl}] [@option{--alt}]
3588 Return true if the Shift, Control, or Alt modifier keys are held down, as
3589 requested by options. This is useful in scripting, to allow some user
3590 control over behaviour without having to wait for a keypress.
3592 Checking key modifier status is only supported on some platforms. If invoked
3593 without any options, the @command{keystatus} command returns true if and
3594 only if checking key modifier status is supported.
3595 @end deffn
3598 @node linux
3599 @subsection linux
3601 @deffn Command linux file @dots{}
3602 Load a Linux kernel image from @var{file}.  The rest of the line is passed
3603 verbatim as the @dfn{kernel command-line}.  Any initrd must be reloaded
3604 after using this command (@pxref{initrd}).
3606 On x86 systems, the kernel will be booted using the 32-bit boot protocol.
3607 Note that this means that the @samp{vga=} boot option will not work; if you
3608 want to set a special video mode, you will need to use GRUB commands such as
3609 @samp{set gfxpayload=1024x768} or @samp{set gfxpayload=keep} (to keep the
3610 same mode as used in GRUB) instead.  GRUB can automatically detect some uses
3611 of @samp{vga=} and translate them to appropriate settings of
3612 @samp{gfxpayload}.  The @command{linux16} command (@pxref{linux16}) avoids
3613 this restriction.
3614 @end deffn
3617 @node linux16
3618 @subsection linux16
3620 @deffn Command linux16 file @dots{}
3621 Load a Linux kernel image from @var{file} in 16-bit mode.  The rest of the
3622 line is passed verbatim as the @dfn{kernel command-line}.  Any initrd must
3623 be reloaded after using this command (@pxref{initrd16}).
3625 The kernel will be booted using the traditional 16-bit boot protocol.  As
3626 well as bypassing problems with @samp{vga=} described in @ref{linux}, this
3627 permits booting some other programs that implement the Linux boot protocol
3628 for the sake of convenience.
3630 This command is only available on x86 systems.
3631 @end deffn
3634 @node list_env
3635 @subsection list_env
3637 @deffn Command list_env [@option{-f} file]
3638 List all variables in the environment block file.  @xref{Environment block}.
3640 The @option{-f} option overrides the default location of the environment
3641 block.
3642 @end deffn
3645 @node load_env
3646 @subsection load_env
3648 @deffn Command load_env [@option{-f} file]
3649 Load all variables from the environment block file into the environment.
3650 @xref{Environment block}.
3652 The @option{-f} option overrides the default location of the environment
3653 block.
3654 @end deffn
3657 @node loopback
3658 @subsection loopback
3660 @deffn Command loopback [@option{-d}] device file
3661 Make the device named @var{device} correspond to the contents of the
3662 filesystem image in @var{file}.  For example:
3664 @example
3665 loopback loop0 /path/to/image
3666 ls (loop0)/
3667 @end example
3669 With the @option{-d} option, delete a device previously created using this
3670 command.
3671 @end deffn
3674 @node ls
3675 @subsection ls
3677 @deffn Command ls [arg @dots{}]
3678 List devices or files.
3680 With no arguments, print all devices known to GRUB.
3682 If the argument is a device name enclosed in parentheses (@pxref{Device
3683 syntax}), then list all files at the root directory of that device.
3685 If the argument is a directory given as an absolute file name (@pxref{File
3686 name syntax}), then list the contents of that directory.
3687 @end deffn
3690 @node normal
3691 @subsection normal
3693 @deffn Command normal [file]
3694 Enter normal mode and display the GRUB menu.
3696 In normal mode, commands, filesystem modules, and cryptography modules are
3697 automatically loaded, and the full GRUB script parser is available.  Other
3698 modules may be explicitly loaded using @command{insmod} (@pxref{insmod}).
3700 If a @var{file} is given, then commands will be read from that file.
3701 Otherwise, they will be read from @file{$prefix/grub.cfg} if it exists.
3703 @command{normal} may be called from within normal mode, creating a nested
3704 environment.  It is more usual to use @command{configfile}
3705 (@pxref{configfile}) for this.
3706 @end deffn
3709 @node normal_exit
3710 @subsection normal_exit
3712 @deffn Command normal_exit
3713 Exit normal mode (@pxref{normal}).  If this instance of normal mode was not
3714 nested within another one, then return to rescue mode.
3715 @end deffn
3718 @node parttool
3719 @subsection parttool
3721 @deffn Command parttool partition commands
3722 Make various modifications to partition table entries.
3724 Each @var{command} is either a boolean option, in which case it must be
3725 followed with @samp{+} or @samp{-} (with no intervening space) to enable or
3726 disable that option, or else it takes a value in the form
3727 @samp{@var{command}=@var{value}}.
3729 Currently, @command{parttool} is only useful on DOS partition tables (also
3730 known as Master Boot Record, or MBR).  On these partition tables, the
3731 following commands are available:
3733 @table @asis
3734 @item @samp{boot} (boolean)
3735 When enabled, this makes the selected partition be the active (bootable)
3736 partition on its disk, clearing the active flag on all other partitions.
3737 This command is limited to @emph{primary} partitions.
3739 @item @samp{type} (value)
3740 Change the type of an existing partition.  The value must be a number in the
3741 range 0-0xFF (prefix with @samp{0x} to enter it in hexadecimal).
3743 @item @samp{hidden} (boolean)
3744 When enabled, this hides the selected partition by setting the @dfn{hidden}
3745 bit in its partition type code; when disabled, unhides the selected
3746 partition by clearing this bit.  This is useful only when booting DOS or
3747 Wwindows and multiple primary FAT partitions exist in one disk.  See also
3748 @ref{DOS/Windows}.
3749 @end table
3750 @end deffn
3753 @node password
3754 @subsection password
3756 @deffn Command password user clear-password
3757 Define a user named @var{user} with password @var{clear-password}.
3758 @xref{Security}.
3759 @end deffn
3762 @node password_pbkdf2
3763 @subsection password_pbkdf2
3765 @deffn Command password_pbkdf2 user hashed-password
3766 Define a user named @var{user} with password hash @var{hashed-password}.
3767 Use @command{grub-mkpasswd-pbkdf2} (@pxref{Invoking grub-mkpasswd-pbkdf2})
3768 to generate password hashes.  @xref{Security}.
3769 @end deffn
3772 @node play
3773 @subsection play
3775 @deffn Command play file | tempo [pitch1 duration1] [pitch2 duration2] ...
3776 Plays a tune
3778 If the argument is a file name (@pxref{File name syntax}), play the tune
3779 recorded in it.  The file format is first the tempo as an unsigned 32bit
3780 little-endian number, then pairs of unsigned 16bit little-endian numbers for
3781 pitch and duration pairs.
3783 If the arguments are a series of numbers, play the inline tune.
3785 The tempo is the base for all note durations. 60 gives a 1-second base, 120
3786 gives a half-second base, etc.  Pitches are Hz.  Set pitch to 0 to produce
3787 a rest.
3788 @end deffn
3791 @node pxe_unload
3792 @subsection pxe_unload
3794 @deffn Command pxe_unload
3795 Unload the PXE environment (@pxref{Network}).
3797 This command is only available on PC BIOS systems.
3798 @end deffn
3801 @node read
3802 @subsection read
3804 @deffn Command read [var]
3805 Read a line of input from the user.  If an environment variable @var{var} is
3806 given, set that environment variable to the line of input that was read,
3807 with no terminating newline.
3808 @end deffn
3811 @node reboot
3812 @subsection reboot
3814 @deffn Command reboot
3815 Reboot the computer.
3816 @end deffn
3819 @node save_env
3820 @subsection save_env
3822 @deffn Command save_env [@option{-f} file] var @dots{}
3823 Save the named variables from the environment to the environment block file.
3824 @xref{Environment block}.
3826 The @option{-f} option overrides the default location of the environment
3827 block.
3828 @end deffn
3831 @node search
3832 @subsection search
3834 @deffn Command search @
3835  [@option{--file}|@option{--label}|@option{--fs-uuid}] @
3836  [@option{--set} [var]] [@option{--no-floppy}] name
3837 Search devices by file (@option{-f}, @option{--file}), filesystem label
3838 (@option{-l}, @option{--label}), or filesystem UUID (@option{-u},
3839 @option{--fs-uuid}).
3841 If the @option{--set} option is used, the first device found is set as the
3842 value of environment variable @var{var}.  The default variable is
3843 @samp{root}.
3845 The @option{--no-floppy} option prevents searching floppy devices, which can
3846 be slow.
3848 The @samp{search.file}, @samp{search.fs_label}, and @samp{search.fs_uuid}
3849 commands are aliases for @samp{search --file}, @samp{search --label}, and
3850 @samp{search --fs-uuid} respectively.
3851 @end deffn
3854 @node sendkey
3855 @subsection sendkey
3857 @deffn Command sendkey @
3858  [@option{--num}|@option{--caps}|@option{--scroll}|@option{--insert}|@
3859 @option{--pause}|@option{--left-shift}|@option{--right-shift}|@
3860 @option{--sysrq}|@option{--numkey}|@option{--capskey}|@option{--scrollkey}|@
3861 @option{--insertkey}|@option{--left-alt}|@option{--right-alt}|@
3862 @option{--left-ctrl}|@option{--right-ctrl} @
3863  @samp{on}|@samp{off}]@dots{} @
3864  [@option{no-led}] @
3865  keystroke
3866 Insert keystrokes into the keyboard buffer when booting.  Sometimes an
3867 operating system or chainloaded boot loader requires particular keys to be
3868 pressed: for example, one might need to press a particular key to enter
3869 "safe mode", or when chainloading another boot loader one might send
3870 keystrokes to it to navigate its menu.  
3872 You may provide up to 16 keystrokes (the length of the BIOS keyboard
3873 buffer).  Keystroke names may be upper-case or lower-case letters, digits,
3874 or taken from the following table:
3876 @c Please keep this table in the same order as in
3877 @c commands/i386/pc/sendkey.c, for ease of maintenance.
3878 @c Exception: The function and numeric keys are sorted, for aesthetics.
3880 @multitable @columnfractions .4 .5
3881 @headitem Name @tab Key
3882 @item escape @tab Escape
3883 @item exclam @tab !
3884 @item at @tab @@
3885 @item numbersign @tab #
3886 @item dollar @tab $
3887 @item percent @tab %
3888 @item caret @tab ^
3889 @item ampersand @tab &
3890 @item asterisk @tab *
3891 @item parenleft @tab (
3892 @item parenright @tab )
3893 @item minus @tab -
3894 @item underscore @tab _
3895 @item equal @tab =
3896 @item plus @tab +
3897 @item backspace @tab Backspace
3898 @item tab @tab Tab
3899 @item bracketleft @tab [
3900 @item braceleft @tab @{
3901 @item bracketright @tab ]
3902 @item braceright @tab @}
3903 @item enter @tab Enter
3904 @item control @tab press and release Control
3905 @item semicolon @tab ;
3906 @item colon @tab :
3907 @item quote @tab '
3908 @item doublequote @tab "
3909 @item backquote @tab `
3910 @item tilde @tab ~
3911 @item shift @tab press and release left Shift
3912 @item backslash @tab \
3913 @item bar @tab |
3914 @item comma @tab ,
3915 @item less @tab <
3916 @item period @tab .
3917 @item greater @tab >
3918 @item slash @tab /
3919 @item question @tab ?
3920 @item rshift @tab press and release right Shift
3921 @item alt @tab press and release Alt
3922 @item space @tab space bar
3923 @item capslock @tab Caps Lock
3924 @item F1 @tab F1
3925 @item F2 @tab F2
3926 @item F3 @tab F3
3927 @item F4 @tab F4
3928 @item F5 @tab F5
3929 @item F6 @tab F6
3930 @item F7 @tab F7
3931 @item F8 @tab F8
3932 @item F9 @tab F9
3933 @item F10 @tab F10
3934 @item F11 @tab F11
3935 @item F12 @tab F12
3936 @item num1 @tab 1 (numeric keypad)
3937 @item num2 @tab 2 (numeric keypad)
3938 @item num3 @tab 3 (numeric keypad)
3939 @item num4 @tab 4 (numeric keypad)
3940 @item num5 @tab 5 (numeric keypad)
3941 @item num6 @tab 6 (numeric keypad)
3942 @item num7 @tab 7 (numeric keypad)
3943 @item num8 @tab 8 (numeric keypad)
3944 @item num9 @tab 9 (numeric keypad)
3945 @item num0 @tab 0 (numeric keypad)
3946 @item numperiod @tab . (numeric keypad)
3947 @item numend @tab End (numeric keypad)
3948 @item numdown @tab Down (numeric keypad)
3949 @item numpgdown @tab Page Down (numeric keypad)
3950 @item numleft @tab Left (numeric keypad)
3951 @item numcenter @tab 5 with Num Lock inactive (numeric keypad)
3952 @item numright @tab Right (numeric keypad)
3953 @item numhome @tab Home (numeric keypad)
3954 @item numup @tab Up (numeric keypad)
3955 @item numpgup @tab Page Up (numeric keypad)
3956 @item numinsert @tab Insert (numeric keypad)
3957 @item numdelete @tab Delete (numeric keypad)
3958 @item numasterisk @tab * (numeric keypad)
3959 @item numminus @tab - (numeric keypad)
3960 @item numplus @tab + (numeric keypad)
3961 @item numslash @tab / (numeric keypad)
3962 @item numenter @tab Enter (numeric keypad)
3963 @item delete @tab Delete
3964 @item insert @tab Insert
3965 @item home @tab Home
3966 @item end @tab End
3967 @item pgdown @tab Page Down
3968 @item pgup @tab Page Up
3969 @item down @tab Down
3970 @item up @tab Up
3971 @item left @tab Left
3972 @item right @tab Right
3973 @end multitable
3975 As well as keystrokes, the @command{sendkey} command takes various options
3976 that affect the BIOS keyboard status flags.  These options take an @samp{on}
3977 or @samp{off} parameter, specifying that the corresponding status flag be
3978 set or unset; omitting the option for a given status flag will leave that
3979 flag at its initial state at boot.  The @option{--num}, @option{--caps},
3980 @option{--scroll}, and @option{--insert} options emulate setting the
3981 corresponding mode, while the @option{--numkey}, @option{--capskey},
3982 @option{--scrollkey}, and @option{--insertkey} options emulate pressing and
3983 holding the corresponding key.  The other status flag options are
3984 self-explanatory.
3986 If the @option{--no-led} option is given, the status flag options will have
3987 no effect on keyboard LEDs.
3989 If the @command{sendkey} command is given multiple times, then only the last
3990 invocation has any effect.
3992 Since @command{sendkey} manipulates the BIOS keyboard buffer, it may cause
3993 hangs, reboots, or other misbehaviour on some systems.  If the operating
3994 system or boot loader that runs after GRUB uses its own keyboard driver
3995 rather than the BIOS keyboard functions, then @command{sendkey} will have no
3996 effect.
3998 This command is only available on PC BIOS systems.
3999 @end deffn
4002 @node set
4003 @subsection set
4005 @deffn Command set [envvar=value]
4006 Set the environment variable @var{envvar} to @var{value}. If invoked with no
4007 arguments, print all environment variables with their values.
4008 @end deffn
4011 @node true
4012 @subsection true
4014 @deffn Command true
4015 Do nothing, successfully.  This is mainly useful in control constructs such
4016 as @code{if} and @code{while} (@pxref{Shell-like scripting}).
4017 @end deffn
4020 @node unset
4021 @subsection unset
4023 @deffn Command unset envvar
4024 Unset the environment variable @var{envvar}.
4025 @end deffn
4028 @node uppermem
4029 @subsection uppermem
4031 This command is not yet implemented for GRUB 2, although it is planned.
4033 @node Internationalisation
4034 @chapter Charset
4035 GRUB uses UTF-8 internally other than in rendering where some GRUB-specific
4036 appropriate representation is used. All text files (including config) are
4037 assumed to be encoded in UTF-8.
4039 @chapter Filesystems
4040 NTFS, JFS, UDF, HFS+, exFAT, long filenames in FAT, Joliet part of
4041 ISO9660 are treated as UTF-16 as per specification. AFS and BFS are read
4042 as UTF-8, again according to specification. BtrFS, cpio, tar, squash4, minix,
4043 minix2, minix3, ROMFS, ReiserFS, XFS, ext2, ext3, ext4, FAT (short names),
4044 RockRidge part of ISO9660, nilfs2, UFS1, UFS2 and ZFS are assumed
4045 to be UTF-8. This might be false on systems configured with legacy charset
4046 but as long as the charset used is superset of ASCII you should be able to
4047 access ASCII-named files. And it's recommended to configure your system to use
4048 UTF-8 to access the filesystem, convmv may help with migration. ISO9660 (plain)
4049 filenames are specified as being ASCII or being described with unspecified
4050 escape sequences. GRUB assumes that the ISO9660 names are UTF-8 (since
4051 any ASCII is valid UTF-8). There are some old CD-ROMs which use CP437
4052 in non-compliant way. You're still able to access files with names containing
4053 only ASCII characters on such filesystems though. You're also able to access
4054 any file if the filesystem contains valid Joliet (UTF-16) or RockRidge (UTF-8).
4055 AFFS, SFS and HFS never use unicode and GRUB assumes them to be in Latin1,
4056 Latin1 and MacRoman respectively. GRUB handles filesystem case-insensitivity
4057 however no attempt is performed at case conversion of international characters
4058 so e.g. a file named lowercase greek alpha is treated as different from
4059 the one named as uppercase alpha. The filesystems in questions are
4060 NTFS (except POSIX namespace), HFS+ (configurable at mkfs time, default
4061 insensitive), SFS (configurable at mkfs time, default insensitive),
4062 JFS (configurable at mkfs time, default sensitive), HFS, AFFS, FAT, exFAT
4063 and ZFS (configurable on per-subvolume basis by property ``casesensitivity'',
4064 default sensitive). On ZFS subvolumes marked as case insensitive files
4065 containing lowercase international characters are inaccessible.
4066 Also like all supported filesystems except HFS+ and ZFS (configurable on
4067 per-subvolume basis by property ``normalization'', default none) GRUB makes
4068 no attempt at check of canonical equivalence so a file name u-diaresis is
4069 treated as distinct from u+combining diaresis. This however means that in
4070 order to access file on HFS+ its name must be specified in normalisation form D.
4071 On normalized ZFS subvolumes filenames out of normalisation are inaccessible.
4073 @chapter Output terminal
4074 Firmware output console ``console'' on ARC and IEEE1275 are limited to ASCII.
4075 BIOS firmware console and VGA text are limited to ASCII and some pseudographics.
4076 None of above mentioned is appropriate for displaying international and any
4077 unsupported character is replaced with question mark except pseudographics
4078 which we attempt to approximate with ASCII. EFI console on the other hand
4079 nominally supports UTF-16 but actual language coverage depends on firmware and
4080 may be very limited. The encoding used on serial can be chosen with
4081 @command{terminfo} as either ASCII, UTF-8 or ``visual UTF-8''. Last one is
4082 against the specification but results in correct rendering of right-to-left
4083 on some readers which don't have own bidi implementation. When using gfxterm
4084 or gfxmenu GRUB itself is responsible for rendering the text. In this case
4085 GRUB is limited by loaded fonts. If fonts contain all required characters
4086 then bidirectional text, cursive variants and combining marks other than
4087 enclosing, half (e.g. left half tilde or combining overline) and double ones.
4088 Ligatures aren't supported though. This should cover European, Middle Eastern
4089 (if you don't mind lack of lam-alif ligature in Arabic) and East Asian scripts.
4090 Notable unsupported scripts are Brahmic family and derived as well as
4091 Mongolian, Tifinagh, Korean Jamo (precomposed characters have no problem)
4092 and tonal writing (2e5-2e9). GRUB also ignores deprecated (as specified
4093 in Unicode) characters (e.g. tags). GRUB also doesn't handle so called
4094 ``annotation characters'' If you can complete either of
4095 two lists or, better, propose a patch to improve rendering, please contact
4096 developper team.
4098 @chapter Input terminal
4099 Firmware console on BIOS, IEEE1275 and ARC doesn't allow you to enter non-ASCII
4100 characters. EFI specification allows for such but author is unaware of any
4101 actual implementations. Serial input is currently limited for latin1 (unlikely
4102 to change). Own keyboard implementations (at_keyboard and usb_keyboard) 
4103 supports any key but work on one-char-per-keystroke.
4104 So no dead keys or advanced input method. Also there is no keymap change hotkey.
4105 In practice it makes difficult to enter any text using non-Latin alphabet.
4106 Moreover all current input consumers are limited to ASCII.
4108 @chapter Gettext
4109 GRUB supports being translated. For this you need to have language *.mo files in $prefix/locale, load gettext module and set ``lang'' variable.
4111 @chapter Regexp
4112 Regexps work on unicode characters, however no attempt at checking cannonical
4113 equivalence has been made. Moreover the classes like [:alpha:] match only
4114 ASCII subset.
4116 @chapter Other
4117 Currently GRUB always uses YEAR-MONTH-DAY HOUR:MINUTE:SECOND [WEEKDAY] 24-hour
4118 datetime format but weekdays are translated.
4119 GRUB always uses the decimal number format with [0-9] as digits and . as
4120 descimal separator and no group separator.
4121 IEEE1275 aliases are matched case-insensitively except non-ASCII which is
4122 matched as binary. Similar behaviour is for matching OSBundleRequired.
4123 Since IEEE1275 aliases and OSBundleRequired don't contain any non-ASCII it
4124 should never be a problem in practice.
4125 Case-sensitive identifiers are matched as raw strings, no canonical
4126 equivalence check is performed. Case-insenstive identifiers are matched
4127 as RAW but additionally [a-z] is equivalent to [A-Z]. GRUB-defined
4128 identifiers use only ASCII and so should user-defined ones.
4129 Identifiers containing non-ASCII may work but aren't supported.
4130 Only the ASCII space characters (space U+0020, tab U+000b, CR U+000d and
4131 LF U+000a) are recognised. Other unicode space characters aren't a valid
4132 field separator.
4133 @command{test} tests <, >, <=, >=, -pgt and -plt compare the strings in the
4134 lexicographical order of unicode codepoints, replicating the behaviour of
4135 test from coreutils.
4136 environment variables and commands are listed in the same order.
4138 @node Security
4139 @chapter Authentication and authorisation
4141 By default, the boot loader interface is accessible to anyone with physical
4142 access to the console: anyone can select and edit any menu entry, and anyone
4143 can get direct access to a GRUB shell prompt.  For most systems, this is
4144 reasonable since anyone with direct physical access has a variety of other
4145 ways to gain full access, and requiring authentication at the boot loader
4146 level would only serve to make it difficult to recover broken systems.
4148 However, in some environments, such as kiosks, it may be appropriate to lock
4149 down the boot loader to require authentication before performing certain
4150 operations.
4152 The @samp{password} (@pxref{password}) and @samp{password_pbkdf2}
4153 (@pxref{password_pbkdf2}) commands can be used to define users, each of
4154 which has an associated password.  @samp{password} sets the password in
4155 plain text, requiring @file{grub.cfg} to be secure; @samp{password_pbkdf2}
4156 sets the password hashed using the Password-Based Key Derivation Function
4157 (RFC 2898), requiring the use of @command{grub-mkpasswd-pbkdf2}
4158 (@pxref{Invoking grub-mkpasswd-pbkdf2}) to generate password hashes.
4160 In order to enable authentication support, the @samp{superusers} environment
4161 variable must be set to a list of usernames, separated by any of spaces,
4162 commas, semicolons, pipes, or ampersands.  Superusers are permitted to use
4163 the GRUB command line, edit menu entries, and execute any menu entry.  If
4164 @samp{superusers} is set, then use of the command line is automatically
4165 restricted to superusers.
4167 Other users may be given access to specific menu entries by giving a list of
4168 usernames (as above) using the @option{--users} option to the
4169 @samp{menuentry} command (@pxref{menuentry}).  If the @option{--unrestricted}
4170 option is used for a menu entry, then that entry is unrestricted.
4171 If the @option{--users} option is not used for a menu entry, then that
4172 only superusers are able to use it.
4174 Putting this together, a typical @file{grub.cfg} fragment might look like
4175 this:
4177 @example
4178 @group
4179 set superusers="root"
4180 password_pbkdf2 root grub.pbkdf2.sha512.10000.biglongstring
4181 password user1 insecure
4183 menuentry "May be run by any user" --unrestricted @{
4184         set root=(hd0,1)
4185         linux /vmlinuz
4188 menuentry "Superusers only" --users "" @{
4189         set root=(hd0,1)
4190         linux /vmlinuz single
4193 menuentry "May be run by user1 or a superuser" --users user1 @{
4194         set root=(hd0,2)
4195         chainloader +1
4197 @end group
4198 @end example
4200 The @command{grub-mkconfig} program does not yet have built-in support for
4201 generating configuration files with authentication.  You can use
4202 @file{/etc/grub.d/40_custom} to add simple superuser authentication, by
4203 adding @kbd{set superusers=} and @kbd{password} or @kbd{password_pbkdf2}
4204 commands.
4207 @node Platform limitations
4208 @chapter Platform limitations
4210 GRUB2 is designed to be portable and is actually ported across platforms. We
4211 try to keep all platforms at the level. Unfortunately some platforms are better
4212 supported than others. This is detailed in current and 2 following sections.
4214 ARC platform is unable to change datetime (firmware doesn't seem to provide a
4215 function for it).
4216 EMU has similar limitation.
4218 ARC platform no serial port is available.
4219 EMU has similar limitation.
4221 Console charset refers only to firmware-assisted console. gfxterm is always
4222 Unicode (see Internationalisation section for its limitations). Serial is
4223 configurable to UTF-8 or ASCII (see Internationalisation). In case of qemu
4224 and coreboot ports the refered console is vga_text. Loongson always uses
4225 gfxterm.
4227 Most limited one is ASCII. CP437 provides additionally pseudographics.
4228 GRUB2 doesn't use any language characters from CP437 as often CP437 is replaced
4229 by national encoding compatible only in pseudographics.
4230 Unicode is the most versatile charset which supports many languages. However
4231 the actual console may be much more limited depending on firmware
4233 On BIOS network is supported only if the image is loaded through network.
4234 On sparc64 GRUB is unable to determine which server it was booted from.
4236 On platforms not having direct serial support (as indicated in the line serial)
4237 you can still redirect firmware console to serial if it allows so.
4239 Direct ATA/AHCI support allows to circumvent various firmware limitations but
4240 isn't needed for normal operation except on baremetal ports.
4242 AT keyboard support allows keyboard layout remapping and support for keys not
4243 available through firmware. It isn't needed for normal operation except
4244 baremetal ports.
4246 USB support provides benefits similar to ATA (for USB disks) or AT (for USB
4247 keyboards). In addition it allows USBserial.
4249 Chainloading refers to the ability to load another bootloader through the same protocol
4251 Hints allow faster disk discovery by already knowing in advance which is the disk in
4252 question. On some platforms hints are correct unless you move the disk between boots.
4253 On other platforms it's just an educated guess.
4254 Note that hint failure results in just reduced performance, not a failure
4256 BadRAM is the ability to mark some of the RAM as ``bad''. Note: due to protocol
4257 limitations mips-loongson (with Linux protocol)
4258 and mips-qemu_mips can use only memory up to first hole.
4260 @multitable @columnfractions .20 .20 .20 .20 .20
4261 @item                    @tab BIOS    @tab Coreboot @tab Multiboot    @tab Qemu 
4262 @item video              @tab yes     @tab yes      @tab yes          @tab yes
4263 @item console charset    @tab CP437   @tab CP437    @tab CP437        @tab CP437
4264 @item network            @tab yes (*) @tab no       @tab no           @tab no
4265 @item ATA/AHCI           @tab yes     @tab yes      @tab yes          @tab yes
4266 @item AT keyboard        @tab yes     @tab yes      @tab yes          @tab yes
4267 @item USB                @tab yes     @tab yes      @tab yes          @tab yes
4268 @item chainloader        @tab local   @tab yes      @tab yes          @tab no
4269 @item cpuid              @tab partial @tab partial  @tab partial      @tab partial
4270 @item hints              @tab guess   @tab guess    @tab guess        @tab guess
4271 @item PCI                @tab yes     @tab yes      @tab yes          @tab yes
4272 @item badram             @tab yes     @tab yes      @tab yes          @tab yes
4273 @item compression        @tab always  @tab pointless @tab no           @tab no
4274 @item exit               @tab yes     @tab no       @tab no           @tab no
4275 @end multitable
4277 @multitable @columnfractions .20 .20 .20 .20 .20
4278 @item                    @tab ia32 EFI    @tab amd64 EFI @tab ia32 IEEE1275 @tab Itanium
4279 @item video              @tab yes         @tab yes       @tab no            @tab no
4280 @item console charset    @tab Unicode     @tab Unicode   @tab ASCII         @tab Unicode
4281 @item network            @tab yes         @tab yes       @tab yes           @tab yes
4282 @item ATA/AHCI           @tab yes         @tab yes       @tab yes           @tab no
4283 @item AT keyboard        @tab yes         @tab yes       @tab yes           @tab no
4284 @item USB                @tab yes         @tab yes       @tab yes           @tab no
4285 @item chainloader        @tab local       @tab local     @tab no            @tab local
4286 @item cpuid              @tab partial     @tab partial   @tab partial       @tab no
4287 @item hints              @tab guess       @tab guess     @tab good          @tab guess
4288 @item PCI                @tab yes         @tab yes       @tab yes           @tab no
4289 @item badram             @tab yes         @tab yes       @tab no            @tab yes
4290 @item compression        @tab no          @tab no        @tab no            @tab no
4291 @item exit               @tab yes         @tab yes       @tab yes           @tab yes
4292 @end multitable
4294 @multitable @columnfractions .20 .20 .20 .20 .20
4295 @item                    @tab Loongson    @tab sparc64 @tab Powerpc @tab ARC
4296 @item video              @tab yes         @tab no      @tab yes     @tab no
4297 @item console charset    @tab N/A         @tab ASCII   @tab ASCII   @tab ASCII
4298 @item network            @tab no          @tab yes (*) @tab yes     @tab no
4299 @item ATA/AHCI           @tab yes         @tab no      @tab no      @tab no
4300 @item AT keyboard        @tab yes         @tab no      @tab no      @tab no
4301 @item USB                @tab yes         @tab no      @tab no      @tab no
4302 @item chainloader        @tab yes         @tab no      @tab no      @tab no
4303 @item cpuid              @tab no          @tab no      @tab no      @tab no
4304 @item hints              @tab good        @tab good    @tab good    @tab no
4305 @item PCI                @tab yes         @tab no      @tab no      @tab no
4306 @item badram             @tab yes (*)     @tab no      @tab no      @tab no
4307 @item compression        @tab configurable @tab no     @tab no      @tab configurable
4308 @item exit               @tab no          @tab yes     @tab yes     @tab yes
4309 @end multitable
4311 @multitable @columnfractions .20 .20 .20 .20 .20
4312 @item                    @tab MIPS qemu @tab emu
4313 @item video              @tab no        @tab yes
4314 @item console charset    @tab CP437     @tab ASCII
4315 @item network            @tab no        @tab yes
4316 @item ATA/AHCI           @tab yes       @tab no
4317 @item AT keyboard        @tab yes       @tab no
4318 @item USB                @tab N/A       @tab yes
4319 @item chainloader        @tab yes       @tab no
4320 @item cpuid              @tab no        @tab no
4321 @item hints              @tab guess     @tab no
4322 @item PCI                @tab no        @tab no
4323 @item badram             @tab yes (*)   @tab no
4324 @item compression        @tab configurable @tab no
4325 @item exit               @tab no        @tab yes
4326 @end multitable
4328 @node Platform-specific operations
4329 @chapter Outline
4331 Some platforms have features which allows to implement
4332 some commands useless or not implementable on others.
4334 Quick summary:
4336 Information retrieval:
4338 @itemize
4339 @item mipsel-loongson: lsspd
4340 @item mips-arc: lsdev
4341 @item efi: lsefisystab, lssal, lsefimmap
4342 @item i386-pc: lsapm
4343 @item acpi-enabled (i386-pc, i386-coreboot, i386-multiboot, *-efi): lsacpi
4344 @end itemize
4346 Workarounds for platform-specific issues:
4347 @itemize
4348 @item i386-efi/x86_64-efi: loadbios, fixvideo
4349 @item acpi-enabled (i386-pc, i386-coreboot, i386-multiboot, *-efi):
4350     acpi (override ACPI tables)
4351 @item i386-pc: drivemap
4352 @item i386-pc: sendkey
4353 @end itemize
4355 Advanced operations for power users:
4356 @itemize
4357 @item x86: iorw (direct access to I/O ports)
4358 @end itemize
4360 Miscelaneous:
4361 @itemize
4362 @item cmos (x86-*, ieee1275, mips-qemu_mips, mips-loongson): cmostest
4363     (used on some laptops to check for special power-on key)
4364 @item i386-pc: play
4365 @end itemize
4367 @node Supported kernels
4368 @chapter Supported boot targets
4370 X86 support is summarised in the following table. ``Yes'' means that the kernel works on the given platform, ``crashes'' means an early kernel crash which we hope will be fixed by concerned kernel developers. ``no'' means GRUB doesn't load the given kernel on a given platform. ``headless'' means that the kernel works but lacks console drivers (you can still use serial or network console).  In case of ``no'' and ``crashes'' the reason is given in footnote.
4371 @multitable @columnfractions .50 .22 .22
4372 @item                                @tab BIOS    @tab Coreboot
4373 @item BIOS chainloading              @tab yes     @tab no (1)
4374 @item NTLDR                          @tab yes     @tab no (1)
4375 @item Plan9                          @tab yes     @tab no (1)
4376 @item Freedos                        @tab yes     @tab no (1)
4377 @item FreeBSD bootloader             @tab yes     @tab crashes (1)
4378 @item 32-bit kFreeBSD                @tab yes     @tab crashes (2,6)
4379 @item 64-bit kFreeBSD                @tab yes     @tab crashes (2,6)
4380 @item 32-bit kNetBSD                 @tab yes     @tab crashes (1)
4381 @item 64-bit kNetBSD                 @tab yes     @tab crashes (2)
4382 @item 32-bit kOpenBSD                @tab yes     @tab yes
4383 @item 64-bit kOpenBSD                @tab yes     @tab yes
4384 @item Multiboot                      @tab yes     @tab yes
4385 @item Multiboot2                     @tab yes     @tab yes
4386 @item 32-bit Linux (legacy protocol) @tab yes     @tab no (1)
4387 @item 64-bit Linux (legacy protocol) @tab yes     @tab no (1)
4388 @item 32-bit Linux (modern protocol) @tab yes     @tab yes
4389 @item 64-bit Linux (modern protocol) @tab yes     @tab yes
4390 @item 32-bit XNU                     @tab yes     @tab ?
4391 @item 64-bit XNU                     @tab yes     @tab ?
4392 @item 32-bit EFI chainloader         @tab no (3)  @tab no (3)
4393 @item 64-bit EFI chainloader         @tab no (3)  @tab no (3)
4394 @item Appleloader                    @tab no (3)  @tab no (3)
4395 @end multitable
4397 @multitable @columnfractions .50 .22 .22
4398 @item                                @tab Multiboot    @tab Qemu 
4399 @item BIOS chainloading              @tab no (1)       @tab no (1)
4400 @item NTLDR                          @tab no (1)       @tab no (1)
4401 @item Plan9                          @tab no (1)       @tab no (1)
4402 @item FreeDOS                        @tab no (1)       @tab no (1)
4403 @item FreeBSD bootloader             @tab crashes (1)  @tab crashes (1)
4404 @item 32-bit kFreeBSD                @tab crashes (6)  @tab crashes (6)
4405 @item 64-bit kFreeBSD                @tab crashes (6)  @tab crashes (6)
4406 @item 32-bit kNetBSD                 @tab crashes (1)  @tab crashes (1)  
4407 @item 64-bit kNetBSD                 @tab yes          @tab yes
4408 @item 32-bit kOpenBSD                @tab yes          @tab yes
4409 @item 64-bit kOpenBSD                @tab yes          @tab yes
4410 @item Multiboot                      @tab yes          @tab yes
4411 @item Multiboot2                     @tab yes          @tab yes
4412 @item 32-bit Linux (legacy protocol) @tab no (1)       @tab no (1)
4413 @item 64-bit Linux (legacy protocol) @tab no (1)       @tab no (1)
4414 @item 32-bit Linux (modern protocol) @tab yes          @tab yes
4415 @item 64-bit Linux (modern protocol) @tab yes          @tab yes
4416 @item 32-bit XNU                     @tab ?            @tab ?
4417 @item 64-bit XNU                     @tab ?            @tab ?
4418 @item 32-bit EFI chainloader         @tab no (3)       @tab no (3)
4419 @item 64-bit EFI chainloader         @tab no (3)       @tab no (3)
4420 @item Appleloader                    @tab no (3)       @tab no (3)
4421 @end multitable
4423 @multitable @columnfractions .50 .22 .22
4424 @item                                @tab ia32 EFI      @tab amd64 EFI
4425 @item BIOS chainloading              @tab no (1)        @tab no (1)
4426 @item NTLDR                          @tab no (1)        @tab no (1)
4427 @item Plan9                          @tab no (1)        @tab no (1)
4428 @item FreeDOS                        @tab no (1)        @tab no (1)
4429 @item FreeBSD bootloader             @tab crashes (1)   @tab crashes (1)
4430 @item 32-bit kFreeBSD                @tab headless      @tab headless
4431 @item 64-bit kFreeBSD                @tab headless      @tab headless
4432 @item 32-bit kNetBSD                 @tab crashes (1)   @tab crashes (1)
4433 @item 64-bit kNetBSD                 @tab yes           @tab yes
4434 @item 32-bit kOpenBSD                @tab headless      @tab headless
4435 @item 64-bit kOpenBSD                @tab headless      @tab headless
4436 @item Multiboot                      @tab yes           @tab yes
4437 @item Multiboot2                     @tab yes           @tab yes
4438 @item 32-bit Linux (legacy protocol) @tab no (1)        @tab no (1)
4439 @item 64-bit Linux (legacy protocol) @tab no (1)        @tab no (1)
4440 @item 32-bit Linux (modern protocol) @tab yes           @tab yes
4441 @item 64-bit Linux (modern protocol) @tab yes           @tab yes
4442 @item 32-bit XNU                     @tab yes           @tab yes
4443 @item 64-bit XNU                     @tab yes (5)       @tab yes
4444 @item 32-bit EFI chainloader         @tab yes           @tab no (4)
4445 @item 64-bit EFI chainloader         @tab no (4)        @tab yes
4446 @item Appleloader                    @tab yes           @tab yes
4447 @end multitable
4449 @multitable @columnfractions .50 .22 .22
4450 @item                                @tab ia32 IEEE1275
4451 @item BIOS chainloading              @tab no (1)
4452 @item NTLDR                          @tab no (1)
4453 @item Plan9                          @tab no (1)
4454 @item FreeDOS                        @tab no (1)
4455 @item FreeBSD bootloader             @tab crashes (1)
4456 @item 32-bit kFreeBSD                @tab crashes (6)
4457 @item 64-bit kFreeBSD                @tab crashes (6)
4458 @item 32-bit kNetBSD                 @tab crashes (1)
4459 @item 64-bit kNetBSD                 @tab ?
4460 @item 32-bit kOpenBSD                @tab ?
4461 @item 64-bit kOpenBSD                @tab ?
4462 @item Multiboot                      @tab ?
4463 @item Multiboot2                     @tab ?
4464 @item 32-bit Linux (legacy protocol) @tab no (1)
4465 @item 64-bit Linux (legacy protocol) @tab no (1)
4466 @item 32-bit Linux (modern protocol) @tab ?
4467 @item 64-bit Linux (modern protocol) @tab ?
4468 @item 32-bit XNU                     @tab ?
4469 @item 64-bit XNU                     @tab ?
4470 @item 32-bit EFI chainloader         @tab no (3)
4471 @item 64-bit EFI chainloader         @tab no (3)
4472 @item Appleloader                    @tab no (3)
4473 @end multitable
4475 @enumerate
4476 @item Requires BIOS
4477 @item Crashes because the memory at 0x0-0x1000 isn't available
4478 @item EFI only
4479 @item 32-bit and 64-bit EFI have different structures and work in different CPU modes so it's not possible to chainload 32-bit bootloader on 64-bit platform and vice-versa
4480 @item Some modules may need to be disabled
4481 @item Requires ACPI
4482 @end enumerate
4484 PowerPC, IA64 and Sparc64 ports support only Linux. MIPS port supports Linux
4485 and multiboot2.
4487 @chapter Boot tests
4489 As you have seen in previous chapter the support matrix is pretty big and some of the configurations are only rarely used. To ensure the quality bootchecks are available for all x86 targets except EFI chainloader, Appleloader and XNU. All x86 platforms have bootcheck facility except ieee1275. Multiboot, multiboot2, BIOS chainloader, ntldr and freebsd-bootloader boot targets are tested only with a fake kernel images. Only Linux is tested among the payloads using Linux protocols.
4491 Following variables must be defined:
4493 @multitable  @columnfractions .30 .65
4494 @item GRUB_PAYLOADS_DIR @tab directory containing the required kernels
4495 @item GRUB_CBFSTOOL @tab cbfstoll from Coreboot package (for coreboot platform only)
4496 @item GRUB_COREBOOT_ROM @tab empty Coreboot ROM
4497 @item GRUB_QEMU_OPTS @tab additional options to be supplied to QEMU
4498 @end multitable
4500 Required files are:
4502 @multitable  @columnfractions .40 .55
4503 @item kfreebsd_env.i386 @tab 32-bit kFreeBSD device hints
4504 @item kfreebsd.i386 @tab 32-bit FreeBSD kernel image
4505 @item kfreebsd.x86_64, kfreebsd_env.x86_64 @tab same from 64-bit kFreeBSD
4506 @item knetbsd.i386 @tab 32-bit NetBSD kernel image
4507 @item knetbsd.miniroot.i386 @tab 32-bit kNetBSD miniroot.kmod.
4508 @item knetbsd.x86_64, knetbsd.miniroot.x86_64  @tab same from 64-bit kNetBSD
4509 @item kopenbsd.i386 @tab 32-bit OpenBSD kernel bsd.rd image
4510 @item kopenbsd.x86_64 @tab same from 64-bit kOpenBSD
4511 @item linux.i386 @tab 32-bit Linux
4512 @item linux.x86_64 @tab 64-bit Linux
4513 @end multitable
4515 @node Troubleshooting
4516 @chapter Error messages produced by GRUB
4518 @menu
4519 * GRUB only offers a rescue shell::
4520 @end menu
4523 @node GRUB only offers a rescue shell
4524 @section GRUB only offers a rescue shell
4526 GRUB's normal start-up procedure involves setting the @samp{prefix}
4527 environment variable to a value set in the core image by
4528 @command{grub-install}, setting the @samp{root} variable to match, loading
4529 the @samp{normal} module from the prefix, and running the @samp{normal}
4530 command (@pxref{normal}).  This command is responsible for reading
4531 @file{/boot/grub/grub.cfg}, running the menu, and doing all the useful
4532 things GRUB is supposed to do.
4534 If, instead, you only get a rescue shell, this usually means that GRUB
4535 failed to load the @samp{normal} module for some reason.  It may be possible
4536 to work around this temporarily: for instance, if the reason for the failure
4537 is that @samp{prefix} is wrong (perhaps it refers to the wrong device, or
4538 perhaps the path to @file{/boot/grub} was not correctly made relative to the
4539 device), then you can correct this and enter normal mode manually:
4541 @example
4542 @group
4543 # Inspect the current prefix (and other preset variables):
4545 # Find out which devices are available:
4547 # Set to the correct value, which might be something like this:
4548 set prefix=(hd0,1)/grub
4549 set root=(hd0,1)
4550 insmod normal
4551 normal
4552 @end group
4553 @end example
4555 However, any problem that leaves you in the rescue shell probably means that
4556 GRUB was not correctly installed.  It may be more useful to try to reinstall
4557 it properly using @kbd{grub-install @var{device}} (@pxref{Invoking
4558 grub-install}).  When doing this, there are a few things to remember:
4560 @itemize @bullet{}
4561 @item
4562 Drive ordering in your operating system may not be the same as the boot
4563 drive ordering used by your firmware.  Do not assume that your first hard
4564 drive (e.g. @samp{/dev/sda}) is the one that your firmware will boot from.
4565 @file{device.map} (@pxref{Device map}) can be used to override this, but it
4566 is usually better to use UUIDs or file system labels and avoid depending on
4567 drive ordering entirely.
4569 @item
4570 At least on BIOS systems, if you tell @command{grub-install} to install GRUB
4571 to a partition but GRUB has already been installed in the master boot
4572 record, then the GRUB installation in the partition will be ignored.
4574 @item
4575 If possible, it is generally best to avoid installing GRUB to a partition
4576 (unless it is a special partition for the use of GRUB alone, such as the
4577 BIOS Boot Partition used on GPT).  Doing this means that GRUB may stop being
4578 able to read its core image due to a file system moving blocks around, such
4579 as while defragmenting, running checks, or even during normal operation.
4580 Installing to the whole disk device is normally more robust.
4582 @item
4583 Check that GRUB actually knows how to read from the device and file system
4584 containing @file{/boot/grub}.  It will not be able to read from encrypted
4585 devices, nor from file systems for which support has not yet been added to
4586 GRUB.
4587 @end itemize
4590 @node Invoking grub-install
4591 @chapter Invoking grub-install
4593 The program @command{grub-install} installs GRUB on your drive using
4594 @command{grub-mkimage} and (on some platforms) @command{grub-setup}.  You
4595 must specify the device name on which you want to install GRUB, like this:
4597 @example
4598 grub-install @var{install_device}
4599 @end example
4601 The device name @var{install_device} is an OS device name or a GRUB
4602 device name.
4604 @command{grub-install} accepts the following options:
4606 @table @option
4607 @item --help
4608 Print a summary of the command-line options and exit.
4610 @item --version
4611 Print the version number of GRUB and exit.
4613 @item --boot-directory=@var{dir}
4614 Install GRUB images under the directory @file{@var{dir}/grub/}
4615 This option is useful when you want to install GRUB into a
4616 separate partition or a removable disk.
4617 If this option is not specified then it defaults to @file{/boot}, so
4619 @example
4620 @kbd{grub-install /dev/sda}
4621 @end example
4623 is equivalent to
4625 @example
4626 @kbd{grub-install --boot-directory=/boot/ /dev/sda}
4627 @end example
4629 Here is an example in which you have a separate @dfn{boot} partition which is 
4630 mounted on
4631 @file{/mnt/boot}:
4633 @example
4634 @kbd{grub-install --boot-directory=/mnt/boot /dev/sdb}
4635 @end example
4637 @item --recheck
4638 Recheck the device map, even if @file{/boot/grub/device.map} already
4639 exists. You should use this option whenever you add/remove a disk
4640 into/from your computer.
4641 @end table
4644 @node Invoking grub-mkconfig
4645 @chapter Invoking grub-mkconfig
4647 The program @command{grub-mkconfig} generates a configuration file for GRUB
4648 (@pxref{Simple configuration}).
4650 @example
4651 grub-mkconfig -o /boot/grub/grub.cfg
4652 @end example
4654 @command{grub-mkconfig} accepts the following options:
4656 @table @option
4657 @item --help
4658 Print a summary of the command-line options and exit.
4660 @item --version
4661 Print the version number of GRUB and exit.
4663 @item -o @var{file}
4664 @itemx --output=@var{file}
4665 Send the generated configuration file to @var{file}.  The default is to send
4666 it to standard output.
4667 @end table
4670 @node Invoking grub-mkpasswd-pbkdf2
4671 @chapter Invoking grub-mkpasswd-pbkdf2
4673 The program @command{grub-mkpasswd-pbkdf2} generates password hashes for
4674 GRUB (@pxref{Security}).
4676 @example
4677 grub-mkpasswd-pbkdf2
4678 @end example
4680 @command{grub-mkpasswd-pbkdf2} accepts the following options:
4682 @table @option
4683 @item -c @var{number}
4684 @itemx --iteration-count=@var{number}
4685 Number of iterations of the underlying pseudo-random function.  Defaults to
4686 10000.
4688 @item -l @var{number}
4689 @itemx --buflen=@var{number}
4690 Length of the generated hash.  Defaults to 64.
4692 @item -s @var{number}
4693 @itemx --salt=@var{number}
4694 Length of the salt.  Defaults to 64.
4695 @end table
4698 @node Invoking grub-mkrescue
4699 @chapter Invoking grub-mkrescue
4701 The program @command{grub-mkrescue} generates a bootable GRUB rescue image
4702 (@pxref{Making a GRUB bootable CD-ROM}).
4704 @example
4705 grub-mkrescue -o grub.iso
4706 @end example
4708 All arguments not explicitly listed as @command{grub-mkrescue} options are
4709 passed on directly to @command{xorriso} in @command{mkisofs} emulation mode.
4710 Options passed to @command{xorriso} will normally be interpreted as
4711 @command{mkisofs} options; if the option @samp{--} is used, then anything
4712 after that will be interpreted as native @command{xorriso} options.
4714 Non-option arguments specify additional source directories.  This is
4715 commonly used to add extra files to the image:
4717 @example
4718 mkdir -p disk/boot/grub
4719 @r{(add extra files to @file{disk/boot/grub})}
4720 grub-mkrescue -o grub.iso disk
4721 @end example
4723 @command{grub-mkrescue} accepts the following options:
4725 @table @option
4726 @item --help
4727 Print a summary of the command-line options and exit.
4729 @item --version
4730 Print the version number of GRUB and exit.
4732 @item -o @var{file}
4733 @itemx --output=@var{file}
4734 Save output in @var{file}.  This "option" is required.
4736 @item --modules=@var{modules}
4737 Pre-load the named GRUB modules in the image.  Multiple entries in
4738 @var{modules} should be separated by whitespace (so you will probably need
4739 to quote this for your shell).
4741 @item --rom-directory=@var{dir}
4742 If generating images for the QEMU or Coreboot platforms, copy the resulting
4743 @file{qemu.img} or @file{coreboot.elf} files respectively to the @var{dir}
4744 directory as well as including them in the image.
4746 @item --xorriso=@var{file}
4747 Use @var{file} as the @command{xorriso} program, rather than the built-in
4748 default.
4750 @item --grub-mkimage=@var{file}
4751 Use @var{file} as the @command{grub-mkimage} program, rather than the
4752 built-in default.
4753 @end table
4756 @node Invoking grub-probe
4757 @chapter Invoking grub-probe
4759 The program @command{grub-probe} probes device information for a given path
4760 or device.
4762 @example
4763 grub-probe --target=fs /boot/grub
4764 grub-probe --target=drive --device /dev/sda1
4765 @end example
4767 @command{grub-probe} must be given a path or device as a non-option
4768 argument, and also accepts the following options:
4770 @table @option
4771 @item --help
4772 Print a summary of the command-line options and exit.
4774 @item --version
4775 Print the version number of GRUB and exit.
4777 @item -d
4778 @itemx --device
4779 If this option is given, then the non-option argument is a system device
4780 name (such as @samp{/dev/sda1}), and @command{grub-probe} will print
4781 information about that device.  If it is not given, then the non-option
4782 argument is a filesystem path (such as @samp{/boot/grub}), and
4783 @command{grub-probe} will print information about the device containing that
4784 part of the filesystem.
4786 @item -m @var{file}
4787 @itemx --device-map=@var{file}
4788 Use @var{file} as the device map (@pxref{Device map}) rather than the
4789 default, usually @samp{/boot/grub/device.map}.
4791 @item -t @var{target}
4792 @itemx --target=@var{target}
4793 Print information about the given path or device as defined by @var{target}.
4794 The available targets and their meanings are:
4796 @table @samp
4797 @item fs
4798 GRUB filesystem module.
4799 @item fs_uuid
4800 Filesystem Universally Unique Identifier (UUID).
4801 @item fs_label
4802 Filesystem label.
4803 @item drive
4804 GRUB device name.
4805 @item device
4806 System device name.
4807 @item partmap
4808 GRUB partition map module.
4809 @item abstraction
4810 GRUB abstraction module (e.g. @samp{lvm}).
4811 @item cryptodisk_uuid
4812 Crypto device UUID.
4813 @item msdos_parttype
4814 MBR partition type code (two hexadecimal digits).
4815 @item hints_string
4816 A string of platform search hints suitable for passing to the
4817 @command{search} command (@pxref{search}).
4818 @item bios_hints
4819 Search hints for the PC BIOS platform.
4820 @item ieee1275_hints
4821 Search hints for the IEEE1275 platform.
4822 @item baremetal_hints
4823 Search hints for platforms where disks are addressed directly rather than
4824 via firmware.
4825 @item efi_hints
4826 Search hints for the EFI platform.
4827 @item arc_hints
4828 Search hints for the ARC platform.
4829 @item compatibility_hint
4830 A guess at a reasonable GRUB drive name for this device, which may be
4831 used as a fallback if the @command{search} command fails.
4832 @item disk
4833 System device name for the whole disk.
4834 @end table
4836 @item -v
4837 @itemx --verbose
4838 Print verbose messages.
4839 @end table
4842 @node Obtaining and Building GRUB
4843 @appendix How to obtain and build GRUB
4845 @quotation
4846 @strong{Caution:} GRUB requires binutils-2.9.1.0.23 or later because the
4847 GNU assembler has been changed so that it can produce real 16bits
4848 machine code between 2.9.1 and 2.9.1.0.x. See
4849 @uref{http://sources.redhat.com/binutils/}, to obtain information on
4850 how to get the latest version.
4851 @end quotation
4853 GRUB is available from the GNU alpha archive site
4854 @uref{ftp://ftp.gnu.org/gnu/grub} or any of its mirrors. The file
4855 will be named grub-version.tar.gz. The current version is
4856 @value{VERSION}, so the file you should grab is:
4858 @uref{ftp://ftp.gnu.org/gnu/grub/grub-@value{VERSION}.tar.gz}
4860 To unbundle GRUB use the instruction:
4862 @example
4863 @kbd{zcat grub-@value{VERSION}.tar.gz | tar xvf -}
4864 @end example
4866 which will create a directory called @file{grub-@value{VERSION}} with
4867 all the sources. You can look at the file @file{INSTALL} for detailed
4868 instructions on how to build and install GRUB, but you should be able to
4869 just do:
4871 @example
4872 @group
4873 @kbd{cd grub-@value{VERSION}}
4874 @kbd{./configure}
4875 @kbd{make install}
4876 @end group
4877 @end example
4879 Also, the latest version is available using Bazaar. See
4880 @uref{http://www.gnu.org/software/grub/grub-download.en.html} for more
4881 information.
4883 @node Reporting bugs
4884 @appendix Reporting bugs
4886 These are the guideline for how to report bugs. Take a look at this
4887 list below before you submit bugs:
4889 @enumerate
4890 @item
4891 Before getting unsettled, read this manual through and through. Also,
4892 see the @uref{http://www.gnu.org/software/grub/grub-faq.html, GNU GRUB FAQ}.
4894 @item
4895 Always mention the information on your GRUB. The version number and the
4896 configuration are quite important. If you build it yourself, write the
4897 options specified to the configure script and your operating system,
4898 including the versions of gcc and binutils.
4900 @item
4901 If you have trouble with the installation, inform us of how you
4902 installed GRUB. Don't omit error messages, if any. Just @samp{GRUB hangs
4903 up when it boots} is not enough.
4905 The information on your hardware is also essential. These are especially
4906 important: the geometries and the partition tables of your hard disk
4907 drives and your BIOS.
4909 @item
4910 If GRUB cannot boot your operating system, write down
4911 @emph{everything} you see on the screen. Don't paraphrase them, like
4912 @samp{The foo OS crashes with GRUB, even though it can boot with the
4913 bar boot loader just fine}. Mention the commands you executed, the
4914 messages printed by them, and information on your operating system
4915 including the version number.
4917 @item
4918 Explain what you wanted to do. It is very useful to know your purpose
4919 and your wish, and how GRUB didn't satisfy you.
4921 @item
4922 If you can investigate the problem yourself, please do. That will give
4923 you and us much more information on the problem. Attaching a patch is
4924 even better.
4926 When you attach a patch, make the patch in unified diff format, and
4927 write ChangeLog entries. But, even when you make a patch, don't forget
4928 to explain the problem, so that we can understand what your patch is
4929 for.
4931 @item
4932 Write down anything that you think might be related. Please understand
4933 that we often need to reproduce the same problem you encountered in our
4934 environment. So your information should be sufficient for us to do the
4935 same thing---Don't forget that we cannot see your computer directly. If
4936 you are not sure whether to state a fact or leave it out, state it!
4937 Reporting too many things is much better than omitting something
4938 important.
4939 @end enumerate
4941 If you follow the guideline above, submit a report to the
4942 @uref{http://savannah.gnu.org/bugs/?group=grub, Bug Tracking System}.
4943 Alternatively, you can submit a report via electronic mail to
4944 @email{bug-grub@@gnu.org}, but we strongly recommend that you use the
4945 Bug Tracking System, because e-mail can be passed over easily.
4947 Once we get your report, we will try to fix the bugs.
4950 @node Future
4951 @appendix Where GRUB will go
4953 GRUB 2 is now quite stable and used in many production systems.  We are
4954 currently working towards a 2.0 release.
4956 If you are interested in the development of GRUB 2, take a look at
4957 @uref{http://www.gnu.org/software/grub/grub.html, the homepage}.
4963 @node Copying This Manual
4964 @appendix Copying This Manual
4966 @menu
4967 * GNU Free Documentation License::  License for copying this manual.
4968 @end menu
4970 @include fdl.texi
4973 @node Index
4974 @unnumbered Index
4976 @c Currently, we use only the Concept Index.
4977 @printindex cp
4980 @bye
4982 Some notes:
4984   This is an attempt to make a manual for GRUB 2. The contents are
4985   copied from the GRUB manual in GRUB Legacy, so they are not always
4986   appropriate yet for GRUB 2.