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