]> git.proxmox.com Git - grub2.git/blob - docs/grub.texi
* docs/grub.texi (Simple configuration): Fix copy-and-paste typo.
[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 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 @end direntry
39
40 @setchapternewpage odd
41
42 @titlepage
43 @sp 10
44 @title the GNU GRUB manual
45 @subtitle The GRand Unified Bootloader, version @value{VERSION}, @value{UPDATED}.
46 @author Gordon Matzigkeit
47 @author Yoshinori K. Okuji
48 @c The following two commands start the copyright page.
49 @page
50 @vskip 0pt plus 1filll
51 @insertcopying
52 @end titlepage
53
54 @c Output the table of contents at the beginning.
55 @contents
56
57 @finalout
58 @headings double
59
60 @ifnottex
61 @node Top
62 @top GNU GRUB manual
63
64 This is the documentation of GNU GRUB, the GRand Unified Bootloader,
65 a flexible and powerful boot loader program for a wide range of
66 architectures.
67
68 This edition documents version @value{VERSION}.
69
70 @insertcopying
71 @end ifnottex
72
73 @menu
74 * Introduction:: Capturing the spirit of GRUB
75 * Naming convention:: Names of your drives in GRUB
76 * Installation:: Installing GRUB on your drive
77 * Booting:: How to boot different operating systems
78 * Configuration:: Writing your own configuration file
79 * Network:: Downloading OS images from a network
80 * Serial terminal:: Using GRUB via a serial line
81 * Vendor power-on keys:: Changing GRUB behaviour on vendor power-on keys
82 * Preset Menu:: Embedding a configuration file into GRUB
83 * Images:: GRUB image files
84 * Filesystem:: Filesystem syntax and semantics
85 * Interface:: The menu and the command-line
86 * Commands:: The list of available builtin commands
87 * Troubleshooting:: Error messages produced by GRUB
88 * Invoking grub-install:: How to use the GRUB installer
89 * Invoking grub-mkconfig:: Generate a GRUB configuration file
90 * Obtaining and Building GRUB:: How to obtain and build GRUB
91 * Reporting bugs:: Where you should send a bug report
92 * Future:: Some future plans on GRUB
93 * Internals:: Hacking GRUB
94 * Copying This Manual:: Copying This Manual
95 * Index::
96 @end menu
97
98
99 @node Introduction
100 @chapter Introduction to GRUB
101
102 @menu
103 * Overview:: What exactly GRUB is and how to use it
104 * History:: From maggot to house fly
105 * Features:: GRUB features
106 * Role of a boot loader:: The role of a boot loader
107 @end menu
108
109
110 @node Overview
111 @section Overview
112
113 Briefly, a @dfn{boot loader} is the first software program that runs when
114 a computer starts. It is responsible for loading and transferring
115 control to an operating system @dfn{kernel} software (such as Linux or
116 GNU Mach). The kernel, in turn, initializes the rest of the operating
117 system (e.g. a GNU system).
118
119 GNU GRUB is a very powerful boot loader, which can load a wide variety
120 of free operating systems, as well as proprietary operating systems with
121 chain-loading@footnote{@dfn{chain-load} is the mechanism for loading
122 unsupported operating systems by loading another boot loader. It is
123 typically used for loading DOS or Windows.}. GRUB is designed to
124 address the complexity of booting a personal computer; both the
125 program and this manual are tightly bound to that computer platform,
126 although porting to other platforms may be addressed in the future.
127
128 One of the important features in GRUB is flexibility; GRUB understands
129 filesystems and kernel executable formats, so you can load an arbitrary
130 operating system the way you like, without recording the physical
131 position of your kernel on the disk. Thus you can load the kernel
132 just by specifying its file name and the drive and partition where the
133 kernel resides.
134
135 When booting with GRUB, you can use either a command-line interface
136 (@pxref{Command-line interface}), or a menu interface (@pxref{Menu
137 interface}). Using the command-line interface, you type the drive
138 specification and file name of the kernel manually. In the menu
139 interface, you just select an OS using the arrow keys. The menu is
140 based on a configuration file which you prepare beforehand
141 (@pxref{Configuration}). While in the menu, you can switch to the
142 command-line mode, and vice-versa. You can even edit menu entries
143 before using them.
144
145 In the following chapters, you will learn how to specify a drive, a
146 partition, and a file name (@pxref{Naming convention}) to GRUB, how to
147 install GRUB on your drive (@pxref{Installation}), and how to boot your
148 OSes (@pxref{Booting}), step by step.
149
150
151 @node History
152 @section History of GRUB
153
154 GRUB originated in 1995 when Erich Boleyn was trying to boot the GNU
155 Hurd with the University of Utah's Mach 4 microkernel (now known as GNU
156 Mach). Erich and Brian Ford designed the Multiboot Specification
157 (@pxref{Top, Multiboot Specification, Motivation, multiboot, The Multiboot
158 Specification}), because they were determined not to add to the large
159 number of mutually-incompatible PC boot methods.
160
161 Erich then began modifying the FreeBSD boot loader so that it would
162 understand Multiboot. He soon realized that it would be a lot easier
163 to write his own boot loader from scratch than to keep working on the
164 FreeBSD boot loader, and so GRUB was born.
165
166 Erich added many features to GRUB, but other priorities prevented him
167 from keeping up with the demands of its quickly-expanding user base. In
168 1999, Gordon Matzigkeit and Yoshinori K. Okuji adopted GRUB as an
169 official GNU package, and opened its development by making the latest
170 sources available via anonymous CVS. @xref{Obtaining and Building
171 GRUB}, for more information.
172
173
174 @node Features
175 @section GRUB features
176
177 The primary requirement for GRUB is that it be compliant with the
178 @dfn{Multiboot Specification}, which is described in @ref{Top, Multiboot
179 Specification, Motivation, multiboot, The Multiboot Specification}.
180
181 The other goals, listed in approximate order of importance, are:
182
183 @itemize @bullet{}
184 @item
185 Basic functions must be straightforward for end-users.
186
187 @item
188 Rich functionality to support kernel experts and designers.
189
190 @item
191 Backward compatibility for booting FreeBSD, NetBSD, OpenBSD, and
192 Linux. Proprietary kernels (such as DOS, Windows NT, and OS/2) are
193 supported via a chain-loading function.
194 @end itemize
195
196 Except for specific compatibility modes (chain-loading and the Linux
197 @dfn{piggyback} format), all kernels will be started in much the same
198 state as in the Multiboot Specification. Only kernels loaded at 1 megabyte
199 or above are presently supported. Any attempt to load below that
200 boundary will simply result in immediate failure and an error message
201 reporting the problem.
202
203 In addition to the requirements above, GRUB has the following features
204 (note that the Multiboot Specification doesn't require all the features
205 that GRUB supports):
206
207 @table @asis
208 @item Recognize multiple executable formats
209 Support many of the @dfn{a.out} variants plus @dfn{ELF}. Symbol
210 tables are also loaded.
211
212 @item Support non-Multiboot kernels
213 Support many of the various free 32-bit kernels that lack Multiboot
214 compliance (primarily FreeBSD, NetBSD, OpenBSD, and
215 Linux). Chain-loading of other boot loaders is also supported.
216
217 @item Load multiples modules
218 Fully support the Multiboot feature of loading multiple modules.
219
220 @item Load a configuration file
221 Support a human-readable text configuration file with preset boot
222 commands. You can also load another configuration file dynamically and
223 embed a preset configuration file in a GRUB image file. The list of
224 commands (@pxref{Commands}) are a superset of those supported on the
225 command-line. An example configuration file is provided in
226 @ref{Configuration}.
227
228 @item Provide a menu interface
229 A menu interface listing preset boot commands, with a programmable
230 timeout, is available. There is no fixed limit on the number of boot
231 entries, and the current implementation has space for several hundred.
232
233 @item Have a flexible command-line interface
234 A fairly flexible command-line interface, accessible from the menu,
235 is available to edit any preset commands, or write a new boot command
236 set from scratch. If no configuration file is present, GRUB drops to
237 the command-line.
238
239 The list of commands (@pxref{Commands}) are a subset of those supported
240 for configuration files. Editing commands closely resembles the Bash
241 command-line (@pxref{Command Line Editing, Bash, Command Line Editing,
242 features, Bash Features}), with @key{TAB}-completion of commands,
243 devices, partitions, and files in a directory depending on context.
244
245 @item Support multiple filesystem types
246 Support multiple filesystem types transparently, plus a useful explicit
247 blocklist notation. The currently supported filesystem types are
248 @dfn{BSD FFS}, @dfn{DOS FAT16 and FAT32}, @dfn{Minix fs}, @dfn{Linux
249 ext2fs}, @dfn{ReiserFS}, @dfn{JFS}, @dfn{XFS}, and @dfn{VSTa
250 fs}. @xref{Filesystem}, for more information.
251
252 @item Support automatic decompression
253 Can decompress files which were compressed by @command{gzip}. This
254 function is both automatic and transparent to the user (i.e. all
255 functions operate upon the uncompressed contents of the specified
256 files). This greatly reduces a file size and loading time, a
257 particularly great benefit for floppies.@footnote{There are a few
258 pathological cases where loading a very badly organized ELF kernel might
259 take longer, but in practice this never happen.}
260
261 It is conceivable that some kernel modules should be loaded in a
262 compressed state, so a different module-loading command can be specified
263 to avoid uncompressing the modules.
264
265 @item Access data on any installed device
266 Support reading data from any or all floppies or hard disk(s) recognized
267 by the BIOS, independent of the setting of the root device.
268
269 @item Be independent of drive geometry translations
270 Unlike many other boot loaders, GRUB makes the particular drive
271 translation irrelevant. A drive installed and running with one
272 translation may be converted to another translation without any adverse
273 effects or changes in GRUB's configuration.
274
275 @item Detect all installed @sc{ram}
276 GRUB can generally find all the installed @sc{ram} on a PC-compatible
277 machine. It uses an advanced BIOS query technique for finding all
278 memory regions. As described on the Multiboot Specification (@pxref{Top,
279 Multiboot Specification, Motivation, multiboot, The Multiboot
280 Specification}), not all kernels make use of this information, but GRUB
281 provides it for those who do.
282
283 @item Support Logical Block Address mode
284 In traditional disk calls (called @dfn{CHS mode}), there is a geometry
285 translation problem, that is, the BIOS cannot access over 1024
286 cylinders, so the accessible space is limited to at least 508 MB and to
287 at most 8GB. GRUB can't universally solve this problem, as there is no
288 standard interface used in all machines. However, several newer machines
289 have the new interface, Logical Block Address (@dfn{LBA}) mode. GRUB
290 automatically detects if LBA mode is available and uses it if
291 available. In LBA mode, GRUB can access the entire disk.
292
293 @item Support network booting
294 GRUB is basically a disk-based boot loader but also has network
295 support. You can load OS images from a network by using the @dfn{TFTP}
296 protocol.
297
298 @item Support remote terminals
299 To support computers with no console, GRUB provides remote terminal
300 support, so that you can control GRUB from a remote host. Only serial
301 terminal support is implemented at the moment.
302 @end table
303
304
305 @node Role of a boot loader
306 @section The role of a boot loader
307
308 The following is a quotation from Gordon Matzigkeit, a GRUB fanatic:
309
310 @quotation
311 Some people like to acknowledge both the operating system and kernel when
312 they talk about their computers, so they might say they use
313 ``GNU/Linux'' or ``GNU/Hurd''. Other people seem to think that the
314 kernel is the most important part of the system, so they like to call
315 their GNU operating systems ``Linux systems.''
316
317 I, personally, believe that this is a grave injustice, because the
318 @emph{boot loader} is the most important software of all. I used to
319 refer to the above systems as either ``LILO''@footnote{The LInux LOader,
320 a boot loader that everybody uses, but nobody likes.} or ``GRUB''
321 systems.
322
323 Unfortunately, nobody ever understood what I was talking about; now I
324 just use the word ``GNU'' as a pseudonym for GRUB.
325
326 So, if you ever hear people talking about their alleged ``GNU'' systems,
327 remember that they are actually paying homage to the best boot loader
328 around@dots{} GRUB!
329 @end quotation
330
331 We, the GRUB maintainers, do not (usually) encourage Gordon's level of
332 fanaticism, but it helps to remember that boot loaders deserve
333 recognition. We hope that you enjoy using GNU GRUB as much as we did
334 writing it.
335
336
337 @node Naming convention
338 @chapter Naming convention
339
340 The device syntax used in GRUB is a wee bit different from what you may
341 have seen before in your operating system(s), and you need to know it so
342 that you can specify a drive/partition.
343
344 Look at the following examples and explanations:
345
346 @example
347 (fd0)
348 @end example
349
350 First of all, GRUB requires that the device name be enclosed with
351 @samp{(} and @samp{)}. The @samp{fd} part means that it is a floppy
352 disk. The number @samp{0} is the drive number, which is counted from
353 @emph{zero}. This expression means that GRUB will use the whole floppy
354 disk.
355
356 @example
357 (hd0,2)
358 @end example
359
360 Here, @samp{hd} means it is a hard disk drive. The first integer
361 @samp{0} indicates the drive number, that is, the first hard disk, while
362 the second integer, @samp{1}, indicates the partition number (or the
363 @sc{pc} slice number in the BSD terminology). The partition numbers are
364 counted from @emph{one}, not from zero (as was the case in previous
365 versions of GRUB). This expression means the second partition of the
366 first hard disk drive. In this case, GRUB uses one partition of the
367 disk, instead of the whole disk.
368
369 @example
370 (hd0,5)
371 @end example
372
373 This specifies the first @dfn{extended partition} of the first hard disk
374 drive. Note that the partition numbers for extended partitions are
375 counted from @samp{5}, regardless of the actual number of primary
376 partitions on your hard disk.
377
378 @example
379 (hd1,a)
380 @end example
381
382 This means the BSD @samp{a} partition of the second hard disk. If you
383 need to specify which @sc{pc} slice number should be used, use something
384 like this: @samp{(hd1,1,a)}. If the @sc{pc} slice number is omitted,
385 GRUB searches for the first @sc{pc} slice which has a BSD @samp{a}
386 partition.
387
388 Of course, to actually access the disks or partitions with GRUB, you
389 need to use the device specification in a command, like @samp{root
390 (fd0)} or @samp{unhide (hd0,3)}. To help you find out which number
391 specifies a partition you want, the GRUB command-line
392 (@pxref{Command-line interface}) options have argument
393 completion. This means that, for example, you only need to type
394
395 @example
396 root (
397 @end example
398
399 followed by a @key{TAB}, and GRUB will display the list of drives,
400 partitions, or file names. So it should be quite easy to determine the
401 name of your target partition, even with minimal knowledge of the
402 syntax.
403
404 Note that GRUB does @emph{not} distinguish IDE from SCSI - it simply
405 counts the drive numbers from zero, regardless of their type. Normally,
406 any IDE drive number is less than any SCSI drive number, although that
407 is not true if you change the boot sequence by swapping IDE and SCSI
408 drives in your BIOS.
409
410 Now the question is, how to specify a file? Again, consider an
411 example:
412
413 @example
414 (hd0,1)/vmlinuz
415 @end example
416
417 This specifies the file named @samp{vmlinuz}, found on the first
418 partition of the first hard disk drive. Note that the argument
419 completion works with file names, too.
420
421 That was easy, admit it. Now read the next chapter, to find out how to
422 actually install GRUB on your drive.
423
424
425 @node Installation
426 @chapter Installation
427
428 In order to install GRUB as your boot loader, you need to first
429 install the GRUB system and utilities under your UNIX-like operating
430 system (@pxref{Obtaining and Building GRUB}). You can do this either
431 from the source tarball, or as a package for your OS.
432
433 After you have done that, you need to install the boot loader on a
434 drive (floppy or hard disk). There are two ways of doing that - either
435 using the utility @command{grub-install} (@pxref{Invoking
436 grub-install}) on a UNIX-like OS, or by running GRUB itself from a
437 floppy. These are quite similar, however the utility might probe a
438 wrong BIOS drive, so you should be careful.
439
440 Also, if you install GRUB on a UNIX-like OS, please make sure that you
441 have an emergency boot disk ready, so that you can rescue your computer
442 if, by any chance, your hard drive becomes unusable (unbootable).
443
444 GRUB comes with boot images, which are normally put in the directory
445 @file{/usr/lib/grub/i386-pc}. Hereafter, the directory where GRUB images are
446 initially placed (normally @file{/usr/lib/grub/i386-pc}) will be
447 called the @dfn{image directory}, and the directory where the boot
448 loader needs to find them (usually @file{/boot/grub}) will be called
449 the @dfn{boot directory}.
450
451 @menu
452 * Installing GRUB using grub-install::
453 * Making a GRUB bootable CD-ROM::
454 @end menu
455
456
457 @node Installing GRUB using grub-install
458 @section Installing GRUB using grub-install
459
460 @strong{Caution:} This procedure is definitely less safe, because
461 there are several ways in which your computer can become
462 unbootable. For example, most operating systems don't tell GRUB how to
463 map BIOS drives to OS devices correctly---GRUB merely @dfn{guesses}
464 the mapping. This will succeed in most cases, but not
465 always. Therefore, GRUB provides you with a map file called the
466 @dfn{device map}, which you must fix if it is wrong. @xref{Device
467 map}, for more details.
468
469 If you still do want to install GRUB under a UNIX-like OS (such
470 as @sc{gnu}), invoke the program @command{grub-install} (@pxref{Invoking
471 grub-install}) as the superuser (@dfn{root}).
472
473 The usage is basically very simple. You only need to specify one
474 argument to the program, namely, where to install the boot loader. The
475 argument can be either a device file (like @samp{/dev/hda}) or a
476 partition specified in GRUB's notation. For example, under Linux the
477 following will install GRUB into the MBR of the first IDE disk:
478
479 @example
480 # @kbd{grub-install /dev/hda}
481 @end example
482
483 Likewise, under GNU/Hurd, this has the same effect:
484
485 @example
486 # @kbd{grub-install /dev/hd0}
487 @end example
488
489 If it is the first BIOS drive, this is the same as well:
490
491 @example
492 # @kbd{grub-install '(hd0)'}
493 @end example
494
495 Or you can omit the parentheses:
496
497 @example
498 # @kbd{grub-install hd0}
499 @end example
500
501 But all the above examples assume that GRUB should use images under
502 the root directory. If you want GRUB to use images under a directory
503 other than the root directory, you need to specify the option
504 @option{--root-directory}. The typical usage is that you create a GRUB
505 boot floppy with a filesystem. Here is an example:
506
507 @example
508 @group
509 # @kbd{mke2fs /dev/fd0}
510 # @kbd{mount -t ext2 /dev/fd0 /mnt}
511 # @kbd{grub-install --root-directory=/mnt fd0}
512 # @kbd{umount /mnt}
513 @end group
514 @end example
515
516 Another example is when you have a separate boot partition
517 which is mounted at @file{/boot}. Since GRUB is a boot loader, it
518 doesn't know anything about mountpoints at all. Thus, you need to run
519 @command{grub-install} like this:
520
521 @example
522 # @kbd{grub-install --root-directory=/boot /dev/hda}
523 @end example
524
525 By the way, as noted above, it is quite difficult to guess BIOS drives
526 correctly under a UNIX-like OS. Thus, @command{grub-install} will prompt
527 you to check if it could really guess the correct mappings, after the
528 installation. The format is defined in @ref{Device map}. Please be
529 quite careful. If the output is wrong, it is unlikely that your
530 computer will be able to boot with no problem.
531
532 Note that @command{grub-install} is actually just a shell script and the
533 real task is done by @command{grub-mkimage} and @command{grub-setup}.
534 Therefore, you may run those commands directly to install GRUB, without
535 using @command{grub-install}. Don't do that, however, unless you are very
536 familiar with the internals of GRUB. Installing a boot loader on a running
537 OS may be extremely dangerous.
538
539
540 @node Making a GRUB bootable CD-ROM
541 @section Making a GRUB bootable CD-ROM
542
543 GRUB supports the @dfn{no emulation mode} in the El Torito
544 specification@footnote{El Torito is a specification for bootable CD
545 using BIOS functions.}. This means that you can use the whole CD-ROM
546 from GRUB and you don't have to make a floppy or hard disk image file,
547 which can cause compatibility problems.
548
549 For booting from a CD-ROM, GRUB uses a special Stage 2 called
550 @file{stage2_eltorito}. The only GRUB files you need to have in your
551 bootable CD-ROM are this @file{stage2_eltorito} and optionally a config file
552 @file{grub.cfg}. You don't need to use @file{stage1} or @file{stage2},
553 because El Torito is quite different from the standard boot process.
554
555 Here is an example of procedures to make a bootable CD-ROM
556 image. First, make a top directory for the bootable image, say,
557 @samp{iso}:
558
559 @example
560 $ @kbd{mkdir iso}
561 @end example
562
563 Make a directory for GRUB:
564
565 @example
566 $ @kbd{mkdir -p iso/boot/grub}
567 @end example
568
569 Copy the file @file{stage2_eltorito}:
570
571 @example
572 $ @kbd{cp /usr/lib/grub/i386-pc/stage2_eltorito iso/boot/grub}
573 @end example
574
575 If desired, make the config file @file{grub.cfg} under @file{iso/boot/grub}
576 (@pxref{Configuration}), and copy any files and directories for the disc to the
577 directory @file{iso/}.
578
579 Finally, make a ISO9660 image file like this:
580
581 @example
582 $ @kbd{mkisofs -R -b boot/grub/stage2_eltorito -no-emul-boot \
583 -boot-load-size 4 -boot-info-table -o grub.iso iso}
584 @end example
585
586 This produces a file named @file{grub.iso}, which then can be burned
587 into a CD (or a DVD). @kbd{mkisofs} has already set up the disc to boot
588 from the @kbd{boot/grub/stage2_eltorito} file, so there is no need to
589 setup GRUB on the disc. (Note that the @kbd{-boot-load-size 4} bit is
590 required for compatibility with the BIOS on many older machines.)
591
592 You can use the device @samp{(cd)} to access a CD-ROM in your
593 config file. This is not required; GRUB automatically sets the root device
594 to @samp{(cd)} when booted from a CD-ROM. It is only necessary to refer to
595 @samp{(cd)} if you want to access other drives as well.
596
597
598 @node Booting
599 @chapter Booting
600
601 GRUB can load Multiboot-compliant kernels in a consistent way,
602 but for some free operating systems you need to use some OS-specific
603 magic.
604
605 @menu
606 * General boot methods:: How to boot OSes with GRUB generally
607 * OS-specific notes:: Notes on some operating systems
608 @end menu
609
610
611 @node General boot methods
612 @section How to boot operating systems
613
614 GRUB has two distinct boot methods. One of the two is to load an
615 operating system directly, and the other is to chain-load another boot
616 loader which then will load an operating system actually. Generally
617 speaking, the former is more desirable, because you don't need to
618 install or maintain other boot loaders and GRUB is flexible enough to
619 load an operating system from an arbitrary disk/partition. However,
620 the latter is sometimes required, since GRUB doesn't support all the
621 existing operating systems natively.
622
623 @menu
624 * Loading an operating system directly::
625 * Chain-loading::
626 @end menu
627
628
629 @node Loading an operating system directly
630 @subsection How to boot an OS directly with GRUB
631
632 Multiboot (@pxref{Top, Multiboot Specification, Motivation, multiboot,
633 The Multiboot Specification}) is the native format supported by GRUB.
634 For the sake of convenience, there is also support for Linux, FreeBSD,
635 NetBSD and OpenBSD. If you want to boot other operating systems, you
636 will have to chain-load them (@pxref{Chain-loading}).
637
638 FIXME: this section is incomplete.
639
640 @enumerate
641 @item
642 Run the command @command{boot} (@pxref{boot}).
643 @end enumerate
644
645 However, DOS and Windows have some deficiencies, so you might have to
646 use more complicated instructions. @xref{DOS/Windows}, for more
647 information.
648
649
650 @node Chain-loading
651 @subsection Chain-loading an OS
652
653 Operating systems that do not support Multiboot and do not have specific
654 support in GRUB (specific support is available for Linux, FreeBSD, NetBSD
655 and OpenBSD) must be chain-loaded, which involves loading another boot
656 loader and jumping to it in real mode.
657
658 The @command{chainloader} command (@pxref{chainloader}) is used to set this
659 up. It is normally also necessary to load some GRUB modules and set the
660 appropriate root device. Putting this together, we get something like this,
661 for a Windows system on the first partition of the first hard disk:
662
663 @verbatim
664 menuentry "Windows" {
665 insmod chain
666 insmod ntfs
667 set root=(hd0,1)
668 chainloader +1
669 }
670 @end verbatim
671 @c FIXME: document UUIDs.
672
673 On systems with multiple hard disks, an additional workaround may be
674 required. @xref{DOS/Windows}.
675
676 Chain-loading is only supported on PC BIOS and EFI platforms.
677
678
679 @node OS-specific notes
680 @section Some caveats on OS-specific issues
681
682 Here, we describe some caveats on several operating systems.
683
684 @menu
685 * GNU/Hurd::
686 * GNU/Linux::
687 * DOS/Windows::
688 @end menu
689
690
691 @node GNU/Hurd
692 @subsection GNU/Hurd
693
694 Since GNU/Hurd is Multiboot-compliant, it is easy to boot it; there is
695 nothing special about it. But do not forget that you have to specify a
696 root partition to the kernel.
697
698 FIXME: this section is incomplete.
699
700 @enumerate
701 @item
702 Run the command @command{boot} (@pxref{boot}).
703 @end enumerate
704
705
706 @node GNU/Linux
707 @subsection GNU/Linux
708
709 It is relatively easy to boot GNU/Linux from GRUB, because it somewhat
710 resembles to boot a Multiboot-compliant OS.
711
712 FIXME: this section is incomplete.
713
714 @enumerate
715 @item
716 Set GRUB's root device to the same drive as GNU/Linux's.
717
718 @item
719 Finally, run the command @command{boot} (@pxref{boot}).
720 @end enumerate
721
722 @strong{Caution:} If you use an initrd and specify the @samp{mem=}
723 option to the kernel to let it use less than actual memory size, you
724 will also have to specify the same memory size to GRUB. To let GRUB know
725 the size, run the command @command{uppermem} @emph{before} loading the
726 kernel. @xref{uppermem}, for more information.
727
728
729 @node DOS/Windows
730 @subsection DOS/Windows
731
732 GRUB cannot boot DOS or Windows directly, so you must chain-load them
733 (@pxref{Chain-loading}). However, their boot loaders have some critical
734 deficiencies, so it may not work to just chain-load them. To overcome
735 the problems, GRUB provides you with two helper functions.
736
737 If you have installed DOS (or Windows) on a non-first hard disk, you
738 have to use the disk swapping technique, because that OS cannot boot
739 from any disks but the first one. The workaround used in GRUB is the
740 command @command{drivemap} (@pxref{drivemap}), like this:
741
742 @example
743 drivemap -s (hd0) (hd1)
744 @end example
745
746 This performs a @dfn{virtual} swap between your first and second hard
747 drive.
748
749 @strong{Caution:} This is effective only if DOS (or Windows) uses BIOS
750 to access the swapped disks. If that OS uses a special driver for the
751 disks, this probably won't work.
752
753 Another problem arises if you installed more than one set of DOS/Windows
754 onto one disk, because they could be confused if there are more than one
755 primary partitions for DOS/Windows. Certainly you should avoid doing
756 this, but there is a solution if you do want to do so. Use the partition
757 hiding/unhiding technique.
758
759 If GRUB @dfn{hides} a DOS (or Windows) partition (@pxref{parttool}), DOS (or
760 Windows) will ignore the partition. If GRUB @dfn{unhides} a DOS (or Windows)
761 partition, DOS (or Windows) will detect the partition. Thus, if you have
762 installed DOS (or Windows) on the first and the second partition of the
763 first hard disk, and you want to boot the copy on the first partition, do
764 the following:
765
766 @example
767 @group
768 parttool (hd0,1) hidden-
769 parttool (hd0,2) hidden+
770 set root=(hd0,1)
771 chainloader +1
772 parttool @verb{'${root}'} boot+
773 boot
774 @end group
775 @end example
776
777
778 @node Configuration
779 @chapter Writing your own configuration file
780
781 GRUB is configured using @file{grub.cfg}, usually located under
782 @file{/boot/grub}. This file is quite flexible, but most users will not
783 need to write the whole thing by hand.
784
785 @menu
786 * Simple configuration:: Recommended for most users
787 * Shell-like scripting:: For power users and developers
788 @end menu
789
790
791 @node Simple configuration
792 @section Simple configuration handling
793
794 The program @command{grub-mkconfig} (@pxref{Invoking grub-mkconfig})
795 generates @file{grub.cfg} files suitable for most cases. It is suitable for
796 use when upgrading a distribution, and will discover available kernels and
797 attempt to generate menu entries for them.
798
799 The file @file{/etc/default/grub} controls the operation of
800 @command{grub-mkconfig}. It is sourced by a shell script, and so must be
801 valid POSIX shell input; normally, it will just be a sequence of
802 @samp{KEY=value} lines, but if the value contains spaces or other special
803 characters then it must be quoted. For example:
804
805 @example
806 GRUB_TERMINAL_INPUT="console serial"
807 @end example
808
809 Valid keys in @file{/etc/default/grub} are as follows:
810
811 @table @samp
812 @item GRUB_DEFAULT
813 The default menu entry. This may be a number, in which case it identifies
814 the Nth entry in the generated menu counted from zero, or the full name of a
815 menu entry, or the special string @samp{saved}. Using the full name may be
816 useful if you want to set a menu entry as the default even though there may
817 be a variable number of entries before it.
818
819 If you set this to @samp{saved}, then the default menu entry will be that
820 saved by @samp{GRUB_SAVEDEFAULT}, @command{grub-set-default}, or
821 @command{grub-reboot}.
822
823 The default is @samp{0}.
824
825 @item GRUB_SAVEDEFAULT
826 If this option is set to @samp{true}, then, when an entry is selected, save
827 it as a new default entry for use by future runs of GRUB. This is only
828 useful if @samp{GRUB_DEFAULT=saved}; it is a separate option because
829 @samp{GRUB_DEFAULT=saved} is useful without this option, in conjunction with
830 @command{grub-set-default} or @command{grub-reboot}. Unset by default.
831
832 @item GRUB_TIMEOUT
833 Boot the default entry this many seconds after the menu is displayed, unless
834 a key is pressed. The default is @samp{5}. Set to @samp{0} to boot
835 immediately without displaying the menu, or to @samp{-1} to wait
836 indefinitely.
837
838 @item GRUB_HIDDEN_TIMEOUT
839 Wait this many seconds for a key to be pressed before displaying the menu.
840 If no key is pressed during that time, boot immediately. Unset by default.
841
842 @item GRUB_HIDDEN_TIMEOUT_QUIET
843 In conjunction with @samp{GRUB_HIDDEN_TIMEOUT}, set this to @samp{true} to
844 suppress the verbose countdown while waiting for a key to be pressed before
845 displaying the menu. Unset by default.
846
847 @item GRUB_DEFAULT_BUTTON
848 @itemx GRUB_TIMEOUT_BUTTON
849 @itemx GRUB_HIDDEN_TIMEOUT_BUTTON
850 @itemx GRUB_BUTTON_CMOS_ADDRESS
851 Variants of the corresponding variables without the @samp{_BUTTON} suffix,
852 used to support vendor-specific power buttons. @xref{Vendor power-on keys}.
853
854 @item GRUB_DISTRIBUTOR
855 Set by distributors of GRUB to their identifying name. This is used to
856 generate more informative menu entry titles.
857
858 @item GRUB_TERMINAL_INPUT
859 Select the terminal input device. You may select multiple devices here,
860 separated by spaces.
861
862 Valid terminal input names depend on the platform, but may include
863 @samp{console} (PC BIOS and EFI consoles), @samp{serial} (serial terminal),
864 @samp{ofconsole} (Open Firmware console), @samp{at_keyboard} (PC AT
865 keyboard, mainly useful with Coreboot), or @samp{usb_keyboard} (USB keyboard
866 using the HID Boot Protocol, for cases where the firmware does not handle
867 this).
868
869 The default is to use the platform's native terminal input.
870
871 @item GRUB_TERMINAL_OUTPUT
872 Select the terminal output device. You may select multiple devices here,
873 separated by spaces.
874
875 Valid terminal output names depend on the platform, but may include
876 @samp{console} (PC BIOS and EFI consoles), @samp{serial} (serial terminal),
877 @samp{gfxterm} (graphics-mode output), @samp{ofconsole} (Open Firmware
878 console), or @samp{vga_text} (VGA text output, mainly useful with Coreboot).
879
880 The default is to use the platform's native terminal output.
881
882 @item GRUB_TERMINAL
883 If this option is set, it overrides both @samp{GRUB_TERMINAL_INPUT} and
884 @samp{GRUB_TERMINAL_OUTPUT} to the same value.
885
886 @item GRUB_SERIAL_COMMAND
887 A command to configure the serial port when using the serial console.
888 @xref{serial}. Defaults to @samp{serial}.
889
890 @item GRUB_CMDLINE_LINUX
891 Command-line arguments to add to menu entries for the Linux kernel.
892
893 @item GRUB_CMDLINE_LINUX_DEFAULT
894 Unless @samp{GRUB_DISABLE_LINUX_RECOVERY} is set, two menu entries will be
895 generated for each Linux kernel: one default entry and one entry for
896 recovery mode. This option lists command-line arguments to add only to the
897 default menu entry, after those listed in @samp{GRUB_CMDLINE_LINUX}.
898
899 @item GRUB_CMDLINE_NETBSD
900 @itemx GRUB_CMDLINE_NETBSD_DEFAULT
901 As @samp{GRUB_CMDLINE_LINUX} and @samp{GRUB_CMDLINE_LINUX_DEFAULT}, but for
902 NetBSD.
903
904 @item GRUB_DISABLE_LINUX_UUID
905 Normally, @command{grub-mkconfig} will generate menu entries that use
906 universally-unique identifiers (UUIDs) to identify the root filesystem to
907 the Linux kernel, using a @samp{root=UUID=...} kernel parameter. This is
908 usually more reliable, but in some cases it may not be appropriate. To
909 disable the use of UUIDs, set this option to @samp{true}.
910
911 @item GRUB_DISABLE_LINUX_RECOVERY
912 Disable the generation of recovery mode menu entries for Linux.
913
914 @item GRUB_DISABLE_NETBSD_RECOVERY
915 Disable the generation of recovery mode menu entries for NetBSD.
916
917 @item GRUB_GFXMODE
918 Set the resolution used on the @samp{gfxterm} graphical terminal. Note that
919 you can only use modes which your graphics card supports via VESA BIOS
920 Extensions (VBE), so for example native LCD panel resolutions may not be
921 available. The default is @samp{640x480}.
922
923 @item GRUB_BACKGROUND
924 Set a background image for use with the @samp{gfxterm} graphical terminal.
925 The value of this option must be a file readable by GRUB at boot time, and
926 it must end with @file{.png}, @file{.tga}, @file{.jpg}, or @file{.jpeg}.
927 The image will be scaled if necessary to fit the screen.
928
929 @item GRUB_THEME
930 Set a theme for use with the @samp{gfxterm} graphical terminal.
931 @xref{Themes}.
932
933 @item GRUB_GFXPAYLOAD_LINUX
934 Set to @samp{text} to force the Linux kernel to boot in normal text mode,
935 @samp{keep} to preserve the graphics mode set using @samp{GRUB_GFXMODE},
936 @samp{@var{width}x@var{height}}[@samp{x@var{depth}}] to set a particular
937 graphics mode, or a sequence of these separated by commas or semicolons to
938 try several modes in sequence.
939
940 Depending on your kernel, your distribution, your graphics card, and the
941 phase of the moon, note that using this option may cause GNU/Linux to suffer
942 from various display problems, particularly during the early part of the
943 boot sequence. If you have problems, simply unset this option and GRUB will
944 tell Linux to boot in normal text mode.
945
946 @item GRUB_DISABLE_OS_PROBER
947 Normally, @command{grub-mkconfig} will try to use the external
948 @command{os-prober} program, if installed, to discover other operating
949 systems installed on the same system and generate appropriate menu entries
950 for them. Set this option to @samp{true} to disable this.
951
952 @item GRUB_INIT_TUNE
953 Play a tune on the speaker when GRUB starts. This is particularly useful
954 for users unable to see the screen. The value of this option is passed
955 directly to @ref{play}.
956 @end table
957
958 For more detailed customisation of @command{grub-mkconfig}'s output, you may
959 edit the scripts in @file{/etc/grub.d} directly.
960 @file{/etc/grub.d/40_custom} is particularly useful for adding entire custom
961 menu entries; simply type the menu entries you want to add at the end of
962 that file, making sure to leave at least the first two lines intact.
963
964
965 @node Shell-like scripting
966 @section Writing full configuration files directly
967
968
969 @node Serial terminal
970 @chapter Using GRUB via a serial line
971
972 This chapter describes how to use the serial terminal support in GRUB.
973
974 If you have many computers or computers with no display/keyboard, it
975 could be very useful to control the computers through serial
976 communications. To connect one computer with another via a serial line,
977 you need to prepare a null-modem (cross) serial cable, and you may need
978 to have multiport serial boards, if your computer doesn't have extra
979 serial ports. In addition, a terminal emulator is also required, such as
980 minicom. Refer to a manual of your operating system, for more
981 information.
982
983 As for GRUB, the instruction to set up a serial terminal is quite
984 simple. First of all, make sure that you haven't specified the option
985 @option{--disable-serial} to the configure script when you built your
986 GRUB images. If you get them in binary form, probably they have serial
987 terminal support already.
988
989 Then, initialize your serial terminal after GRUB starts up. Here is an
990 example:
991
992 @example
993 @group
994 grub> @kbd{serial --unit=0 --speed=9600}
995 grub> @kbd{terminal serial}
996 @end group
997 @end example
998
999 The command @command{serial} initializes the serial unit 0 with the
1000 speed 9600bps. The serial unit 0 is usually called @samp{COM1}, so, if
1001 you want to use COM2, you must specify @samp{--unit=1} instead. This
1002 command accepts many other options, so please refer to @ref{serial},
1003 for more details.
1004
1005 The command @command{terminal} (@pxref{terminal}) chooses which type of
1006 terminal you want to use. In the case above, the terminal will be a
1007 serial terminal, but you can also pass @code{console} to the command,
1008 as @samp{terminal serial console}. In this case, a terminal in which
1009 you press any key will be selected as a GRUB terminal.
1010
1011 However, note that GRUB assumes that your terminal emulator is
1012 compatible with VT100 by default. This is true for most terminal
1013 emulators nowadays, but you should pass the option @option{--dumb} to
1014 the command if your terminal emulator is not VT100-compatible or
1015 implements few VT100 escape sequences. If you specify this option then
1016 GRUB provides you with an alternative menu interface, because the normal
1017 menu requires several fancy features of your terminal.
1018
1019 @node Vendor power-on keys
1020 @chapter Using GRUB with vendor power-on keys
1021 Some laptop vendor provide an additional power-on button which boots another OS.
1022 GRUB supports such buttons with GRUB_TIMEOUT_BUTTON, GRUB_DEFAULT_BUTTON,
1023 GRUB_HIDDEN_TIMEOUT_BUTTON and GRUB_BUTTON_CMOS_ADDRESS variables in
1024 default/grub. GRUB_TIMEOUT_BUTTON, GRUB_DEFAULT_BUTTON and
1025 GRUB_HIDDEN_TIMEOUT_BUTTON are used instead of corresponding variables without
1026 _BUTTON suffix when powered using special button.
1027 GRUB_BUTTON_CMOS_ADDRESS is vendor specific and partially model-specific.
1028 Values known to GRUB team are:
1029
1030 @table @key
1031 @item Dell XPS M1530
1032 85:3
1033 @end table
1034
1035 To take full advantage of this function install GRUB into MBR.
1036
1037 @node Filesystem
1038 @chapter Filesystem syntax and semantics
1039
1040 GRUB uses a special syntax for specifying disk drives which can be
1041 accessed by BIOS. Because of BIOS limitations, GRUB cannot distinguish
1042 between IDE, ESDI, SCSI, or others. You must know yourself which BIOS
1043 device is equivalent to which OS device. Normally, that will be clear if
1044 you see the files in a device or use the command @command{find}
1045 (@pxref{find}).
1046
1047 @menu
1048 * Device syntax:: How to specify devices
1049 * File name syntax:: How to specify files
1050 * Block list syntax:: How to specify block lists
1051 @end menu
1052
1053
1054 @node Device syntax
1055 @section How to specify devices
1056
1057 The device syntax is like this:
1058
1059 @example
1060 @code{(@var{device}[,@var{part-num}][,@var{bsd-subpart-letter}])}
1061 @end example
1062
1063 @samp{[]} means the parameter is optional. @var{device} should be
1064 either @samp{fd} or @samp{hd} followed by a digit, like @samp{fd0}.
1065 But you can also set @var{device} to a hexadecimal or a decimal number
1066 which is a BIOS drive number, so the following are equivalent:
1067
1068 @example
1069 (hd0)
1070 (0x80)
1071 (128)
1072 @end example
1073
1074 @var{part-num} represents the partition number of @var{device}, starting
1075 from one for primary partitions and from five for extended partitions,
1076 and @var{bsd-subpart-letter} represents the BSD disklabel subpartition,
1077 such as @samp{a} or @samp{e}.
1078
1079 A shortcut for specifying BSD subpartitions is
1080 @code{(@var{device},@var{bsd-subpart-letter})}, in this case, GRUB
1081 searches for the first PC partition containing a BSD disklabel, then
1082 finds the subpartition @var{bsd-subpart-letter}. Here is an example:
1083
1084 @example
1085 (hd0,a)
1086 @end example
1087
1088 The syntax @samp{(hd0)} represents using the entire disk (or the
1089 MBR when installing GRUB), while the syntax @samp{(hd0,1)}
1090 represents using the first partition of the disk (or the boot sector
1091 of the partition when installing GRUB).
1092
1093 If you enabled the network support, the special drive, @samp{(nd)}, is
1094 also available. Before using the network drive, you must initialize the
1095 network. @xref{Network}, for more information.
1096
1097 If you boot GRUB from a CD-ROM, @samp{(cd)} is available. @xref{Making
1098 a GRUB bootable CD-ROM}, for details.
1099
1100
1101 @node File name syntax
1102 @section How to specify files
1103
1104 There are two ways to specify files, by @dfn{absolute file name} and by
1105 @dfn{block list}.
1106
1107 An absolute file name resembles a Unix absolute file name, using
1108 @samp{/} for the directory separator (not @samp{\} as in DOS). One
1109 example is @samp{(hd0,1)/boot/grub/grub.cfg}. This means the file
1110 @file{/boot/grub/grub.cfg} in the first partition of the first hard
1111 disk. If you omit the device name in an absolute file name, GRUB uses
1112 GRUB's @dfn{root device} implicitly. So if you set the root device to,
1113 say, @samp{(hd1,1)} by the command @command{root} (@pxref{root}), then
1114 @code{/boot/kernel} is the same as @code{(hd1,1)/boot/kernel}.
1115
1116
1117 @node Block list syntax
1118 @section How to specify block lists
1119
1120 A block list is used for specifying a file that doesn't appear in the
1121 filesystem, like a chainloader. The syntax is
1122 @code{[@var{offset}]+@var{length}[,[@var{offset}]+@var{length}]@dots{}}.
1123 Here is an example:
1124
1125 @example
1126 @code{0+100,200+1,300+300}
1127 @end example
1128
1129 This represents that GRUB should read blocks 0 through 99, block 200,
1130 and blocks 300 through 599. If you omit an offset, then GRUB assumes
1131 the offset is zero.
1132
1133 Like the file name syntax (@pxref{File name syntax}), if a blocklist
1134 does not contain a device name, then GRUB uses GRUB's @dfn{root
1135 device}. So @code{(hd0,2)+1} is the same as @code{+1} when the root
1136 device is @samp{(hd0,2)}.
1137
1138
1139 @node Interface
1140 @chapter GRUB's user interface
1141
1142 GRUB has both a simple menu interface for choosing preset entries from a
1143 configuration file, and a highly flexible command-line for performing
1144 any desired combination of boot commands.
1145
1146 GRUB looks for its configuration file as soon as it is loaded. If one
1147 is found, then the full menu interface is activated using whatever
1148 entries were found in the file. If you choose the @dfn{command-line} menu
1149 option, or if the configuration file was not found, then GRUB drops to
1150 the command-line interface.
1151
1152 @menu
1153 * Command-line interface:: The flexible command-line interface
1154 * Menu interface:: The simple menu interface
1155 * Menu entry editor:: Editing a menu entry
1156 @end menu
1157
1158
1159 @node Command-line interface
1160 @section The flexible command-line interface
1161
1162 The command-line interface provides a prompt and after it an editable
1163 text area much like a command-line in Unix or DOS. Each command is
1164 immediately executed after it is entered@footnote{However, this
1165 behavior will be changed in the future version, in a user-invisible
1166 way.}. The commands (@pxref{Command-line and menu entry commands}) are a
1167 subset of those available in the configuration file, used with exactly
1168 the same syntax.
1169
1170 Cursor movement and editing of the text on the line can be done via a
1171 subset of the functions available in the Bash shell:
1172
1173 @table @key
1174 @item C-f
1175 @itemx PC right key
1176 Move forward one character.
1177
1178 @item C-b
1179 @itemx PC left key
1180 Move back one character.
1181
1182 @item C-a
1183 @itemx HOME
1184 Move to the start of the line.
1185
1186 @item C-e
1187 @itemx END
1188 Move the the end of the line.
1189
1190 @item C-d
1191 @itemx DEL
1192 Delete the character underneath the cursor.
1193
1194 @item C-h
1195 @itemx BS
1196 Delete the character to the left of the cursor.
1197
1198 @item C-k
1199 Kill the text from the current cursor position to the end of the line.
1200
1201 @item C-u
1202 Kill backward from the cursor to the beginning of the line.
1203
1204 @item C-y
1205 Yank the killed text back into the buffer at the cursor.
1206
1207 @item C-p
1208 @itemx PC up key
1209 Move up through the history list.
1210
1211 @item C-n
1212 @itemx PC down key
1213 Move down through the history list.
1214 @end table
1215
1216 When typing commands interactively, if the cursor is within or before
1217 the first word in the command-line, pressing the @key{TAB} key (or
1218 @key{C-i}) will display a listing of the available commands, and if the
1219 cursor is after the first word, the @kbd{@key{TAB}} will provide a
1220 completion listing of disks, partitions, and file names depending on the
1221 context. Note that to obtain a list of drives, one must open a
1222 parenthesis, as @command{root (}.
1223
1224 Note that you cannot use the completion functionality in the TFTP
1225 filesystem. This is because TFTP doesn't support file name listing for
1226 the security.
1227
1228
1229 @node Menu interface
1230 @section The simple menu interface
1231
1232 The menu interface is quite easy to use. Its commands are both
1233 reasonably intuitive and described on screen.
1234
1235 Basically, the menu interface provides a list of @dfn{boot entries} to
1236 the user to choose from. Use the arrow keys to select the entry of
1237 choice, then press @key{RET} to run it. An optional timeout is
1238 available to boot the default entry (the first one if not set), which is
1239 aborted by pressing any key.
1240
1241 Commands are available to enter a bare command-line by pressing @key{c}
1242 (which operates exactly like the non-config-file version of GRUB, but
1243 allows one to return to the menu if desired by pressing @key{ESC}) or to
1244 edit any of the @dfn{boot entries} by pressing @key{e}.
1245
1246 If you protect the menu interface with a password (@pxref{Security}),
1247 all you can do is choose an entry by pressing @key{RET}, or press
1248 @key{p} to enter the password.
1249
1250
1251 @node Menu entry editor
1252 @section Editing a menu entry
1253
1254 The menu entry editor looks much like the main menu interface, but the
1255 lines in the menu are individual commands in the selected entry instead
1256 of entry names.
1257
1258 If an @key{ESC} is pressed in the editor, it aborts all the changes made
1259 to the configuration entry and returns to the main menu interface.
1260
1261 When a particular line is selected, the editor places the user in a
1262 special version of the GRUB command-line to edit that line. When the
1263 user hits @key{RET}, GRUB replaces the line in question in the boot
1264 entry with the changes (unless it was aborted via @key{ESC},
1265 in which case the changes are thrown away).
1266
1267 If you want to add a new line to the menu entry, press @key{o} if adding
1268 a line after the current line or press @key{O} if before the current
1269 line.
1270
1271 To delete a line, hit the key @key{d}. Although GRUB unfortunately
1272 does not support @dfn{undo}, you can do almost the same thing by just
1273 returning to the main menu.
1274
1275
1276 @node Commands
1277 @chapter The list of available commands
1278
1279 In this chapter, we list all commands that are available in GRUB.
1280
1281 Commands belong to different groups. A few can only be used in
1282 the global section of the configuration file (or ``menu''); most
1283 of them can be entered on the command-line and can be used either
1284 anywhere in the menu or specifically in the menu entries.
1285
1286 @menu
1287 * Menu-specific commands::
1288 * General commands::
1289 * Command-line and menu entry commands::
1290 @end menu
1291
1292
1293 @node Menu-specific commands
1294 @section The list of commands for the menu only
1295
1296 The semantics used in parsing the configuration file are the following:
1297
1298 @itemize @bullet
1299 @item
1300 The menu-specific commands have to be used before any others.
1301
1302 @item
1303 The files @emph{must} be in plain-text format.
1304
1305 @item
1306 @samp{#} at the beginning of a line in a configuration file means it is
1307 only a comment.
1308
1309 @item
1310 Options are separated by spaces.
1311
1312 @item
1313 All numbers can be either decimal or hexadecimal. A hexadecimal number
1314 must be preceded by @samp{0x}, and is case-insensitive.
1315
1316 @item
1317 Extra options or text at the end of the line are ignored unless otherwise
1318 specified.
1319
1320 @item
1321 Unrecognized commands are added to the current entry, except before entries
1322 start, where they are ignored.
1323 @end itemize
1324
1325 These commands can only be used in the menu:
1326
1327 @menu
1328 * menuentry:: Start a menu entry
1329 @end menu
1330
1331
1332 @node menuentry
1333 @subsection menuentry
1334
1335 @deffn Command title name @dots{}
1336 Start a new boot entry, and set its name to the contents of the rest of
1337 the line, starting with the first non-space character.
1338 @end deffn
1339
1340
1341 @node General commands
1342 @section The list of general commands
1343
1344 Commands usable anywhere in the menu and in the command-line.
1345
1346 @menu
1347 * serial:: Set up a serial device
1348 * terminfo:: Define terminal type
1349 @end menu
1350
1351
1352 @node serial
1353 @subsection serial
1354
1355 @deffn Command serial [@option{--unit=unit}] [@option{--port=port}] [@option{--speed=speed}] [@option{--word=word}] [@option{--parity=parity}] [@option{--stop=stop}]
1356 Initialize a serial device. @var{unit} is a number in the range 0-3
1357 specifying which serial port to use; default is 0, which corresponds to
1358 the port often called COM1. @var{port} is the I/O port where the UART
1359 is to be found; if specified it takes precedence over @var{unit}.
1360 @var{speed} is the transmission speed; default is 9600. @var{word} and
1361 @var{stop} are the number of data bits and stop bits. Data bits must
1362 be in the range 5-8 and stop bits must be 1 or 2. Default is 8 data
1363 bits and one stop bit. @var{parity} is one of @samp{no}, @samp{odd},
1364 @samp{even} and defaults to @samp{no}.
1365
1366 The serial port is not used as a communication channel unless the
1367 @command{terminal} command is used (@pxref{terminal}).
1368
1369 This command is only available if GRUB is compiled with serial
1370 support. See also @ref{Serial terminal}.
1371 @end deffn
1372
1373
1374 @node terminfo
1375 @subsection terminfo
1376
1377 @deffn Command terminfo [term]
1378 Define the capabilities of your terminal by giving the name of an entry in
1379 the terminfo database, which should correspond roughly to a @samp{TERM}
1380 environment variable in Unix.
1381
1382 At the moment, only @samp{vt100} is supported in GRUB 2. If you need other
1383 terminal types, please contact us to discuss the best way to include support
1384 for these in GRUB.
1385
1386 If no option is specified, the current terminal type is printed.
1387 @end deffn
1388
1389
1390 @node Command-line and menu entry commands
1391 @section The list of command-line and menu entry commands
1392
1393 These commands are usable in the command-line and in menu entries. If
1394 you forget a command, you can run the command @command{help}
1395 (@pxref{help}).
1396
1397 @menu
1398 * acpi:: Load ACPI tables
1399 * blocklist:: Print a block list
1400 * boot:: Start up your operating system
1401 * cat:: Show the contents of a file
1402 * chainloader:: Chain-load another boot loader
1403 * cmp:: Compare two files
1404 * configfile:: Load a configuration file
1405 * crc:: Calculate CRC32 checksums
1406 * date:: Display or set current date and time
1407 * drivemap:: Map a drive to another
1408 * echo:: Display a line of text
1409 * export:: Export an environment variable
1410 * gettext:: Translate a string
1411 * gptsync:: Fill an MBR based on GPT entries
1412 * halt:: Shut down your computer
1413 * help:: Show help messages
1414 * insmod:: Insert a module
1415 * keystatus:: Check key modifier status
1416 * ls:: List devices or files
1417 * parttool:: Modify partition table entries
1418 * play:: Play a tune
1419 * reboot:: Reboot your computer
1420 * set:: Set an environment variable
1421 * unset:: Unset an environment variable
1422 @end menu
1423
1424
1425 @node acpi
1426 @subsection acpi
1427
1428 @deffn Command acpi [@option{-1}|@option{-2}] @
1429 [@option{--exclude=table1,@dots{}}|@option{--load-only=table1,@dots{}}] @
1430 [@option{--oemid=id}] [@option{--oemtable=table}] @
1431 [@option{--oemtablerev=rev}] [@option{--oemtablecreator=creator}] @
1432 [@option{--oemtablecreatorrev=rev}] [@option{--no-ebda}] @
1433 filename @dots{}
1434 Modern BIOS systems normally implement the Advanced Configuration and Power
1435 Interface (ACPI), and define various tables that describe the interface
1436 between an ACPI-compliant operating system and the firmware. In some cases,
1437 the tables provided by default only work well with certain operating
1438 systems, and it may be necessary to replace some of them.
1439
1440 Normally, this command will replace the Root System Description Pointer
1441 (RSDP) in the Extended BIOS Data Area to point to the new tables. If the
1442 @option{--no-ebda} option is used, the new tables will be known only to
1443 GRUB, but may be used by GRUB's EFI emulation.
1444 @end deffn
1445
1446
1447 @node blocklist
1448 @subsection blocklist
1449
1450 @deffn Command blocklist file
1451 Print a block list (@pxref{Block list syntax}) for @var{file}.
1452 @end deffn
1453
1454
1455 @node boot
1456 @subsection boot
1457
1458 @deffn Command boot
1459 Boot the OS or chain-loader which has been loaded. Only necessary if
1460 running the fully interactive command-line (it is implicit at the end of
1461 a menu entry).
1462 @end deffn
1463
1464
1465 @node cat
1466 @subsection cat
1467
1468 @deffn Command cat file
1469 Display the contents of the file @var{file}. This command may be useful
1470 to remind you of your OS's root partition:
1471
1472 @example
1473 grub> @kbd{cat /etc/fstab}
1474 @end example
1475 @end deffn
1476
1477
1478 @node chainloader
1479 @subsection chainloader
1480
1481 @deffn Command chainloader [@option{--force}] file
1482 Load @var{file} as a chain-loader. Like any other file loaded by the
1483 filesystem code, it can use the blocklist notation (@pxref{Block list
1484 syntax}) to grab the first sector of the current partition with @samp{+1}.
1485 If you specify the option @option{--force}, then load @var{file} forcibly,
1486 whether it has a correct signature or not. This is required when you want to
1487 load a defective boot loader, such as SCO UnixWare 7.1.
1488 @end deffn
1489
1490
1491 @node cmp
1492 @subsection cmp
1493
1494 @deffn Command cmp file1 file2
1495 Compare the file @var{file1} with the file @var{file2}. If they differ
1496 in size, print the sizes like this:
1497
1498 @example
1499 Differ in size: 0x1234 [foo], 0x4321 [bar]
1500 @end example
1501
1502 If the sizes are equal but the bytes at an offset differ, then print the
1503 bytes like this:
1504
1505 @example
1506 Differ at the offset 777: 0xbe [foo], 0xef [bar]
1507 @end example
1508
1509 If they are completely identical, nothing will be printed.
1510 @end deffn
1511
1512
1513 @node configfile
1514 @subsection configfile
1515
1516 @deffn Command configfile file
1517 Load @var{file} as a configuration file.
1518 @end deffn
1519
1520
1521 @node crc
1522 @subsection crc
1523
1524 @deffn Command crc file
1525 Display the CRC32 checksum of @var{file}.
1526 @end deffn
1527
1528
1529 @node date
1530 @subsection date
1531
1532 @deffn Command date [[year-]month-day] [hour:minute[:second]]
1533 With no arguments, print the current date and time.
1534
1535 Otherwise, take the current date and time, change any elements specified as
1536 arguments, and set the result as the new date and time. For example, `date
1537 01-01' will set the current month and day to January 1, but leave the year,
1538 hour, minute, and second unchanged.
1539 @end deffn
1540
1541
1542 @node drivemap
1543 @subsection drivemap
1544
1545 @deffn Command drivemap @option{-l}|@option{-r}|[@option{-s}] @
1546 from_drive to_drive
1547 Without options, map the drive @var{from_drive} to the drive @var{to_drive}.
1548 This is necessary when you chain-load some operating systems, such as DOS,
1549 if such an OS resides at a non-first drive. For convenience, any partition
1550 suffix on the drive is ignored, so you can safely use @verb{'${root}'} as a
1551 drive specification.
1552
1553 With the @option{-s} option, perform the reverse mapping as well, swapping
1554 the two drives.
1555
1556 With the @option{-l} option, list the current mappings.
1557
1558 With the @option{-r} option, reset all mappings to the default values.
1559
1560 For example:
1561
1562 @example
1563 drivemap -s (hd0) (hd1)
1564 @end example
1565 @end deffn
1566
1567
1568 @node echo
1569 @subsection echo
1570
1571 @deffn Command echo [@option{-n}] [@option{-e}] string @dots{}
1572 Display the requested text and, unless the @option{-n} option is used, a
1573 trailing new line. If there is more than one string, they are separated by
1574 spaces in the output. As usual in GRUB commands, variables may be
1575 substituted using @samp{$@{var@}}.
1576
1577 The @option{-e} option enables interpretation of backslash escapes. The
1578 following sequences are recognised:
1579
1580 @table @code
1581 @item \\
1582 backslash
1583
1584 @item \a
1585 alert (BEL)
1586
1587 @item \c
1588 suppress trailing new line
1589
1590 @item \f
1591 form feed
1592
1593 @item \n
1594 new line
1595
1596 @item \r
1597 carriage return
1598
1599 @item \t
1600 horizontal tab
1601
1602 @item \v
1603 vertical tab
1604 @end table
1605
1606 When interpreting backslash escapes, backslash followed by any other
1607 character will print that character.
1608 @end deffn
1609
1610
1611 @node export
1612 @subsection export
1613
1614 @deffn Command export envvar
1615 Export the environment variable @var{envvar}. Exported variables are visible
1616 to subsidiary configuration files loaded using @command{configfile}.
1617 @end deffn
1618
1619
1620 @node gettext
1621 @subsection gettext
1622
1623 @deffn Command gettext string
1624 Translate @var{string} into the current language.
1625
1626 The current language code is stored in the @samp{lang} variable in GRUB's
1627 environment. Translation files in MO format are read from
1628 @samp{locale_dir}, usually @file{/boot/grub/locale}.
1629 @end deffn
1630
1631
1632 @node gptsync
1633 @subsection gptsync
1634
1635 @deffn Command gptsync device [partition[+/-[type]]] @dots{}
1636 Disks using the GUID Partition Table (GPT) also have a legacy Master Boot
1637 Record (MBR) partition table for compatibility with the BIOS and with older
1638 operating systems. The legacy MBR can only represent a limited subset of
1639 GPT partition entries.
1640
1641 This command populates the legacy MBR with the specified @var{partition}
1642 entries on @var{device}. Up to three partitions may be used.
1643
1644 @var{type} is an MBR partition type code; prefix with @samp{0x} if you want
1645 to enter this in hexadecimal. The separator between @var{partition} and
1646 @var{type} may be @samp{+} to make the partition active, or @samp{-} to make
1647 it inactive; only one partition may be active. If both the separator and
1648 type are omitted, then the partition will be inactive.
1649 @end deffn
1650
1651
1652 @node halt
1653 @subsection halt
1654
1655 @deffn Command halt @option{--no-apm}
1656 The command halts the computer. If the @option{--no-apm} option
1657 is specified, no APM BIOS call is performed. Otherwise, the computer
1658 is shut down using APM.
1659 @end deffn
1660
1661
1662 @node help
1663 @subsection help
1664
1665 @deffn Command help @option{--all} [pattern @dots{}]
1666 Display helpful information about builtin commands. If you do not
1667 specify @var{pattern}, this command shows short descriptions of most of
1668 available commands. If you specify the option @option{--all} to this
1669 command, short descriptions of rarely used commands (such as
1670 @ref{testload}) are displayed as well.
1671
1672 If you specify any @var{patterns}, it displays longer information
1673 about each of the commands which match those @var{patterns}.
1674 @end deffn
1675
1676
1677 @node insmod
1678 @subsection insmod
1679
1680 @deffn Command insmod module
1681 Insert the dynamic GRUB module called @var{module}.
1682 @end deffn
1683
1684
1685 @node keystatus
1686 @subsection keystatus
1687
1688 @deffn Command keystatus [@option{--shift}] [@option{--ctrl}] [@option{--alt}]
1689 Return true if the Shift, Control, or Alt modifier keys are held down, as
1690 requested by options. This is useful in scripting, to allow some user
1691 control over behaviour without having to wait for a keypress.
1692
1693 Checking key modifier status is only supported on some platforms. If invoked
1694 without any options, the @command{keystatus} command returns true if and
1695 only if checking key modifier status is supported.
1696 @end deffn
1697
1698
1699 @node ls
1700 @subsection ls
1701
1702 @deffn Command ls [arg]
1703 List devices or files.
1704
1705 With no arguments, print all devices known to GRUB.
1706
1707 If the argument is a device name enclosed in parentheses (@pxref{Device
1708 syntax}), then list all files at the root directory of that device.
1709
1710 If the argument is a directory given as an absolute file name (@pxref{File
1711 name syntax}), then list the contents of that directory.
1712 @end deffn
1713
1714
1715 @node parttool
1716 @subsection parttool
1717
1718 @deffn Command parttool partition commands
1719 Make various modifications to partition table entries.
1720
1721 Each @var{command} is either a boolean option, in which case it must be
1722 followed with @samp{+} or @samp{-} (with no intervening space) to enable or
1723 disable that option, or else it takes a value in the form
1724 @samp{@var{command}=@var{value}}.
1725
1726 Currently, @command{parttool} is only useful on DOS partition tables (also
1727 known as Master Boot Record, or MBR). On these partition tables, the
1728 following commands are available:
1729
1730 @table @asis
1731 @item @samp{boot} (boolean)
1732 When enabled, this makes the selected partition be the active (bootable)
1733 partition on its disk, clearing the active flag on all other partitions.
1734 This command is limited to @emph{primary} partitions.
1735
1736 @item @samp{type} (value)
1737 Change the type of an existing partition. The value must be a number in the
1738 range 0-0xFF (prefix with @samp{0x} to enter it in hexadecimal).
1739
1740 @item @samp{hidden} (boolean)
1741 When enabled, this hides the selected partition by setting the @dfn{hidden}
1742 bit in its partition type code; when disabled, unhides the selected
1743 partition by clearing this bit. This is useful only when booting DOS or
1744 Wwindows and multiple primary FAT partitions exist in one disk. See also
1745 @ref{DOS/Windows}.
1746 @end table
1747 @end deffn
1748
1749
1750 @node play
1751 @subsection play
1752
1753 @deffn Command play file | tempo [pitch1 duration1] [pitch2 duration2] ...
1754 Plays a tune
1755
1756 If the argument is a file name (@pxref{File name syntax}), play the tune
1757 recorded in it. The file format is first the tempo as an unsigned 32bit
1758 little-endian number, then pairs of unsigned 16bit little-endian numbers for
1759 pitch and duration pairs.
1760
1761 If the arguments are a series of numbers, play the inline tune.
1762
1763 The tempo is the base for all note durations. 60 gives a 1-second base, 120
1764 gives a half-second base, etc. Pitches are Hz. Set pitch to 0 to produce
1765 a rest.
1766 @end deffn
1767
1768
1769 @node reboot
1770 @subsection reboot
1771
1772 @deffn Command reboot
1773 Reboot the computer.
1774 @end deffn
1775
1776
1777 @node set
1778 @subsection set
1779
1780 @deffn Command set [envvar=value]
1781 Set the environment variable @var{envvar} to @var{value}. If invoked with no
1782 arguments, print all environment variables with their values.
1783 @end deffn
1784
1785
1786 @node unset
1787 @subsection unset
1788
1789 @deffn Command unset envvar
1790 Unset the environment variable @var{envvar}.
1791 @end deffn
1792
1793
1794 @node Invoking grub-install
1795 @chapter Invoking grub-install
1796
1797 The program @command{grub-install} installs GRUB on your drive using
1798 @command{grub-mkimage} and (on some platforms) @command{grub-setup}. You
1799 must specify the device name on which you want to install GRUB, like this:
1800
1801 @example
1802 grub-install @var{install_device}
1803 @end example
1804
1805 The device name @var{install_device} is an OS device name or a GRUB
1806 device name.
1807
1808 @command{grub-install} accepts the following options:
1809
1810 @table @option
1811 @item --help
1812 Print a summary of the command-line options and exit.
1813
1814 @item --version
1815 Print the version number of GRUB and exit.
1816
1817 @item --root-directory=@var{dir}
1818 Install GRUB images under the directory @var{dir} instead of the root
1819 directory. This option is useful when you want to install GRUB into a
1820 separate partition or a removable disk. Here is an example in which
1821 you have a separate @dfn{boot} partition which is mounted on
1822 @file{/boot}:
1823
1824 @example
1825 @kbd{grub-install --root-directory=/boot hd0}
1826 @end example
1827
1828 @item --recheck
1829 Recheck the device map, even if @file{/boot/grub/device.map} already
1830 exists. You should use this option whenever you add/remove a disk
1831 into/from your computer.
1832 @end table
1833
1834
1835 @node Invoking grub-mkconfig
1836 @chapter Invoking grub-mkconfig
1837
1838 The program @command{grub-mkconfig} generates a configuration file for GRUB
1839 (@pxref{Simple configuration}).
1840
1841 @example
1842 grub-mkconfig -o /boot/grub/grub.cfg
1843 @end example
1844
1845 @command{grub-mkconfig} accepts the following options:
1846
1847 @table @option
1848 @item --help
1849 Print a summary of the command-line options and exit.
1850
1851 @item --version
1852 Print the version number of GRUB and exit.
1853
1854 @item -o @var{file}
1855 @itemx --output=@var{file}
1856 Send the generated configuration file to @var{file}. The default is to send
1857 it to standard output.
1858 @end table
1859
1860
1861 @node Obtaining and Building GRUB
1862 @appendix How to obtain and build GRUB
1863
1864 @quotation
1865 @strong{Caution:} GRUB requires binutils-2.9.1.0.23 or later because the
1866 GNU assembler has been changed so that it can produce real 16bits
1867 machine code between 2.9.1 and 2.9.1.0.x. See
1868 @uref{http://sources.redhat.com/binutils/}, to obtain information on
1869 how to get the latest version.
1870 @end quotation
1871
1872 GRUB is available from the GNU alpha archive site
1873 @uref{ftp://alpha.gnu.org/gnu/grub} or any of its mirrors. The file
1874 will be named grub-version.tar.gz. The current version is
1875 @value{VERSION}, so the file you should grab is:
1876
1877 @uref{ftp://alpha.gnu.org/gnu/grub/grub-@value{VERSION}.tar.gz}
1878
1879 To unbundle GRUB use the instruction:
1880
1881 @example
1882 @kbd{zcat grub-@value{VERSION}.tar.gz | tar xvf -}
1883 @end example
1884
1885 which will create a directory called @file{grub-@value{VERSION}} with
1886 all the sources. You can look at the file @file{INSTALL} for detailed
1887 instructions on how to build and install GRUB, but you should be able to
1888 just do:
1889
1890 @example
1891 @group
1892 @kbd{cd grub-@value{VERSION}}
1893 @kbd{./configure}
1894 @kbd{make install}
1895 @end group
1896 @end example
1897
1898 Also, the latest version is available from the SVN. See
1899 @uref{http://savannah.gnu.org/svn/?group=grub} for more information.
1900
1901 @node Reporting bugs
1902 @appendix Reporting bugs
1903
1904 These are the guideline for how to report bugs. Take a look at this
1905 list below before you submit bugs:
1906
1907 @enumerate
1908 @item
1909 Before getting unsettled, read this manual through and through. Also,
1910 see the @uref{http://www.gnu.org/software/grub/grub-faq.html, GNU GRUB FAQ}.
1911
1912 @item
1913 Always mention the information on your GRUB. The version number and the
1914 configuration are quite important. If you build it yourself, write the
1915 options specified to the configure script and your operating system,
1916 including the versions of gcc and binutils.
1917
1918 @item
1919 If you have trouble with the installation, inform us of how you
1920 installed GRUB. Don't omit error messages, if any. Just @samp{GRUB hangs
1921 up when it boots} is not enough.
1922
1923 The information on your hardware is also essential. These are especially
1924 important: the geometries and the partition tables of your hard disk
1925 drives and your BIOS.
1926
1927 @item
1928 If GRUB cannot boot your operating system, write down
1929 @emph{everything} you see on the screen. Don't paraphrase them, like
1930 @samp{The foo OS crashes with GRUB, even though it can boot with the
1931 bar boot loader just fine}. Mention the commands you executed, the
1932 messages printed by them, and information on your operating system
1933 including the version number.
1934
1935 @item
1936 Explain what you wanted to do. It is very useful to know your purpose
1937 and your wish, and how GRUB didn't satisfy you.
1938
1939 @item
1940 If you can investigate the problem yourself, please do. That will give
1941 you and us much more information on the problem. Attaching a patch is
1942 even better.
1943
1944 When you attach a patch, make the patch in unified diff format, and
1945 write ChangeLog entries. But, even when you make a patch, don't forget
1946 to explain the problem, so that we can understand what your patch is
1947 for.
1948
1949 @item
1950 Write down anything that you think might be related. Please understand
1951 that we often need to reproduce the same problem you encounterred in our
1952 environment. So your information should be sufficient for us to do the
1953 same thing---Don't forget that we cannot see your computer directly. If
1954 you are not sure whether to state a fact or leave it out, state it!
1955 Reporting too many things is much better than omitting something
1956 important.
1957 @end enumerate
1958
1959 If you follow the guideline above, submit a report to the
1960 @uref{http://savannah.gnu.org/bugs/?group=grub, Bug Tracking System}.
1961 Alternatively, you can submit a report via electronic mail to
1962 @email{bug-grub@@gnu.org}, but we strongly recommend that you use the
1963 Bug Tracking System, because e-mail can be passed over easily.
1964
1965 Once we get your report, we will try to fix the bugs.
1966
1967
1968 @node Future
1969 @appendix Where GRUB will go
1970
1971 We started the next generation of GRUB, GRUB 2. GRUB 2 includes
1972 internationalization, dynamic module loading, real memory management,
1973 multiple architecture support, a scripting language, and many other
1974 nice feature. If you are interested in the development of GRUB 2, take
1975 a look at @uref{http://www.gnu.org/software/grub/grub.html, the
1976 homepage}.
1977
1978
1979
1980 @node Copying This Manual
1981 @appendix Copying This Manual
1982
1983 @menu
1984 * GNU Free Documentation License:: License for copying this manual.
1985 @end menu
1986
1987 @include fdl.texi
1988
1989
1990 @node Index
1991 @unnumbered Index
1992
1993 @c Currently, we use only the Concept Index.
1994 @printindex cp
1995
1996
1997 @bye
1998
1999 Some notes:
2000
2001 This is an attempt to make a manual for GRUB 2. The contents are
2002 copied from the GRUB manual in GRUB Legacy, so they are not always
2003 appropriate yet for GRUB 2.