6 @settitle GNU GRUB Manual @value{VERSION}
7 @c Unify all our little indices for now.
15 @footnotestyle separate
20 This manual is for GNU GRUB (version @value{VERSION},
23 Copyright @copyright{} 1999,2000,2001,2002,2004,2006,2008,2009 Free Software Foundation, Inc.
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
35 * GRUB: (grub). The GRand Unified Bootloader
36 * grub-install: (grub)Invoking grub-install. Install GRUB on your drive
37 * grub-terminfo: (grub)Invoking grub-terminfo. Generate a terminfo
42 @setchapternewpage odd
46 @title the GNU GRUB manual
47 @subtitle The GRand Unified Bootloader, version @value{VERSION}, @value{UPDATED}.
48 @author Gordon Matzigkeit
49 @author Yoshinori K. Okuji
50 @c The following two commands start the copyright page.
52 @vskip 0pt plus 1filll
56 @c Output the table of contents at the beginning.
66 This is the documentation of GNU GRUB, the GRand Unified Bootloader,
67 a flexible and powerful boot loader program for a wide range of
70 This edition documents version @value{VERSION}.
76 * Introduction:: Capturing the spirit of GRUB
77 * Naming convention:: Names of your drives in GRUB
78 * Installation:: Installing GRUB on your drive
79 * Booting:: How to boot different operating systems
80 * Configuration:: Writing your own configuration file
81 * Network:: Downloading OS images from a network
82 * Serial terminal:: Using GRUB via a serial line
83 * Preset Menu:: Embedding a configuration file into GRUB
84 * Images:: GRUB image files
85 * Filesystem:: Filesystem syntax and semantics
86 * Interface:: The menu and the command-line
87 * Commands:: The list of available builtin commands
88 * Troubleshooting:: Error messages produced by GRUB
89 * Invoking the grub shell:: How to use the grub shell
90 * Invoking grub-install:: How to use the GRUB installer
91 * Invoking grub-terminfo:: How to generate a terminfo command
92 * Obtaining and Building GRUB:: How to obtain and build GRUB
93 * Reporting bugs:: Where you should send a bug report
94 * Future:: Some future plans on GRUB
95 * Internals:: Hacking GRUB
96 * Copying This Manual:: Copying This Manual
102 @chapter Introduction to GRUB
105 * Overview:: What exactly GRUB is and how to use it
106 * History:: From maggot to house fly
107 * Features:: GRUB features
108 * Role of a boot loader:: The role of a boot loader
115 Briefly, a @dfn{boot loader} is the first software program that runs when
116 a computer starts. It is responsible for loading and transferring
117 control to an operating system @dfn{kernel} software (such as Linux or
118 GNU Mach). The kernel, in turn, initializes the rest of the operating
119 system (e.g. a GNU system).
121 GNU GRUB is a very powerful boot loader, which can load a wide variety
122 of free operating systems, as well as proprietary operating systems with
123 chain-loading@footnote{@dfn{chain-load} is the mechanism for loading
124 unsupported operating systems by loading another boot loader. It is
125 typically used for loading DOS or Windows.}. GRUB is designed to
126 address the complexity of booting a personal computer; both the
127 program and this manual are tightly bound to that computer platform,
128 although porting to other platforms may be addressed in the future.
130 One of the important features in GRUB is flexibility; GRUB understands
131 filesystems and kernel executable formats, so you can load an arbitrary
132 operating system the way you like, without recording the physical
133 position of your kernel on the disk. Thus you can load the kernel
134 just by specifying its file name and the drive and partition where the
137 When booting with GRUB, you can use either a command-line interface
138 (@pxref{Command-line interface}), or a menu interface (@pxref{Menu
139 interface}). Using the command-line interface, you type the drive
140 specification and file name of the kernel manually. In the menu
141 interface, you just select an OS using the arrow keys. The menu is
142 based on a configuration file which you prepare beforehand
143 (@pxref{Configuration}). While in the menu, you can switch to the
144 command-line mode, and vice-versa. You can even edit menu entries
147 In the following chapters, you will learn how to specify a drive, a
148 partition, and a file name (@pxref{Naming convention}) to GRUB, how to
149 install GRUB on your drive (@pxref{Installation}), and how to boot your
150 OSes (@pxref{Booting}), step by step.
154 @section History of GRUB
156 GRUB originated in 1995 when Erich Boleyn was trying to boot the GNU
157 Hurd with the University of Utah's Mach 4 microkernel (now known as GNU
158 Mach). Erich and Brian Ford designed the Multiboot Specification
159 (@pxref{Top, Multiboot Specification, Motivation, multiboot, The Multiboot
160 Specification}), because they were determined not to add to the large
161 number of mutually-incompatible PC boot methods.
163 Erich then began modifying the FreeBSD boot loader so that it would
164 understand Multiboot. He soon realized that it would be a lot easier
165 to write his own boot loader from scratch than to keep working on the
166 FreeBSD boot loader, and so GRUB was born.
168 Erich added many features to GRUB, but other priorities prevented him
169 from keeping up with the demands of its quickly-expanding user base. In
170 1999, Gordon Matzigkeit and Yoshinori K. Okuji adopted GRUB as an
171 official GNU package, and opened its development by making the latest
172 sources available via anonymous CVS. @xref{Obtaining and Building
173 GRUB}, for more information.
177 @section GRUB features
179 The primary requirement for GRUB is that it be compliant with the
180 @dfn{Multiboot Specification}, which is described in @ref{Top, Multiboot
181 Specification, Motivation, multiboot, The Multiboot Specification}.
183 The other goals, listed in approximate order of importance, are:
187 Basic functions must be straightforward for end-users.
190 Rich functionality to support kernel experts and designers.
193 Backward compatibility for booting FreeBSD, NetBSD, OpenBSD, and
194 Linux. Proprietary kernels (such as DOS, Windows NT, and OS/2) are
195 supported via a chain-loading function.
198 Except for specific compatibility modes (chain-loading and the Linux
199 @dfn{piggyback} format), all kernels will be started in much the same
200 state as in the Multiboot Specification. Only kernels loaded at 1 megabyte
201 or above are presently supported. Any attempt to load below that
202 boundary will simply result in immediate failure and an error message
203 reporting the problem.
205 In addition to the requirements above, GRUB has the following features
206 (note that the Multiboot Specification doesn't require all the features
210 @item Recognize multiple executable formats
211 Support many of the @dfn{a.out} variants plus @dfn{ELF}. Symbol
212 tables are also loaded.
214 @item Support non-Multiboot kernels
215 Support many of the various free 32-bit kernels that lack Multiboot
216 compliance (primarily FreeBSD, NetBSD, OpenBSD, and
217 Linux). Chain-loading of other boot loaders is also supported.
219 @item Load multiples modules
220 Fully support the Multiboot feature of loading multiple modules.
222 @item Load a configuration file
223 Support a human-readable text configuration file with preset boot
224 commands. You can also load another configuration file dynamically and
225 embed a preset configuration file in a GRUB image file. The list of
226 commands (@pxref{Commands}) are a superset of those supported on the
227 command-line. An example configuration file is provided in
230 @item Provide a menu interface
231 A menu interface listing preset boot commands, with a programmable
232 timeout, is available. There is no fixed limit on the number of boot
233 entries, and the current implementation has space for several hundred.
235 @item Have a flexible command-line interface
236 A fairly flexible command-line interface, accessible from the menu,
237 is available to edit any preset commands, or write a new boot command
238 set from scratch. If no configuration file is present, GRUB drops to
241 The list of commands (@pxref{Commands}) are a subset of those supported
242 for configuration files. Editing commands closely resembles the Bash
243 command-line (@pxref{Command Line Editing, Bash, Command Line Editing,
244 features, Bash Features}), with @key{TAB}-completion of commands,
245 devices, partitions, and files in a directory depending on context.
247 @item Support multiple filesystem types
248 Support multiple filesystem types transparently, plus a useful explicit
249 blocklist notation. The currently supported filesystem types are
250 @dfn{BSD FFS}, @dfn{DOS FAT16 and FAT32}, @dfn{Minix fs}, @dfn{Linux
251 ext2fs}, @dfn{ReiserFS}, @dfn{JFS}, @dfn{XFS}, and @dfn{VSTa
252 fs}. @xref{Filesystem}, for more information.
254 @item Support automatic decompression
255 Can decompress files which were compressed by @command{gzip}. This
256 function is both automatic and transparent to the user (i.e. all
257 functions operate upon the uncompressed contents of the specified
258 files). This greatly reduces a file size and loading time, a
259 particularly great benefit for floppies.@footnote{There are a few
260 pathological cases where loading a very badly organized ELF kernel might
261 take longer, but in practice this never happen.}
263 It is conceivable that some kernel modules should be loaded in a
264 compressed state, so a different module-loading command can be specified
265 to avoid uncompressing the modules.
267 @item Access data on any installed device
268 Support reading data from any or all floppies or hard disk(s) recognized
269 by the BIOS, independent of the setting of the root device.
271 @item Be independent of drive geometry translations
272 Unlike many other boot loaders, GRUB makes the particular drive
273 translation irrelevant. A drive installed and running with one
274 translation may be converted to another translation without any adverse
275 effects or changes in GRUB's configuration.
277 @item Detect all installed @sc{ram}
278 GRUB can generally find all the installed @sc{ram} on a PC-compatible
279 machine. It uses an advanced BIOS query technique for finding all
280 memory regions. As described on the Multiboot Specification (@pxref{Top,
281 Multiboot Specification, Motivation, multiboot, The Multiboot
282 Specification}), not all kernels make use of this information, but GRUB
283 provides it for those who do.
285 @item Support Logical Block Address mode
286 In traditional disk calls (called @dfn{CHS mode}), there is a geometry
287 translation problem, that is, the BIOS cannot access over 1024
288 cylinders, so the accessible space is limited to at least 508 MB and to
289 at most 8GB. GRUB can't universally solve this problem, as there is no
290 standard interface used in all machines. However, several newer machines
291 have the new interface, Logical Block Address (@dfn{LBA}) mode. GRUB
292 automatically detects if LBA mode is available and uses it if
293 available. In LBA mode, GRUB can access the entire disk.
295 @item Support network booting
296 GRUB is basically a disk-based boot loader but also has network
297 support. You can load OS images from a network by using the @dfn{TFTP}
300 @item Support remote terminals
301 To support computers with no console, GRUB provides remote terminal
302 support, so that you can control GRUB from a remote host. Only serial
303 terminal support is implemented at the moment.
307 @node Role of a boot loader
308 @section The role of a boot loader
310 The following is a quotation from Gordon Matzigkeit, a GRUB fanatic:
313 Some people like to acknowledge both the operating system and kernel when
314 they talk about their computers, so they might say they use
315 ``GNU/Linux'' or ``GNU/Hurd''. Other people seem to think that the
316 kernel is the most important part of the system, so they like to call
317 their GNU operating systems ``Linux systems.''
319 I, personally, believe that this is a grave injustice, because the
320 @emph{boot loader} is the most important software of all. I used to
321 refer to the above systems as either ``LILO''@footnote{The LInux LOader,
322 a boot loader that everybody uses, but nobody likes.} or ``GRUB''
325 Unfortunately, nobody ever understood what I was talking about; now I
326 just use the word ``GNU'' as a pseudonym for GRUB.
328 So, if you ever hear people talking about their alleged ``GNU'' systems,
329 remember that they are actually paying homage to the best boot loader
333 We, the GRUB maintainers, do not (usually) encourage Gordon's level of
334 fanaticism, but it helps to remember that boot loaders deserve
335 recognition. We hope that you enjoy using GNU GRUB as much as we did
339 @node Naming convention
340 @chapter Naming convention
342 The device syntax used in GRUB is a wee bit different from what you may
343 have seen before in your operating system(s), and you need to know it so
344 that you can specify a drive/partition.
346 Look at the following examples and explanations:
352 First of all, GRUB requires that the device name be enclosed with
353 @samp{(} and @samp{)}. The @samp{fd} part means that it is a floppy
354 disk. The number @samp{0} is the drive number, which is counted from
355 @emph{zero}. This expression means that GRUB will use the whole floppy
362 Here, @samp{hd} means it is a hard disk drive. The first integer
363 @samp{0} indicates the drive number, that is, the first hard disk, while
364 the second integer, @samp{1}, indicates the partition number (or the
365 @sc{pc} slice number in the BSD terminology). The partition numbers are
366 counted from @emph{one}, not from zero (as was the case in previous
367 versions of GRUB). This expression means the second partition of the
368 first hard disk drive. In this case, GRUB uses one partition of the
369 disk, instead of the whole disk.
375 This specifies the first @dfn{extended partition} of the first hard disk
376 drive. Note that the partition numbers for extended partitions are
377 counted from @samp{5}, regardless of the actual number of primary
378 partitions on your hard disk.
384 This means the BSD @samp{a} partition of the second hard disk. If you
385 need to specify which @sc{pc} slice number should be used, use something
386 like this: @samp{(hd1,1,a)}. If the @sc{pc} slice number is omitted,
387 GRUB searches for the first @sc{pc} slice which has a BSD @samp{a}
390 Of course, to actually access the disks or partitions with GRUB, you
391 need to use the device specification in a command, like @samp{root
392 (fd0)} or @samp{unhide (hd0,3)}. To help you find out which number
393 specifies a partition you want, the GRUB command-line
394 (@pxref{Command-line interface}) options have argument
395 completion. This means that, for example, you only need to type
401 followed by a @key{TAB}, and GRUB will display the list of drives,
402 partitions, or file names. So it should be quite easy to determine the
403 name of your target partition, even with minimal knowledge of the
406 Note that GRUB does @emph{not} distinguish IDE from SCSI - it simply
407 counts the drive numbers from zero, regardless of their type. Normally,
408 any IDE drive number is less than any SCSI drive number, although that
409 is not true if you change the boot sequence by swapping IDE and SCSI
412 Now the question is, how to specify a file? Again, consider an
419 This specifies the file named @samp{vmlinuz}, found on the first
420 partition of the first hard disk drive. Note that the argument
421 completion works with file names, too.
423 That was easy, admit it. Now read the next chapter, to find out how to
424 actually install GRUB on your drive.
428 @chapter Installation
430 In order to install GRUB as your boot loader, you need to first
431 install the GRUB system and utilities under your UNIX-like operating
432 system (@pxref{Obtaining and Building GRUB}). You can do this either
433 from the source tarball, or as a package for your OS.
435 After you have done that, you need to install the boot loader on a
436 drive (floppy or hard disk). There are two ways of doing that - either
437 using the utility @command{grub-install} (@pxref{Invoking
438 grub-install}) on a UNIX-like OS, or by running GRUB itself from a
439 floppy. These are quite similar, however the utility might probe a
440 wrong BIOS drive, so you should be careful.
442 Also, if you install GRUB on a UNIX-like OS, please make sure that you
443 have an emergency boot disk ready, so that you can rescue your computer
444 if, by any chance, your hard drive becomes unusable (unbootable).
446 GRUB comes with boot images, which are normally put in the directory
447 @file{/usr/lib/grub/i386-pc}. Hereafter, the directory where GRUB images are
448 initially placed (normally @file{/usr/lib/grub/i386-pc}) will be
449 called the @dfn{image directory}, and the directory where the boot
450 loader needs to find them (usually @file{/boot/grub}) will be called
451 the @dfn{boot directory}.
454 * Installing GRUB using grub-install::
458 @node Installing GRUB using grub-install
459 @section Installing GRUB using grub-install
461 @strong{Caution:} This procedure is definitely less safe, because
462 there are several ways in which your computer can become
463 unbootable. For example, most operating systems don't tell GRUB how to
464 map BIOS drives to OS devices correctly---GRUB merely @dfn{guesses}
465 the mapping. This will succeed in most cases, but not
466 always. Therefore, GRUB provides you with a map file called the
467 @dfn{device map}, which you must fix if it is wrong. @xref{Device
468 map}, for more details.
470 If you still do want to install GRUB under a UNIX-like OS (such
471 as @sc{gnu}), invoke the program @command{grub-install} (@pxref{Invoking
472 grub-install}) as the superuser (@dfn{root}).
474 The usage is basically very simple. You only need to specify one
475 argument to the program, namely, where to install the boot loader. The
476 argument can be either a device file (like @samp{/dev/hda}) or a
477 partition specified in GRUB's notation. For example, under Linux the
478 following will install GRUB into the MBR of the first IDE disk:
481 # @kbd{grub-install /dev/hda}
484 Likewise, under GNU/Hurd, this has the same effect:
487 # @kbd{grub-install /dev/hd0}
490 If it is the first BIOS drive, this is the same as well:
493 # @kbd{grub-install '(hd0)'}
496 Or you can omit the parentheses:
499 # @kbd{grub-install hd0}
502 But all the above examples assume that GRUB should use images under
503 the root directory. If you want GRUB to use images under a directory
504 other than the root directory, you need to specify the option
505 @option{--root-directory}. The typical usage is that you create a GRUB
506 boot floppy with a filesystem. Here is an example:
510 # @kbd{mke2fs /dev/fd0}
511 # @kbd{mount -t ext2 /dev/fd0 /mnt}
512 # @kbd{grub-install --root-directory=/mnt fd0}
517 Another example is when you have a separate boot partition
518 which is mounted at @file{/boot}. Since GRUB is a boot loader, it
519 doesn't know anything about mountpoints at all. Thus, you need to run
520 @command{grub-install} like this:
523 # @kbd{grub-install --root-directory=/boot /dev/hda}
526 By the way, as noted above, it is quite difficult to guess BIOS drives
527 correctly under a UNIX-like OS. Thus, @command{grub-install} will prompt
528 you to check if it could really guess the correct mappings, after the
529 installation. The format is defined in @ref{Device map}. Please be
530 quite careful. If the output is wrong, it is unlikely that your
531 computer will be able to boot with no problem.
533 Note that @command{grub-install} is actually just a shell script and the
534 real task is done by the grub shell @command{grub} (@pxref{Invoking the
535 grub shell}). Therefore, you may run @command{grub} directly to install
536 GRUB, without using @command{grub-install}. Don't do that, however,
537 unless you are very familiar with the internals of GRUB. Installing a
538 boot loader on a running OS may be extremely dangerous.
541 @node Making a GRUB bootable CD-ROM
542 @section Making a GRUB bootable CD-ROM
544 GRUB supports the @dfn{no emulation mode} in the El Torito
545 specification@footnote{El Torito is a specification for bootable CD
546 using BIOS functions.}. This means that you can use the whole CD-ROM
547 from GRUB and you don't have to make a floppy or hard disk image file,
548 which can cause compatibility problems.
550 For booting from a CD-ROM, GRUB uses a special Stage 2 called
551 @file{stage2_eltorito}. The only GRUB files you need to have in your
552 bootable CD-ROM are this @file{stage2_eltorito} and optionally a config file
553 @file{grub.cfg}. You don't need to use @file{stage1} or @file{stage2},
554 because El Torito is quite different from the standard boot process.
556 Here is an example of procedures to make a bootable CD-ROM
557 image. First, make a top directory for the bootable image, say,
564 Make a directory for GRUB:
567 $ @kbd{mkdir -p iso/boot/grub}
570 Copy the file @file{stage2_eltorito}:
573 $ @kbd{cp /usr/lib/grub/i386-pc/stage2_eltorito iso/boot/grub}
576 If desired, make the config file @file{grub.cfg} under @file{iso/boot/grub}
577 (@pxref{Configuration}), and copy any files and directories for the disc to the
578 directory @file{iso/}.
580 Finally, make a ISO9660 image file like this:
583 $ @kbd{mkisofs -R -b boot/grub/stage2_eltorito -no-emul-boot \
584 -boot-load-size 4 -boot-info-table -o grub.iso iso}
587 This produces a file named @file{grub.iso}, which then can be burned
588 into a CD (or a DVD). @kbd{mkisofs} has already set up the disc to boot
589 from the @kbd{boot/grub/stage2_eltorito} file, so there is no need to
590 setup GRUB on the disc. (Note that the @kbd{-boot-load-size 4} bit is
591 required for compatibility with the BIOS on many older machines.)
593 You can use the device @samp{(cd)} to access a CD-ROM in your
594 config file. This is not required; GRUB automatically sets the root device
595 to @samp{(cd)} when booted from a CD-ROM. It is only necessary to refer to
596 @samp{(cd)} if you want to access other drives as well.
602 GRUB can load Multiboot-compliant kernels in a consistent way,
603 but for some free operating systems you need to use some OS-specific
607 * General boot methods:: How to boot OSes with GRUB generally
608 * OS-specific notes:: Notes on some operating systems
612 @node General boot methods
613 @section How to boot operating systems
615 GRUB has two distinct boot methods. One of the two is to load an
616 operating system directly, and the other is to chain-load another boot
617 loader which then will load an operating system actually. Generally
618 speaking, the former is more desirable, because you don't need to
619 install or maintain other boot loaders and GRUB is flexible enough to
620 load an operating system from an arbitrary disk/partition. However,
621 the latter is sometimes required, since GRUB doesn't support all the
622 existing operating systems natively.
625 * Loading an operating system directly::
630 @node Loading an operating system directly
631 @subsection How to boot an OS directly with GRUB
633 Multiboot (@pxref{Top, Multiboot Specification, Motivation, multiboot,
634 The Multiboot Specification}) is the native format supported by GRUB.
635 For the sake of convenience, there is also support for Linux, FreeBSD,
636 NetBSD and OpenBSD. If you want to boot other operating systems, you
637 will have to chain-load them (@pxref{Chain-loading}).
639 FIXME: this section is incomplete.
643 Run the command @command{boot} (@pxref{boot}).
646 However, DOS and Windows have some deficiencies, so you might have to
647 use more complicated instructions. @xref{DOS/Windows}, for more
651 @node OS-specific notes
652 @section Some caveats on OS-specific issues
654 Here, we describe some caveats on several operating systems.
665 Since GNU/Hurd is Multiboot-compliant, it is easy to boot it; there is
666 nothing special about it. But do not forget that you have to specify a
667 root partition to the kernel.
669 FIXME: this section is incomplete.
673 Run the command @command{boot} (@pxref{boot}).
678 @subsection GNU/Linux
680 It is relatively easy to boot GNU/Linux from GRUB, because it somewhat
681 resembles to boot a Multiboot-compliant OS.
683 FIXME: this section is incomplete.
687 Set GRUB's root device to the same drive as GNU/Linux's.
690 Finally, run the command @command{boot} (@pxref{boot}).
693 @strong{Caution:} If you use an initrd and specify the @samp{mem=}
694 option to the kernel to let it use less than actual memory size, you
695 will also have to specify the same memory size to GRUB. To let GRUB know
696 the size, run the command @command{uppermem} @emph{before} loading the
697 kernel. @xref{uppermem}, for more information.
700 @node Serial terminal
701 @chapter Using GRUB via a serial line
703 This chapter describes how to use the serial terminal support in GRUB.
705 If you have many computers or computers with no display/keyboard, it
706 could be very useful to control the computers through serial
707 communications. To connect one computer with another via a serial line,
708 you need to prepare a null-modem (cross) serial cable, and you may need
709 to have multiport serial boards, if your computer doesn't have extra
710 serial ports. In addition, a terminal emulator is also required, such as
711 minicom. Refer to a manual of your operating system, for more
714 As for GRUB, the instruction to set up a serial terminal is quite
715 simple. First of all, make sure that you haven't specified the option
716 @option{--disable-serial} to the configure script when you built your
717 GRUB images. If you get them in binary form, probably they have serial
718 terminal support already.
720 Then, initialize your serial terminal after GRUB starts up. Here is an
725 grub> @kbd{serial --unit=0 --speed=9600}
726 grub> @kbd{terminal serial}
730 The command @command{serial} initializes the serial unit 0 with the
731 speed 9600bps. The serial unit 0 is usually called @samp{COM1}, so, if
732 you want to use COM2, you must specify @samp{--unit=1} instead. This
733 command accepts many other options, so please refer to @ref{serial},
736 The command @command{terminal} (@pxref{terminal}) chooses which type of
737 terminal you want to use. In the case above, the terminal will be a
738 serial terminal, but you can also pass @code{console} to the command,
739 as @samp{terminal serial console}. In this case, a terminal in which
740 you press any key will be selected as a GRUB terminal.
742 However, note that GRUB assumes that your terminal emulator is
743 compatible with VT100 by default. This is true for most terminal
744 emulators nowadays, but you should pass the option @option{--dumb} to
745 the command if your terminal emulator is not VT100-compatible or
746 implements few VT100 escape sequences. If you specify this option then
747 GRUB provides you with an alternative menu interface, because the normal
748 menu requires several fancy features of your terminal.
752 @chapter Filesystem syntax and semantics
754 GRUB uses a special syntax for specifying disk drives which can be
755 accessed by BIOS. Because of BIOS limitations, GRUB cannot distinguish
756 between IDE, ESDI, SCSI, or others. You must know yourself which BIOS
757 device is equivalent to which OS device. Normally, that will be clear if
758 you see the files in a device or use the command @command{find}
762 * Device syntax:: How to specify devices
763 * File name syntax:: How to specify files
764 * Block list syntax:: How to specify block lists
769 @section How to specify devices
771 The device syntax is like this:
774 @code{(@var{device}[,@var{part-num}][,@var{bsd-subpart-letter}])}
777 @samp{[]} means the parameter is optional. @var{device} should be
778 either @samp{fd} or @samp{hd} followed by a digit, like @samp{fd0}.
779 But you can also set @var{device} to a hexadecimal or a decimal number
780 which is a BIOS drive number, so the following are equivalent:
788 @var{part-num} represents the partition number of @var{device}, starting
789 from one for primary partitions and from five for extended partitions,
790 and @var{bsd-subpart-letter} represents the BSD disklabel subpartition,
791 such as @samp{a} or @samp{e}.
793 A shortcut for specifying BSD subpartitions is
794 @code{(@var{device},@var{bsd-subpart-letter})}, in this case, GRUB
795 searches for the first PC partition containing a BSD disklabel, then
796 finds the subpartition @var{bsd-subpart-letter}. Here is an example:
802 The syntax @samp{(hd0)} represents using the entire disk (or the
803 MBR when installing GRUB), while the syntax @samp{(hd0,1)}
804 represents using the first partition of the disk (or the boot sector
805 of the partition when installing GRUB).
807 If you enabled the network support, the special drive, @samp{(nd)}, is
808 also available. Before using the network drive, you must initialize the
809 network. @xref{Network}, for more information.
811 If you boot GRUB from a CD-ROM, @samp{(cd)} is available. @xref{Making
812 a GRUB bootable CD-ROM}, for details.
815 @node File name syntax
816 @section How to specify files
818 There are two ways to specify files, by @dfn{absolute file name} and by
821 An absolute file name resembles a Unix absolute file name, using
822 @samp{/} for the directory separator (not @samp{\} as in DOS). One
823 example is @samp{(hd0,1)/boot/grub/grub.cfg}. This means the file
824 @file{/boot/grub/grub.cfg} in the first partition of the first hard
825 disk. If you omit the device name in an absolute file name, GRUB uses
826 GRUB's @dfn{root device} implicitly. So if you set the root device to,
827 say, @samp{(hd1,1)} by the command @command{root} (@pxref{root}), then
828 @code{/boot/kernel} is the same as @code{(hd1,1)/boot/kernel}.
831 @node Block list syntax
832 @section How to specify block lists
834 A block list is used for specifying a file that doesn't appear in the
835 filesystem, like a chainloader. The syntax is
836 @code{[@var{offset}]+@var{length}[,[@var{offset}]+@var{length}]@dots{}}.
840 @code{0+100,200+1,300+300}
843 This represents that GRUB should read blocks 0 through 99, block 200,
844 and blocks 300 through 599. If you omit an offset, then GRUB assumes
847 Like the file name syntax (@pxref{File name syntax}), if a blocklist
848 does not contain a device name, then GRUB uses GRUB's @dfn{root
849 device}. So @code{(hd0,2)+1} is the same as @code{+1} when the root
850 device is @samp{(hd0,2)}.
854 @chapter GRUB's user interface
856 GRUB has both a simple menu interface for choosing preset entries from a
857 configuration file, and a highly flexible command-line for performing
858 any desired combination of boot commands.
860 GRUB looks for its configuration file as soon as it is loaded. If one
861 is found, then the full menu interface is activated using whatever
862 entries were found in the file. If you choose the @dfn{command-line} menu
863 option, or if the configuration file was not found, then GRUB drops to
864 the command-line interface.
867 * Command-line interface:: The flexible command-line interface
868 * Menu interface:: The simple menu interface
872 @node Command-line interface
873 @section The flexible command-line interface
875 The command-line interface provides a prompt and after it an editable
876 text area much like a command-line in Unix or DOS. Each command is
877 immediately executed after it is entered@footnote{However, this
878 behavior will be changed in the future version, in a user-invisible
879 way.}. The commands (@pxref{Command-line and menu entry commands}) are a
880 subset of those available in the configuration file, used with exactly
883 Cursor movement and editing of the text on the line can be done via a
884 subset of the functions available in the Bash shell:
889 Move forward one character.
893 Move back one character.
897 Move to the start of the line.
901 Move the the end of the line.
905 Delete the character underneath the cursor.
909 Delete the character to the left of the cursor.
912 Kill the text from the current cursor position to the end of the line.
915 Kill backward from the cursor to the beginning of the line.
918 Yank the killed text back into the buffer at the cursor.
922 Move up through the history list.
926 Move down through the history list.
929 When typing commands interactively, if the cursor is within or before
930 the first word in the command-line, pressing the @key{TAB} key (or
931 @key{C-i}) will display a listing of the available commands, and if the
932 cursor is after the first word, the @kbd{@key{TAB}} will provide a
933 completion listing of disks, partitions, and file names depending on the
934 context. Note that to obtain a list of drives, one must open a
935 parenthesis, as @command{root (}.
937 Note that you cannot use the completion functionality in the TFTP
938 filesystem. This is because TFTP doesn't support file name listing for
943 @section The simple menu interface
945 The menu interface is quite easy to use. Its commands are both
946 reasonably intuitive and described on screen.
948 Basically, the menu interface provides a list of @dfn{boot entries} to
949 the user to choose from. Use the arrow keys to select the entry of
950 choice, then press @key{RET} to run it. An optional timeout is
951 available to boot the default entry (the first one if not set), which is
952 aborted by pressing any key.
954 Commands are available to enter a bare command-line by pressing @key{c}
955 (which operates exactly like the non-config-file version of GRUB, but
956 allows one to return to the menu if desired by pressing @key{ESC}) or to
957 edit any of the @dfn{boot entries} by pressing @key{e}.
959 If you protect the menu interface with a password (@pxref{Security}),
960 all you can do is choose an entry by pressing @key{RET}, or press
961 @key{p} to enter the password.
964 @node Menu entry editor
965 @section Editing a menu entry
967 The menu entry editor looks much like the main menu interface, but the
968 lines in the menu are individual commands in the selected entry instead
971 If an @key{ESC} is pressed in the editor, it aborts all the changes made
972 to the configuration entry and returns to the main menu interface.
974 When a particular line is selected, the editor places the user in a
975 special version of the GRUB command-line to edit that line. When the
976 user hits @key{RET}, GRUB replaces the line in question in the boot
977 entry with the changes (unless it was aborted via @key{ESC},
978 in which case the changes are thrown away).
980 If you want to add a new line to the menu entry, press @key{o} if adding
981 a line after the current line or press @key{O} if before the current
984 To delete a line, hit the key @key{d}. Although GRUB unfortunately
985 does not support @dfn{undo}, you can do almost the same thing by just
986 returning to the main menu.
990 @chapter The list of available commands
992 In this chapter, we list all commands that are available in GRUB.
994 Commands belong to different groups. A few can only be used in
995 the global section of the configuration file (or ``menu''); most
996 of them can be entered on the command-line and can be used either
997 anywhere in the menu or specifically in the menu entries.
1000 * Menu-specific commands::
1001 * General commands::
1002 * Command-line and menu entry commands::
1006 @node Menu-specific commands
1007 @section The list of commands for the menu only
1009 The semantics used in parsing the configuration file are the following:
1013 The menu-specific commands have to be used before any others.
1016 The files @emph{must} be in plain-text format.
1019 @samp{#} at the beginning of a line in a configuration file means it is
1023 Options are separated by spaces.
1026 All numbers can be either decimal or hexadecimal. A hexadecimal number
1027 must be preceded by @samp{0x}, and is case-insensitive.
1030 Extra options or text at the end of the line are ignored unless otherwise
1034 Unrecognized commands are added to the current entry, except before entries
1035 start, where they are ignored.
1038 These commands can only be used in the menu:
1041 * menuentry:: Start a menu entry
1046 @subsection menuentry
1048 @deffn Command title name @dots{}
1049 Start a new boot entry, and set its name to the contents of the rest of
1050 the line, starting with the first non-space character.
1054 @node General commands
1055 @section The list of general commands
1057 Commands usable anywhere in the menu and in the command-line.
1060 * serial:: Set up a serial device
1061 * terminfo:: Define escape sequences for a terminal
1068 @deffn Command serial [@option{--unit=unit}] [@option{--port=port}] [@option{--speed=speed}] [@option{--word=word}] [@option{--parity=parity}] [@option{--stop=stop}] [@option{--device=dev}]
1069 Initialize a serial device. @var{unit} is a number in the range 0-3
1070 specifying which serial port to use; default is 0, which corresponds to
1071 the port often called COM1. @var{port} is the I/O port where the UART
1072 is to be found; if specified it takes precedence over @var{unit}.
1073 @var{speed} is the transmission speed; default is 9600. @var{word} and
1074 @var{stop} are the number of data bits and stop bits. Data bits must
1075 be in the range 5-8 and stop bits must be 1 or 2. Default is 8 data
1076 bits and one stop bit. @var{parity} is one of @samp{no}, @samp{odd},
1077 @samp{even} and defaults to @samp{no}. The option @option{--device}
1078 can only be used in the grub shell and is used to specify the
1079 tty device to be used in the host operating system (@pxref{Invoking the
1082 The serial port is not used as a communication channel unless the
1083 @command{terminal} command is used (@pxref{terminal}).
1085 This command is only available if GRUB is compiled with serial
1086 support. See also @ref{Serial terminal}.
1091 @subsection terminfo
1093 @deffn Command terminfo @option{--name=name} @option{--cursor-address=seq} [@option{--clear-screen=seq}] [@option{--enter-standout-mode=seq}] [@option{--exit-standout-mode=seq}]
1094 Define the capabilities of your terminal. Use this command to define
1095 escape sequences, if it is not vt100-compatible. You may use @samp{\e}
1096 for @key{ESC} and @samp{^X} for a control character.
1098 You can use the utility @command{grub-terminfo} to generate
1099 appropriate arguments to this command. @xref{Invoking grub-terminfo}.
1101 If no option is specified, the current settings are printed.
1105 @node Command-line and menu entry commands
1106 @section The list of command-line and menu entry commands
1108 These commands are usable in the command-line and in menu entries. If
1109 you forget a command, you can run the command @command{help}
1113 * acpi:: Load ACPI tables
1114 * blocklist:: Print a block list
1115 * boot:: Start up your operating system
1116 * cat:: Show the contents of a file
1117 * chainloader:: Chain-load another boot loader
1118 * cmp:: Compare two files
1119 * configfile:: Load a configuration file
1120 * crc:: Calculate CRC32 checksums
1121 * date:: Display or set current date and time
1122 * echo:: Display a line of text
1123 * export:: Export an environment variable
1124 * halt:: Shut down your computer
1125 * help:: Show help messages
1126 * insmod:: Insert a module
1127 * keystatus:: Check key modifier status
1128 * ls:: List devices or files
1129 * reboot:: Reboot your computer
1130 * set:: Set an environment variable
1131 * unset:: Unset an environment variable
1138 @deffn Command acpi [@option{-1}|@option{-2}] @
1139 [@option{--exclude=table1,@dots{}}|@option{--load-only=table1,@dots{}}] @
1140 [@option{--oemid=id}] [@option{--oemtable=table}] @
1141 [@option{--oemtablerev=rev}] [@option{--oemtablecreator=creator}] @
1142 [@option{--oemtablecreatorrev=rev}] [@option{--no-ebda}] @
1144 Modern BIOS systems normally implement the Advanced Configuration and Power
1145 Interface (ACPI), and define various tables that describe the interface
1146 between an ACPI-compliant operating system and the firmware. In some cases,
1147 the tables provided by default only work well with certain operating
1148 systems, and it may be necessary to replace some of them.
1150 Normally, this command will replace the Root System Description Pointer
1151 (RSDP) in the Extended BIOS Data Area to point to the new tables. If the
1152 @option{--no-ebda} option is used, the new tables will be known only to
1153 GRUB, but may be used by GRUB's EFI emulation.
1158 @subsection blocklist
1160 @deffn Command blocklist file
1161 Print a block list (@pxref{Block list syntax}) for @var{file}.
1169 Boot the OS or chain-loader which has been loaded. Only necessary if
1170 running the fully interactive command-line (it is implicit at the end of
1178 @deffn Command cat file
1179 Display the contents of the file @var{file}. This command may be useful
1180 to remind you of your OS's root partition:
1183 grub> @kbd{cat /etc/fstab}
1189 @subsection chainloader
1191 @deffn Command chainloader [@option{--force}] file
1192 Load @var{file} as a chain-loader. Like any other file loaded by the
1193 filesystem code, it can use the blocklist notation to grab the first
1194 sector of the current partition with @samp{+1}. If you specify the
1195 option @option{--force}, then load @var{file} forcibly, whether it has a
1196 correct signature or not. This is required when you want to load a
1197 defective boot loader, such as SCO UnixWare 7.1 (@pxref{SCO UnixWare}).
1204 @deffn Command cmp file1 file2
1205 Compare the file @var{file1} with the file @var{file2}. If they differ
1206 in size, print the sizes like this:
1209 Differ in size: 0x1234 [foo], 0x4321 [bar]
1212 If the sizes are equal but the bytes at an offset differ, then print the
1216 Differ at the offset 777: 0xbe [foo], 0xef [bar]
1219 If they are completely identical, nothing will be printed.
1224 @subsection configfile
1226 @deffn Command configfile file
1227 Load @var{file} as a configuration file.
1234 @deffn Command crc file
1235 Display the CRC32 checksum of @var{file}.
1242 @deffn Command date [[year-]month-day] [hour:minute[:second]]
1243 With no arguments, print the current date and time.
1245 Otherwise, take the current date and time, change any elements specified as
1246 arguments, and set the result as the new date and time. For example, `date
1247 01-01' will set the current month and day to January 1, but leave the year,
1248 hour, minute, and second unchanged.
1255 @deffn Command echo [@option{-n}] [@option{-e}] string @dots{}
1256 Display the requested text and, unless the @option{-n} option is used, a
1257 trailing new line. If there is more than one string, they are separated by
1258 spaces in the output. As usual in GRUB commands, variables may be
1259 substituted using @samp{$@{var@}}.
1261 The @option{-e} option enables interpretation of backslash escapes. The
1262 following sequences are recognised:
1272 suppress trailing new line
1290 When interpreting backslash escapes, backslash followed by any other
1291 character will print that character.
1298 @deffn Command export envvar
1299 Export the environment variable @var{envvar}. Exported variables are visible
1300 to subsidiary configuration files loaded using @command{configfile}.
1307 @deffn Command halt @option{--no-apm}
1308 The command halts the computer. If the @option{--no-apm} option
1309 is specified, no APM BIOS call is performed. Otherwise, the computer
1310 is shut down using APM.
1317 @deffn Command help @option{--all} [pattern @dots{}]
1318 Display helpful information about builtin commands. If you do not
1319 specify @var{pattern}, this command shows short descriptions of most of
1320 available commands. If you specify the option @option{--all} to this
1321 command, short descriptions of rarely used commands (such as
1322 @ref{testload}) are displayed as well.
1324 If you specify any @var{patterns}, it displays longer information
1325 about each of the commands which match those @var{patterns}.
1332 @deffn Command insmod module
1333 Insert the dynamic GRUB module called @var{module}.
1338 @subsection keystatus
1340 @deffn Command keystatus [@option{--shift}] [@option{--ctrl}] [@option{--alt}]
1341 Return true if the Shift, Control, or Alt modifier keys are held down, as
1342 requested by options. This is useful in scripting, to allow some user
1343 control over behaviour without having to wait for a keypress.
1345 Checking key modifier status is only supported on some platforms. If invoked
1346 without any options, the @command{keystatus} command returns true if and
1347 only if checking key modifier status is supported.
1354 @deffn Command ls [arg]
1355 List devices or files.
1357 With no arguments, print all devices known to GRUB.
1359 If the argument is a device name enclosed in parentheses (@pxref{Device
1360 syntax}), then list all files at the root directory of that device.
1362 If the argument is a directory given as an absolute file name (@pxref{File
1363 name syntax}), then list the contents of that directory.
1370 @deffn Command reboot
1371 Reboot the computer.
1378 @deffn Command set [envvar=value]
1379 Set the environment variable @var{envvar} to @var{value}. If invoked with no
1380 arguments, print all environment variables with their values.
1387 @deffn Command unset envvar
1388 Unset the environment variable @var{envvar}.
1392 @node Invoking grub-install
1393 @chapter Invoking grub-install
1395 The program @command{grub-install} installs GRUB on your drive using the
1396 grub shell (@pxref{Invoking the grub shell}). You must specify the
1397 device name on which you want to install GRUB, like this:
1400 grub-install @var{install_device}
1403 The device name @var{install_device} is an OS device name or a GRUB
1406 @command{grub-install} accepts the following options:
1410 Print a summary of the command-line options and exit.
1413 Print the version number of GRUB and exit.
1415 @item --root-directory=@var{dir}
1416 Install GRUB images under the directory @var{dir} instead of the root
1417 directory. This option is useful when you want to install GRUB into a
1418 separate partition or a removable disk. Here is an example in which
1419 you have a separate @dfn{boot} partition which is mounted on
1423 @kbd{grub-install --root-directory=/boot hd0}
1427 Recheck the device map, even if @file{/boot/grub/device.map} already
1428 exists. You should use this option whenever you add/remove a disk
1429 into/from your computer.
1433 @node Obtaining and Building GRUB
1434 @appendix How to obtain and build GRUB
1437 @strong{Caution:} GRUB requires binutils-2.9.1.0.23 or later because the
1438 GNU assembler has been changed so that it can produce real 16bits
1439 machine code between 2.9.1 and 2.9.1.0.x. See
1440 @uref{http://sources.redhat.com/binutils/}, to obtain information on
1441 how to get the latest version.
1444 GRUB is available from the GNU alpha archive site
1445 @uref{ftp://alpha.gnu.org/gnu/grub} or any of its mirrors. The file
1446 will be named grub-version.tar.gz. The current version is
1447 @value{VERSION}, so the file you should grab is:
1449 @uref{ftp://alpha.gnu.org/gnu/grub/grub-@value{VERSION}.tar.gz}
1451 To unbundle GRUB use the instruction:
1454 @kbd{zcat grub-@value{VERSION}.tar.gz | tar xvf -}
1457 which will create a directory called @file{grub-@value{VERSION}} with
1458 all the sources. You can look at the file @file{INSTALL} for detailed
1459 instructions on how to build and install GRUB, but you should be able to
1464 @kbd{cd grub-@value{VERSION}}
1470 Also, the latest version is available from the SVN. See
1471 @uref{http://savannah.gnu.org/svn/?group=grub} for more information.
1473 @node Reporting bugs
1474 @appendix Reporting bugs
1476 These are the guideline for how to report bugs. Take a look at this
1477 list below before you submit bugs:
1481 Before getting unsettled, read this manual through and through. Also,
1482 see the @uref{http://www.gnu.org/software/grub/grub-faq.html, GNU GRUB FAQ}.
1485 Always mention the information on your GRUB. The version number and the
1486 configuration are quite important. If you build it yourself, write the
1487 options specified to the configure script and your operating system,
1488 including the versions of gcc and binutils.
1491 If you have trouble with the installation, inform us of how you
1492 installed GRUB. Don't omit error messages, if any. Just @samp{GRUB hangs
1493 up when it boots} is not enough.
1495 The information on your hardware is also essential. These are especially
1496 important: the geometries and the partition tables of your hard disk
1497 drives and your BIOS.
1500 If GRUB cannot boot your operating system, write down
1501 @emph{everything} you see on the screen. Don't paraphrase them, like
1502 @samp{The foo OS crashes with GRUB, even though it can boot with the
1503 bar boot loader just fine}. Mention the commands you executed, the
1504 messages printed by them, and information on your operating system
1505 including the version number.
1508 Explain what you wanted to do. It is very useful to know your purpose
1509 and your wish, and how GRUB didn't satisfy you.
1512 If you can investigate the problem yourself, please do. That will give
1513 you and us much more information on the problem. Attaching a patch is
1516 When you attach a patch, make the patch in unified diff format, and
1517 write ChangeLog entries. But, even when you make a patch, don't forget
1518 to explain the problem, so that we can understand what your patch is
1522 Write down anything that you think might be related. Please understand
1523 that we often need to reproduce the same problem you encounterred in our
1524 environment. So your information should be sufficient for us to do the
1525 same thing---Don't forget that we cannot see your computer directly. If
1526 you are not sure whether to state a fact or leave it out, state it!
1527 Reporting too many things is much better than omitting something
1531 If you follow the guideline above, submit a report to the
1532 @uref{http://savannah.gnu.org/bugs/?group=grub, Bug Tracking System}.
1533 Alternatively, you can submit a report via electronic mail to
1534 @email{bug-grub@@gnu.org}, but we strongly recommend that you use the
1535 Bug Tracking System, because e-mail can be passed over easily.
1537 Once we get your report, we will try to fix the bugs.
1541 @appendix Where GRUB will go
1543 We started the next generation of GRUB, GRUB 2. GRUB 2 includes
1544 internationalization, dynamic module loading, real memory management,
1545 multiple architecture support, a scripting language, and many other
1546 nice feature. If you are interested in the development of GRUB 2, take
1547 a look at @uref{http://www.gnu.org/software/grub/grub.html, the
1552 @node Copying This Manual
1553 @appendix Copying This Manual
1556 * GNU Free Documentation License:: License for copying this manual.
1565 @c Currently, we use only the Concept Index.
1573 This is an attempt to make a manual for GRUB 2. The contents are
1574 copied from the GRUB manual in GRUB Legacy, so they are not always
1575 appropriate yet for GRUB 2.