10 @c Unify all our little indices for now.
17 @footnotestyle separate
23 * GRUB: (grub). The GRand Unified Bootloader
24 * grub-install: (grub)Invoking grub-install. Install GRUB on your drive
25 * grub-md5-crypt: (grub)Invoking grub-md5-crypt. Encrypt a password
27 * grub-terminfo: (grub)Invoking grub-terminfo. Generate a terminfo
30 * grub-set-default: (grub)Invoking grub-set-default. Set a default boot
32 * mbchk: (grub)Invoking mbchk. Check for the format of a Multiboot kernel
35 @setchapternewpage odd
38 Copyright @copyright{} 1999,2000,2001,2002,2004 Free Software Foundation, Inc.
40 Permission is granted to make and distribute verbatim copies of
41 this manual provided the copyright notice and this permission notice
42 are preserved on all copies.
45 Permission is granted to process this file through TeX and print the
46 results, provided the printed document carries a copying permission
47 notice identical to this one except for the removal of this paragraph
48 (this paragraph not being relevant to the printed manual).
52 Permission is granted to copy and distribute modified versions of this
53 manual under the conditions for verbatim copying, provided also that
54 the entire resulting derived work is distributed under the terms of a
55 permission notice identical to this one.
57 Permission is granted to copy and distribute translations of this manual
58 into another language, under the above conditions for modified versions.
63 @title the GRUB manual
64 @subtitle The GRand Unified Bootloader, version @value{VERSION}, @value{UPDATED}.
65 @author Gordon Matzigkeit
66 @author Yoshinori K. Okuji
67 @c The following two commands start the copyright page.
69 @vskip 0pt plus 1filll
70 Copyright @copyright{} 1999,2000,2001,2002,2004 Free Software Foundation, Inc.
72 Permission is granted to make and distribute verbatim copies of
73 this manual provided the copyright notice and this permission notice
74 are preserved on all copies.
75 Permission is granted to copy and distribute modified versions of this
76 manual under the conditions for verbatim copying, provided that the entire
77 resulting derived work is distributed under the terms of a permission
78 notice identical to this one.
80 Permission is granted to copy and distribute translations of this manual
81 into another language, under the above conditions for modified versions,
82 except that this permission notice may be stated in a translation approved
83 by Free Software Foundation.
86 @c Output the table of contents at the beginning.
96 This is the documentation of GNU GRUB, the GRand Unified Bootloader,
97 a flexible and powerful boot loader program for @sc{pc}s.
99 This edition documents version @value{VERSION}.
103 * Introduction:: Capturing the spirit of GRUB
104 * Naming convention:: Names of your drives in GRUB
105 * Installation:: Installing GRUB on your drive
106 * Booting:: How to boot different operating systems
107 * Configuration:: Writing your own configuration file
108 * Network:: Downloading OS images from a network
109 * Serial terminal:: Using GRUB via a serial line
110 * Preset Menu:: Embedding a configuration file into GRUB
111 * Security:: Improving the security
112 * Images:: GRUB image files
113 * Filesystem:: Filesystem syntax and semantics
114 * Interface:: The menu and the command-line
115 * Commands:: The list of available builtin commands
116 * Troubleshooting:: Error messages produced by GRUB
117 * Invoking the grub shell:: How to use the grub shell
118 * Invoking grub-install:: How to use the GRUB installer
119 * Invoking grub-md5-crypt:: How to generate a cryptic password
120 * Invoking grub-terminfo:: How to generate a terminfo command
121 * Invoking grub-set-default:: How to set a default boot entry
122 * Invoking mbchk:: How to use the Multiboot checker
123 * Obtaining and Building GRUB:: How to obtain and build GRUB
124 * Reporting bugs:: Where you should send a bug report
125 * Future:: Some future plans on GRUB
126 * Internals:: Hacking GRUB
132 @chapter Introduction to GRUB
135 * Overview:: What exactly GRUB is and how to use it
136 * History:: From maggot to house fly
137 * Features:: GRUB features
138 * Role of a boot loader:: The role of a boot loader
145 Briefly, a @dfn{boot loader} is the first software program that runs when
146 a computer starts. It is responsible for loading and transferring
147 control to an operating system @dfn{kernel} software (such as Linux or
148 GNU Mach). The kernel, in turn, initializes the rest of the operating
149 system (e.g. a GNU system).
151 GNU GRUB is a very powerful boot loader, which can load a wide variety
152 of free operating systems, as well as proprietary operating systems with
153 chain-loading@footnote{@dfn{chain-load} is the mechanism for loading
154 unsupported operating systems by loading another boot loader. It is
155 typically used for loading DOS or Windows.}. GRUB is designed to
156 address the complexity of booting a personal computer; both the
157 program and this manual are tightly bound to that computer platform,
158 although porting to other platforms may be addressed in the future.
160 One of the important features in GRUB is flexibility; GRUB understands
161 filesystems and kernel executable formats, so you can load an arbitrary
162 operating system the way you like, without recording the physical
163 position of your kernel on the disk. Thus you can load the kernel
164 just by specifying its file name and the drive and partition where the
167 When booting with GRUB, you can use either a command-line interface
168 (@pxref{Command-line interface}), or a menu interface (@pxref{Menu
169 interface}). Using the command-line interface, you type the drive
170 specification and file name of the kernel manually. In the menu
171 interface, you just select an OS using the arrow keys. The menu is
172 based on a configuration file which you prepare beforehand
173 (@pxref{Configuration}). While in the menu, you can switch to the
174 command-line mode, and vice-versa. You can even edit menu entries
177 In the following chapters, you will learn how to specify a drive, a
178 partition, and a file name (@pxref{Naming convention}) to GRUB, how to
179 install GRUB on your drive (@pxref{Installation}), and how to boot your
180 OSes (@pxref{Booting}), step by step.
182 Besides the GRUB boot loader itself, there is a @dfn{grub shell}
183 @command{grub} (@pxref{Invoking the grub shell}) which can be run when
184 you are in your operating system. It emulates the boot loader and can
185 be used for installing the boot loader.
189 @section History of GRUB
191 GRUB originated in 1995 when Erich Boleyn was trying to boot the GNU
192 Hurd with the University of Utah's Mach 4 microkernel (now known as GNU
193 Mach). Erich and Brian Ford designed the Multiboot Specification
194 (@pxref{Top, Multiboot Specification, Motivation, multiboot, The Multiboot
195 Specification}), because they were determined not to add to the large
196 number of mutually-incompatible PC boot methods.
198 Erich then began modifying the FreeBSD boot loader so that it would
199 understand Multiboot. He soon realized that it would be a lot easier
200 to write his own boot loader from scratch than to keep working on the
201 FreeBSD boot loader, and so GRUB was born.
203 Erich added many features to GRUB, but other priorities prevented him
204 from keeping up with the demands of its quickly-expanding user base. In
205 1999, Gordon Matzigkeit and Yoshinori K. Okuji adopted GRUB as an
206 official GNU package, and opened its development by making the latest
207 sources available via anonymous CVS. @xref{Obtaining and Building
208 GRUB}, for more information.
212 @section GRUB features
214 The primary requirement for GRUB is that it be compliant with the
215 @dfn{Multiboot Specification}, which is described in @ref{Top, Multiboot
216 Specification, Motivation, multiboot, The Multiboot Specification}.
218 The other goals, listed in approximate order of importance, are:
222 Basic functions must be straightforward for end-users.
225 Rich functionality to support kernel experts and designers.
228 Backward compatibility for booting FreeBSD, NetBSD, OpenBSD, and
229 Linux. Proprietary kernels (such as DOS, Windows NT, and OS/2) are
230 supported via a chain-loading function.
233 Except for specific compatibility modes (chain-loading and the Linux
234 @dfn{piggyback} format), all kernels will be started in much the same
235 state as in the Multiboot Specification. Only kernels loaded at 1 megabyte
236 or above are presently supported. Any attempt to load below that
237 boundary will simply result in immediate failure and an error message
238 reporting the problem.
240 In addition to the requirements above, GRUB has the following features
241 (note that the Multiboot Specification doesn't require all the features
245 @item Recognize multiple executable formats
246 Support many of the @dfn{a.out} variants plus @dfn{ELF}. Symbol
247 tables are also loaded.
249 @item Support non-Multiboot kernels
250 Support many of the various free 32-bit kernels that lack Multiboot
251 compliance (primarily FreeBSD, NetBSD, OpenBSD, and
252 Linux). Chain-loading of other boot loaders is also supported.
254 @item Load multiples modules
255 Fully support the Multiboot feature of loading multiple modules.
257 @item Load a configuration file
258 Support a human-readable text configuration file with preset boot
259 commands. You can also load another configuration file dynamically and
260 embed a preset configuration file in a GRUB image file. The list of
261 commands (@pxref{Commands}) are a superset of those supported on the
262 command-line. An example configuration file is provided in
265 @item Provide a menu interface
266 A menu interface listing preset boot commands, with a programmable
267 timeout, is available. There is no fixed limit on the number of boot
268 entries, and the current implementation has space for several hundred.
270 @item Have a flexible command-line interface
271 A fairly flexible command-line interface, accessible from the menu,
272 is available to edit any preset commands, or write a new boot command
273 set from scratch. If no configuration file is present, GRUB drops to
276 The list of commands (@pxref{Commands}) are a subset of those supported
277 for configuration files. Editing commands closely resembles the Bash
278 command-line (@pxref{Command Line Editing, Bash, Command Line Editing,
279 features, Bash Features}), with @key{TAB}-completion of commands,
280 devices, partitions, and files in a directory depending on context.
282 @item Support multiple filesystem types
283 Support multiple filesystem types transparently, plus a useful explicit
284 blocklist notation. The currently supported filesystem types are
285 @dfn{BSD FFS}, @dfn{DOS FAT16 and FAT32}, @dfn{Minix fs}, @dfn{Linux
286 ext2fs}, @dfn{ReiserFS}, @dfn{JFS}, @dfn{XFS}, and @dfn{VSTa
287 fs}. @xref{Filesystem}, for more information.
289 @item Support automatic decompression
290 Can decompress files which were compressed by @command{gzip}. This
291 function is both automatic and transparent to the user (i.e. all
292 functions operate upon the uncompressed contents of the specified
293 files). This greatly reduces a file size and loading time, a
294 particularly great benefit for floppies.@footnote{There are a few
295 pathological cases where loading a very badly organized ELF kernel might
296 take longer, but in practice this never happen.}
298 It is conceivable that some kernel modules should be loaded in a
299 compressed state, so a different module-loading command can be specified
300 to avoid uncompressing the modules.
302 @item Access data on any installed device
303 Support reading data from any or all floppies or hard disk(s) recognized
304 by the BIOS, independent of the setting of the root device.
306 @item Be independent of drive geometry translations
307 Unlike many other boot loaders, GRUB makes the particular drive
308 translation irrelevant. A drive installed and running with one
309 translation may be converted to another translation without any adverse
310 effects or changes in GRUB's configuration.
312 @item Detect all installed @sc{ram}
313 GRUB can generally find all the installed @sc{ram} on a PC-compatible
314 machine. It uses an advanced BIOS query technique for finding all
315 memory regions. As described on the Multiboot Specification (@pxref{Top,
316 Multiboot Specification, Motivation, multiboot, The Multiboot
317 Specification}), not all kernels make use of this information, but GRUB
318 provides it for those who do.
320 @item Support Logical Block Address mode
321 In traditional disk calls (called @dfn{CHS mode}), there is a geometry
322 translation problem, that is, the BIOS cannot access over 1024
323 cylinders, so the accessible space is limited to at least 508 MB and to
324 at most 8GB. GRUB can't universally solve this problem, as there is no
325 standard interface used in all machines. However, several newer machines
326 have the new interface, Logical Block Address (@dfn{LBA}) mode. GRUB
327 automatically detects if LBA mode is available and uses it if
328 available. In LBA mode, GRUB can access the entire disk.
330 @item Support network booting
331 GRUB is basically a disk-based boot loader but also has network
332 support. You can load OS images from a network by using the @dfn{TFTP}
335 @item Support remote terminals
336 To support computers with no console, GRUB provides remote terminal
337 support, so that you can control GRUB from a remote host. Only serial
338 terminal support is implemented at the moment.
342 @node Role of a boot loader
343 @section The role of a boot loader
345 The following is a quotation from Gordon Matzigkeit, a GRUB fanatic:
348 Some people like to acknowledge both the operating system and kernel when
349 they talk about their computers, so they might say they use
350 ``GNU/Linux'' or ``GNU/Hurd''. Other people seem to think that the
351 kernel is the most important part of the system, so they like to call
352 their GNU operating systems ``Linux systems.''
354 I, personally, believe that this is a grave injustice, because the
355 @emph{boot loader} is the most important software of all. I used to
356 refer to the above systems as either ``LILO''@footnote{The LInux LOader,
357 a boot loader that everybody uses, but nobody likes.} or ``GRUB''
360 Unfortunately, nobody ever understood what I was talking about; now I
361 just use the word ``GNU'' as a pseudonym for GRUB.
363 So, if you ever hear people talking about their alleged ``GNU'' systems,
364 remember that they are actually paying homage to the best boot loader
368 We, the GRUB maintainers, do not (usually) encourage Gordon's level of
369 fanaticism, but it helps to remember that boot loaders deserve
370 recognition. We hope that you enjoy using GNU GRUB as much as we did
374 @node Naming convention
375 @chapter Naming convention
377 The device syntax used in GRUB is a wee bit different from what you may
378 have seen before in your operating system(s), and you need to know it so
379 that you can specify a drive/partition.
381 Look at the following examples and explanations:
387 First of all, GRUB requires that the device name be enclosed with
388 @samp{(} and @samp{)}. The @samp{fd} part means that it is a floppy
389 disk. The number @samp{0} is the drive number, which is counted from
390 @emph{zero}. This expression means that GRUB will use the whole floppy
397 Here, @samp{hd} means it is a hard disk drive. The first integer
398 @samp{0} indicates the drive number, that is, the first hard disk, while
399 the second integer, @samp{1}, indicates the partition number (or the
400 @sc{pc} slice number in the BSD terminology). Once again, please note
401 that the partition numbers are counted from @emph{zero}, not from
402 one. This expression means the second partition of the first hard disk
403 drive. In this case, GRUB uses one partition of the disk, instead of the
410 This specifies the first @dfn{extended partition} of the first hard disk
411 drive. Note that the partition numbers for extended partitions are
412 counted from @samp{4}, regardless of the actual number of primary
413 partitions on your hard disk.
419 This means the BSD @samp{a} partition of the second hard disk. If you
420 need to specify which @sc{pc} slice number should be used, use something
421 like this: @samp{(hd1,0,a)}. If the @sc{pc} slice number is omitted,
422 GRUB searches for the first @sc{pc} slice which has a BSD @samp{a}
425 Of course, to actually access the disks or partitions with GRUB, you
426 need to use the device specification in a command, like @samp{root
427 (fd0)} or @samp{unhide (hd0,2)}. To help you find out which number
428 specifies a partition you want, the GRUB command-line
429 (@pxref{Command-line interface}) options have argument
430 completion. This means that, for example, you only need to type
436 followed by a @key{TAB}, and GRUB will display the list of drives,
437 partitions, or file names. So it should be quite easy to determine the
438 name of your target partition, even with minimal knowledge of the
441 Note that GRUB does @emph{not} distinguish IDE from SCSI - it simply
442 counts the drive numbers from zero, regardless of their type. Normally,
443 any IDE drive number is less than any SCSI drive number, although that
444 is not true if you change the boot sequence by swapping IDE and SCSI
447 Now the question is, how to specify a file? Again, consider an
454 This specifies the file named @samp{vmlinuz}, found on the first
455 partition of the first hard disk drive. Note that the argument
456 completion works with file names, too.
458 That was easy, admit it. Now read the next chapter, to find out how to
459 actually install GRUB on your drive.
463 @chapter Installation
465 In order to install GRUB as your boot loader, you need to first
466 install the GRUB system and utilities under your UNIX-like operating
467 system (@pxref{Obtaining and Building GRUB}). You can do this either
468 from the source tarball, or as a package for your OS.
470 After you have done that, you need to install the boot loader on a
471 drive (floppy or hard disk). There are two ways of doing that - either
472 using the utility @command{grub-install} (@pxref{Invoking
473 grub-install}) on a UNIX-like OS, or by running GRUB itself from a
474 floppy. These are quite similar, however the utility might probe a
475 wrong BIOS drive, so you should be careful.
477 Also, if you install GRUB on a UNIX-like OS, please make sure that you
478 have an emergency boot disk ready, so that you can rescue your computer
479 if, by any chance, your hard drive becomes unusable (unbootable).
481 GRUB comes with boot images, which are normally put in the directory
482 @file{/usr/lib/grub/i386-pc}. If you do not use grub-install, then
483 you need to copy the files @file{stage1}, @file{stage2}, and
484 @file{*stage1_5} to the directory @file{/boot/grub}, and run the
485 @command{grub-set-default} (@pxref{Invoking grub-set-default}) if you
486 intend to use @samp{default saved} (@pxref{default}) in your
487 configuration file. Hereafter, the directory where GRUB images are
488 initially placed (normally @file{/usr/lib/grub/i386-pc}) will be
489 called the @dfn{image directory}, and the directory where the boot
490 loader needs to find them (usually @file{/boot/grub}) will be called
491 the @dfn{boot directory}.
494 * Creating a GRUB boot floppy::
495 * Installing GRUB natively::
496 * Installing GRUB using grub-install::
497 * Making a GRUB bootable CD-ROM::
501 @node Creating a GRUB boot floppy
502 @section Creating a GRUB boot floppy
504 To create a GRUB boot floppy, you need to take the files @file{stage1}
505 and @file{stage2} from the image directory, and write them to the first
506 and the second block of the floppy disk, respectively.
508 @strong{Caution:} This procedure will destroy any data currently stored
511 On a UNIX-like operating system, that is done with the following
516 # @kbd{cd /usr/lib/grub/i386-pc}
517 # @kbd{dd if=stage1 of=/dev/fd0 bs=512 count=1}
520 # @kbd{dd if=stage2 of=/dev/fd0 bs=512 seek=1}
527 The device file name may be different. Consult the manual for your OS.
530 @node Installing GRUB natively
531 @section Installing GRUB natively
533 @strong{Caution:} Installing GRUB's stage1 in this manner will erase the
534 normal boot-sector used by an OS.
536 GRUB can currently boot GNU Mach, Linux, FreeBSD, NetBSD, and OpenBSD
537 directly, so using it on a boot sector (the first sector of a
538 partition) should be okay. But generally, it would be a good idea to
539 back up the first sector of the partition on which you are installing
540 GRUB's stage1. This isn't as important if you are installing GRUB on
541 the first sector of a hard disk, since it's easy to reinitialize it
542 (e.g. by running @samp{FDISK /MBR} from DOS).
544 If you decide to install GRUB in the native environment, which is
545 definitely desirable, you'll need to create a GRUB boot disk, and
546 reboot your computer with it. Otherwise, see @ref{Installing GRUB using
549 Once started, GRUB will show the command-line interface
550 (@pxref{Command-line interface}). First, set the GRUB's @dfn{root
551 device}@footnote{Note that GRUB's root device doesn't necessarily mean
552 your OS's root partition; if you need to specify a root partition for
553 your OS, add the argument into the command @command{kernel}.} to the
554 partition containing the boot directory, like this:
557 grub> @kbd{root (hd0,0)}
560 If you are not sure which partition actually holds this directory, use the
561 command @command{find} (@pxref{find}), like this:
564 grub> @kbd{find /boot/grub/stage1}
567 This will search for the file name @file{/boot/grub/stage1} and show the
568 devices which contain the file.
570 Once you've set the root device correctly, run the command
571 @command{setup} (@pxref{setup}):
574 grub> @kbd{setup (hd0)}
577 This command will install the GRUB boot loader on the Master Boot
578 Record (MBR) of the first drive. If you want to put GRUB into the boot
579 sector of a partition instead of putting it in the MBR, specify the
580 partition into which you want to install GRUB:
583 grub> @kbd{setup (hd0,0)}
586 If you install GRUB into a partition or a drive other than the first
587 one, you must chain-load GRUB from another boot loader. Refer to the
588 manual for the boot loader to know how to chain-load GRUB.
590 After using the setup command, you will boot into GRUB without the
591 GRUB floppy. See the chapter @ref{Booting} to find out how to boot
592 your operating systems from GRUB.
595 @node Installing GRUB using grub-install
596 @section Installing GRUB using grub-install
598 @strong{Caution:} This procedure is definitely less safe, because
599 there are several ways in which your computer can become
600 unbootable. For example, most operating systems don't tell GRUB how to
601 map BIOS drives to OS devices correctly---GRUB merely @dfn{guesses}
602 the mapping. This will succeed in most cases, but not
603 always. Therefore, GRUB provides you with a map file called the
604 @dfn{device map}, which you must fix if it is wrong. @xref{Device
605 map}, for more details.
607 If you still do want to install GRUB under a UNIX-like OS (such
608 as @sc{gnu}), invoke the program @command{grub-install} (@pxref{Invoking
609 grub-install}) as the superuser (@dfn{root}).
611 The usage is basically very simple. You only need to specify one
612 argument to the program, namely, where to install the boot loader. The
613 argument can be either a device file (like @samp{/dev/hda}) or a
614 partition specified in GRUB's notation. For example, under Linux the
615 following will install GRUB into the MBR of the first IDE disk:
618 # @kbd{grub-install /dev/hda}
621 Likewise, under GNU/Hurd, this has the same effect:
624 # @kbd{grub-install /dev/hd0}
627 If it is the first BIOS drive, this is the same as well:
630 # @kbd{grub-install '(hd0)'}
633 Or you can omit the parentheses:
636 # @kbd{grub-install hd0}
639 But all the above examples assume that GRUB should use images under
640 the root directory. If you want GRUB to use images under a directory
641 other than the root directory, you need to specify the option
642 @option{--root-directory}. The typical usage is that you create a GRUB
643 boot floppy with a filesystem. Here is an example:
647 # @kbd{mke2fs /dev/fd0}
648 # @kbd{mount -t ext2 /dev/fd0 /mnt}
649 # @kbd{grub-install --root-directory=/mnt fd0}
654 Another example is when you have a separate boot partition
655 which is mounted at @file{/boot}. Since GRUB is a boot loader, it
656 doesn't know anything about mountpoints at all. Thus, you need to run
657 @command{grub-install} like this:
660 # @kbd{grub-install --root-directory=/boot /dev/hda}
663 By the way, as noted above, it is quite difficult to guess BIOS drives
664 correctly under a UNIX-like OS. Thus, @command{grub-install} will prompt
665 you to check if it could really guess the correct mappings, after the
666 installation. The format is defined in @ref{Device map}. Please be
667 quite careful. If the output is wrong, it is unlikely that your
668 computer will be able to boot with no problem.
670 Note that @command{grub-install} is actually just a shell script and the
671 real task is done by the grub shell @command{grub} (@pxref{Invoking the
672 grub shell}). Therefore, you may run @command{grub} directly to install
673 GRUB, without using @command{grub-install}. Don't do that, however,
674 unless you are very familiar with the internals of GRUB. Installing a
675 boot loader on a running OS may be extremely dangerous.
678 @node Making a GRUB bootable CD-ROM
679 @section Making a GRUB bootable CD-ROM
681 GRUB supports the @dfn{no emulation mode} in the El Torito
682 specification@footnote{El Torito is a specification for bootable CD
683 using BIOS functions.}. This means that you can use the whole CD-ROM
684 from GRUB and you don't have to make a floppy or hard disk image file,
685 which can cause compatibility problems.
687 For booting from a CD-ROM, GRUB uses a special Stage 2 called
688 @file{stage2_eltorito}. The only GRUB files you need to have in your
689 bootable CD-ROM are this @file{stage2_eltorito} and optionally a config file
690 @file{menu.lst}. You don't need to use @file{stage1} or @file{stage2},
691 because El Torito is quite different from the standard boot process.
693 Here is an example of procedures to make a bootable CD-ROM
694 image. First, make a top directory for the bootable image, say,
701 Make a directory for GRUB:
704 $ @kbd{mkdir -p iso/boot/grub}
707 Copy the file @file{stage2_eltorito}:
710 $ @kbd{cp /usr/lib/grub/i386-pc/stage2_eltorito iso/boot/grub}
713 If desired, make the config file @file{menu.lst} under @file{iso/boot/grub}
714 (@pxref{Configuration}), and copy any files and directories for the disc to the
715 directory @file{iso/}.
717 Finally, make a ISO9660 image file like this:
720 $ @kbd{mkisofs -R -b boot/grub/stage2_eltorito -no-emul-boot \
721 -boot-load-size 4 -boot-info-table -o grub.iso iso}
724 This produces a file named @file{grub.iso}, which then can be burned
725 into a CD (or a DVD). @kbd{mkisofs} has already set up the disc to boot
726 from the @kbd{boot/grub/stage2_eltorito} file, so there is no need to
727 setup GRUB on the disc. (Note that the @kbd{-boot-load-size 4} bit is
728 required for compatibility with the BIOS on many older machines.)
730 You can use the device @samp{(cd)} to access a CD-ROM in your
731 config file. This is not required; GRUB automatically sets the root device
732 to @samp{(cd)} when booted from a CD-ROM. It is only necessary to refer to
733 @samp{(cd)} if you want to access other drives as well.
739 GRUB can load Multiboot-compliant kernels in a consistent way,
740 but for some free operating systems you need to use some OS-specific
744 * General boot methods:: How to boot OSes with GRUB generally
745 * OS-specific notes:: Notes on some operating systems
746 * Making your system robust:: How to make your system robust
750 @node General boot methods
751 @section How to boot operating systems
753 GRUB has two distinct boot methods. One of the two is to load an
754 operating system directly, and the other is to chain-load another boot
755 loader which then will load an operating system actually. Generally
756 speaking, the former is more desirable, because you don't need to
757 install or maintain other boot loaders and GRUB is flexible enough to
758 load an operating system from an arbitrary disk/partition. However,
759 the latter is sometimes required, since GRUB doesn't support all the
760 existing operating systems natively.
763 * Loading an operating system directly::
768 @node Loading an operating system directly
769 @subsection How to boot an OS directly with GRUB
771 Multiboot (@pxref{Top, Multiboot Specification, Motivation, multiboot,
772 The Multiboot Specification}) is the native format supported by GRUB.
773 For the sake of convenience, there is also support for Linux, FreeBSD,
774 NetBSD and OpenBSD. If you want to boot other operating systems, you
775 will have to chain-load them (@pxref{Chain-loading}).
777 Generally, GRUB can boot any Multiboot-compliant OS in the following
782 Set GRUB's root device to the drive where the OS images are stored with
783 the command @command{root} (@pxref{root}).
786 Load the kernel image with the command @command{kernel} (@pxref{kernel}).
789 If you need modules, load them with the command @command{module}
790 (@pxref{module}) or @command{modulenounzip} (@pxref{modulenounzip}).
793 Run the command @command{boot} (@pxref{boot}).
796 Linux, FreeBSD, NetBSD and OpenBSD can be booted in a similar
797 manner. You load a kernel image with the command @command{kernel} and
798 then run the command @command{boot}. If the kernel requires some
799 parameters, just append the parameters to @command{kernel}, after the
800 file name of the kernel. Also, please refer to @ref{OS-specific notes},
801 for information on your OS-specific issues.
805 @subsection Load another boot loader to boot unsupported operating systems
807 If you want to boot an unsupported operating system (e.g. Windows 95),
808 chain-load a boot loader for the operating system. Normally, the boot
809 loader is embedded in the @dfn{boot sector} of the partition on which
810 the operating system is installed.
814 Set GRUB's root device to the partition by the command
815 @command{rootnoverify} (@pxref{rootnoverify}):
818 grub> @kbd{rootnoverify (hd0,0)}
822 Set the @dfn{active} flag in the partition using the command
823 @command{makeactive}@footnote{This is not necessary for most of the
824 modern operating systems.} (@pxref{makeactive}):
827 grub> @kbd{makeactive}
831 Load the boot loader with the command @command{chainloader}
832 (@pxref{chainloader}):
835 grub> @kbd{chainloader +1}
838 @samp{+1} indicates that GRUB should read one sector from the start of
839 the partition. The complete description about this syntax can be found
840 in @ref{Block list syntax}.
843 Run the command @command{boot} (@pxref{boot}).
846 However, DOS and Windows have some deficiencies, so you might have to
847 use more complicated instructions. @xref{DOS/Windows}, for more
851 @node OS-specific notes
852 @section Some caveats on OS-specific issues
854 Here, we describe some caveats on several operating systems.
871 Since GNU/Hurd is Multiboot-compliant, it is easy to boot it; there is
872 nothing special about it. But do not forget that you have to specify a
873 root partition to the kernel.
877 Set GRUB's root device to the same drive as GNU/Hurd's. Probably the
878 command @code{find /boot/gnumach} or similar can help you
882 Load the kernel and the module, like this:
886 grub> @kbd{kernel /boot/gnumach root=hd0s1}
887 grub> @kbd{module /boot/serverboot}
892 Run the command @command{boot} (@pxref{boot}).
897 @subsection GNU/Linux
899 It is relatively easy to boot GNU/Linux from GRUB, because it somewhat
900 resembles to boot a Multiboot-compliant OS.
904 Set GRUB's root device to the same drive as GNU/Linux's. Probably the
905 command @code{find /vmlinuz} or similar can help you (@pxref{find}).
911 grub> @kbd{kernel /vmlinuz root=/dev/hda1}
914 If you need to specify some kernel parameters, just append them to the
915 command. For example, to set @option{vga} to @samp{ext}, do this:
918 grub> @kbd{kernel /vmlinuz root=/dev/hda1 vga=ext}
921 See the documentation in the Linux source tree for complete
922 information on the available options.
925 If you use an initrd, execute the command @command{initrd}
926 (@pxref{initrd}) after @command{kernel}:
929 grub> @kbd{initrd /initrd}
933 Finally, run the command @command{boot} (@pxref{boot}).
936 @strong{Caution:} If you use an initrd and specify the @samp{mem=}
937 option to the kernel to let it use less than actual memory size, you
938 will also have to specify the same memory size to GRUB. To let GRUB know
939 the size, run the command @command{uppermem} @emph{before} loading the
940 kernel. @xref{uppermem}, for more information.
946 GRUB can load the kernel directly, either in ELF or a.out format. But
947 this is not recommended, since FreeBSD's bootstrap interface sometimes
948 changes heavily, so GRUB can't guarantee to pass kernel parameters
951 Thus, we'd recommend loading the very flexible loader
952 @file{/boot/loader} instead. See this example:
956 grub> @kbd{root (hd0,a)}
957 grub> @kbd{kernel /boot/loader}
966 GRUB can load NetBSD a.out and ELF directly, follow these steps:
970 Set GRUB's root device with @command{root} (@pxref{root}).
973 Load the kernel with @command{kernel} (@pxref{kernel}). You should
974 append the ugly option @option{--type=netbsd}, if you want to load an
975 ELF kernel, like this:
978 grub> @kbd{kernel --type=netbsd /netbsd-elf}
982 Run @command{boot} (@pxref{boot}).
985 For now, however, GRUB doesn't allow you to pass kernel parameters, so
986 it may be better to chain-load it instead. For more information, please
987 see @ref{Chain-loading}.
993 The booting instruction is exactly the same as for NetBSD
998 @subsection DOS/Windows
1000 GRUB cannot boot DOS or Windows directly, so you must chain-load them
1001 (@pxref{Chain-loading}). However, their boot loaders have some critical
1002 deficiencies, so it may not work to just chain-load them. To overcome
1003 the problems, GRUB provides you with two helper functions.
1005 If you have installed DOS (or Windows) on a non-first hard disk, you
1006 have to use the disk swapping technique, because that OS cannot boot
1007 from any disks but the first one. The workaround used in GRUB is the
1008 command @command{map} (@pxref{map}), like this:
1012 grub> @kbd{map (hd0) (hd1)}
1013 grub> @kbd{map (hd1) (hd0)}
1017 This performs a @dfn{virtual} swap between your first and second hard
1020 @strong{Caution:} This is effective only if DOS (or Windows) uses BIOS
1021 to access the swapped disks. If that OS uses a special driver for the
1022 disks, this probably won't work.
1024 Another problem arises if you installed more than one set of DOS/Windows
1025 onto one disk, because they could be confused if there are more than one
1026 primary partitions for DOS/Windows. Certainly you should avoid doing
1027 this, but there is a solution if you do want to do so. Use the partition
1028 hiding/unhiding technique.
1030 If GRUB @dfn{hide}s a DOS (or Windows) partition (@pxref{hide}), DOS (or
1031 Windows) will ignore the partition. If GRUB @dfn{unhide}s a DOS (or
1032 Windows) partition (@pxref{unhide}), DOS (or Windows) will detect the
1033 partition. Thus, if you have installed DOS (or Windows) on the first
1034 and the second partition of the first hard disk, and you want to boot
1035 the copy on the first partition, do the following:
1039 grub> @kbd{unhide (hd0,0)}
1040 grub> @kbd{hide (hd0,1)}
1041 grub> @kbd{rootnoverify (hd0,0)}
1042 grub> @kbd{chainloader +1}
1043 grub> @kbd{makeactive}
1050 @subsection SCO UnixWare
1052 It is known that the signature in the boot loader for SCO UnixWare is
1053 wrong, so you will have to specify the option @option{--force} to
1054 @command{chainloader} (@pxref{chainloader}), like this:
1058 grub> @kbd{rootnoverify (hd1,0)}
1059 grub> @kbd{chainloader --force +1}
1060 grub> @kbd{makeactive}
1069 QNX seems to use a bigger boot loader, so you need to boot it up, like
1074 grub> @kbd{rootnoverify (hd1,1)}
1075 grub> @kbd{chainloader +4}
1081 @node Making your system robust
1082 @section How to make your system robust
1084 When you test a new kernel or a new OS, it is important to make sure
1085 that your computer can boot even if the new system is unbootable. This
1086 is crucial especially if you maintain servers or remote systems. To
1087 accomplish this goal, you need to set up two things:
1091 You must maintain a system which is always bootable. For instance, if
1092 you test a new kernel, you need to keep a working kernel in a
1093 different place. And, it would sometimes be very nice to even have a
1094 complete copy of a working system in a different partition or disk.
1097 You must direct GRUB to boot a working system when the new system
1098 fails. This is possible with the @dfn{fallback} system in GRUB.
1101 The former requirement is very specific to each OS, so this
1102 documentation does not cover that topic. It is better to consult some
1105 So let's see the GRUB part. There are two possibilities: one of them
1106 is quite simple but not very robust, and the other is a bit complex to
1107 set up but probably the best solution to make sure that your system
1108 can start as long as GRUB itself is bootable.
1111 * Booting once-only::
1112 * Booting fallback systems::
1116 @node Booting once-only
1117 @subsection Booting once-only
1119 You can teach GRUB to boot an entry only at next boot time. Suppose
1120 that your have an old kernel @file{old_kernel} and a new kernel
1121 @file{new_kernel}. You know that @file{old_kernel} can boot
1122 your system correctly, and you want to test @file{new_kernel}.
1124 To ensure that your system will go back to the old kernel even if the
1125 new kernel fails (e.g. it panics), you can specify that GRUB should
1126 try the new kernel only once and boot the old kernel after that.
1128 First, modify your configuration file. Here is an example:
1132 default saved # This is important!!!
1135 title the old kernel
1140 title the new kernel
1143 savedefault 0 # This is important!!!
1147 Note that this configuration file uses @samp{default saved}
1148 (@pxref{default}) at the head and @samp{savedefault 0}
1149 (@pxref{savedefault}) in the entry for the new kernel. This means
1150 that GRUB boots a saved entry by default, and booting the entry for the
1151 new kernel saves @samp{0} as the saved entry.
1153 With this configuration file, after all, GRUB always tries to boot the
1154 old kernel after it booted the new one, because @samp{0} is the entry
1155 of @code{the old kernel}.
1157 The next step is to tell GRUB to boot the new kernel at next boot
1158 time. For this, execute @command{grub-set-default} (@pxref{Invoking
1162 # @kbd{grub-set-default 1}
1165 This command sets the saved entry to @samp{1}, that is, to the new
1168 This method is useful, but still not very robust, because GRUB stops
1169 booting, if there is any error in the boot entry, such that the new
1170 kernel has an invalid executable format. Thus, it it even better to
1171 use the @dfn{fallback} mechanism of GRUB. Look at next subsection for
1175 @node Booting fallback systems
1176 @subsection Booting fallback systems
1178 GRUB supports a fallback mechanism of booting one or more other
1179 entries if a default boot entry fails. You can specify multiple
1180 fallback entries if you wish.
1182 Suppose that you have three systems, @samp{A}, @samp{B} and
1183 @samp{C}. @samp{A} is a system which you want to boot by
1184 default. @samp{B} is a backup system which is supposed to boot
1185 safely. @samp{C} is another backup system which is used in case where
1188 Then you may want GRUB to boot the first system which is bootable
1189 among @samp{A}, @samp{B} and @samp{C}. A configuration file can be
1190 written in this way:
1194 default saved # This is important!!!
1196 fallback 1 2 # This is important!!!
1201 savedefault fallback # This is important!!!
1206 savedefault fallback # This is important!!!
1215 Note that @samp{default saved} (@pxref{default}), @samp{fallback 1 2}
1216 and @samp{savedefault fallback} are used. GRUB will boot a saved entry
1217 by default and save a fallback entry as next boot entry with this
1220 When GRUB tries to boot @samp{A}, GRUB saves @samp{1} as next boot
1221 entry, because the command @command{fallback} specifies that @samp{1}
1222 is the first fallback entry. The entry @samp{1} is @samp{B}, so GRUB
1223 will try to boot @samp{B} at next boot time.
1225 Likewise, when GRUB tries to boot @samp{B}, GRUB saves @samp{2} as
1226 next boot entry, because @command{fallback} specifies @samp{2} as next
1227 fallback entry. This makes sure that GRUB will boot @samp{C} after
1230 It is noteworthy that GRUB uses fallback entries both when GRUB
1231 itself fails in booting an entry and when @samp{A} or @samp{B} fails
1232 in starting up your system. So this solution ensures that your system
1233 is started even if GRUB cannot find your kernel or if your kernel
1236 However, you need to run @command{grub-set-default} (@pxref{Invoking
1237 grub-set-default}) when @samp{A} starts correctly or you fix @samp{A}
1238 after it crashes, since GRUB always sets next boot entry to a fallback
1239 entry. You should run this command in a startup script such as
1240 @file{rc.local} to boot @samp{A} by default:
1243 # @kbd{grub-set-default 0}
1246 where @samp{0} is the number of the boot entry for the system
1249 If you want to see what is current default entry, you can look at the
1250 file @file{/boot/grub/default} (or @file{/grub/default} in
1251 some systems). Because this file is plain-text, you can just
1252 @command{cat} this file. But it is strongly recommended @strong{not to
1253 modify this file directly}, because GRUB may fail in saving a default
1254 entry in this file, if you change this file in an unintended
1255 manner. Therefore, you should use @command{grub-set-default} when you
1256 need to change the default entry.
1260 @chapter Configuration
1262 You've probably noticed that you need to type several commands to boot your
1263 OS. There's a solution to that - GRUB provides a menu interface
1264 (@pxref{Menu interface}) from which you can select an item (using arrow
1265 keys) that will do everything to boot an OS.
1267 To enable the menu, you need a configuration file,
1268 @file{menu.lst} under the boot directory. We'll analyze an example
1271 The file first contains some general settings, the menu interface
1272 related options. You can put these commands (@pxref{Menu-specific
1273 commands}) before any of the items (starting with @command{title}
1279 # Sample boot menu configuration file
1284 As you may have guessed, these lines are comments. Lines starting with a
1285 hash character (@samp{#}), and blank lines, are ignored by GRUB.
1289 # By default, boot the first entry.
1294 The first entry (here, counting starts with number zero, not one!) will
1295 be the default choice.
1299 # Boot automatically after 30 secs.
1304 As the comment says, GRUB will boot automatically in 30 seconds, unless
1305 interrupted with a keypress.
1309 # Fallback to the second entry.
1314 If, for any reason, the default entry doesn't work, fall back to the
1315 second one (this is rarely used, for obvious reasons).
1317 Note that the complete descriptions of these commands, which are menu
1318 interface specific, can be found in @ref{Menu-specific
1319 commands}. Other descriptions can be found in @ref{Commands}.
1321 Now, on to the actual OS definitions. You will see that each entry
1322 begins with a special command, @command{title} (@pxref{title}), and the
1323 action is described after it. Note that there is no command
1324 @command{boot} (@pxref{boot}) at the end of each item. That is because
1325 GRUB automatically executes @command{boot} if it loads other commands
1328 The argument for the command @command{title} is used to display a short
1329 title/description of the entry in the menu. Since @command{title}
1330 displays the argument as is, you can write basically anything there.
1334 # For booting GNU/Hurd
1337 kernel /boot/gnumach.gz root=hd0s1
1338 module /boot/serverboot.gz
1342 This boots GNU/Hurd from the first hard disk.
1346 # For booting GNU/Linux
1348 kernel (hd1,0)/vmlinuz root=/dev/hdb1
1352 This boots GNU/Linux, but from the second hard disk.
1356 # For booting Mach (getting kernel from floppy)
1357 title Utah Mach4 multiboot
1359 pause Insert the diskette now^G!!
1360 kernel (fd0)/boot/kernel root=hd0s3
1361 module (fd0)/boot/bootstrap
1365 This boots Mach with a kernel on a floppy, but the root filesystem at
1366 hd0s3. It also contains a @command{pause} line (@pxref{pause}), which
1367 will cause GRUB to display a prompt and delay, before actually executing
1368 the rest of the commands and booting.
1372 # For booting FreeBSD
1379 This item will boot FreeBSD kernel loaded from the @samp{a} partition of
1380 the third @sc{pc} slice of the first hard disk.
1388 # chainload OS/2 bootloader from the first sector
1390 # This is similar to "chainload", but loads a specific file
1391 #chainloader /boot/chain.os2
1395 This will boot OS/2, using a chain-loader (@pxref{Chain-loading}).
1399 # For booting Windows NT or Windows95
1400 title Windows NT / Windows 95 boot menu
1404 # For loading DOS if Windows NT is installed
1405 # chainload /bootsect.dos
1409 The same as the above, but for Windows.
1413 # For installing GRUB into the hard disk
1414 title Install GRUB into the hard disk
1420 This will just (re)install GRUB onto the hard disk.
1423 # Change the colors.
1424 title Change the colors
1425 color light-green/brown blink-red/blue
1428 In the last entry, the command @command{color} is used (@pxref{color}),
1429 to change the menu colors (try it!). This command is somewhat special,
1430 because it can be used both in the command-line and in the menu. GRUB
1431 has several such commands, see @ref{General commands}.
1433 We hope that you now understand how to use the basic features of
1434 GRUB. To learn more about GRUB, see the following chapters.
1438 @chapter Downloading OS images from a network
1440 Although GRUB is a disk-based boot loader, it does provide network
1441 support. To use the network support, you need to enable at least one
1442 network driver in the GRUB build process. For more information please
1443 see @file{netboot/README.netboot} in the source distribution.
1446 * General usage of network support::
1451 @node General usage of network support
1452 @section How to set up your network
1454 GRUB requires a file server and optionally a server that will assign an
1455 IP address to the machine on which GRUB is running. For the former, only
1456 TFTP is supported at the moment. The latter is either BOOTP, DHCP or a
1457 RARP server@footnote{RARP is not advised, since it cannot serve much
1458 information}. It is not necessary to run both the servers on one
1459 computer. How to configure these servers is beyond the scope of this
1460 document, so please refer to the manuals specific to those
1463 If you decided to use a server to assign an IP address, set up the
1464 server and run @command{bootp} (@pxref{bootp}), @command{dhcp}
1465 (@pxref{dhcp}) or @command{rarp} (@pxref{rarp}) for BOOTP, DHCP or RARP,
1466 respectively. Each command will show an assigned IP address, a netmask,
1467 an IP address for your TFTP server and a gateway. If any of the
1468 addresses is wrong or it causes an error, probably the configuration of
1469 your servers isn't set up properly.
1471 Otherwise, run @command{ifconfig}, like this:
1474 grub> @kbd{ifconfig --address=192.168.110.23 --server=192.168.110.14}
1477 You can also use @command{ifconfig} in conjuction with @command{bootp},
1478 @command{dhcp} or @command{rarp} (e.g. to reassign the server address
1479 manually). @xref{ifconfig}, for more details.
1481 Finally, download your OS images from your network. The network can be
1482 accessed using the network drive @samp{(nd)}. Everything else is very
1483 similar to the normal instructions (@pxref{Booting}).
1492 Address: 192.168.110.23 Netmask: 255.255.255.0
1493 Server: 192.168.110.14 Gateway: 192.168.110.1
1495 grub> @kbd{root (nd)}
1496 grub> @kbd{kernel /tftproot/gnumach.gz root=sd0s1}
1497 grub> @kbd{module /tftproot/serverboot.gz}
1504 @section Booting from a network
1506 It is sometimes very useful to boot from a network, especially when you
1507 use a machine which has no local disk. In this case, you need to obtain
1508 a kind of Net Boot @sc{rom}, such as a PXE @sc{rom} or a free software
1509 package like Etherboot. Such a Boot @sc{rom} first boots the machine,
1510 sets up the network card installed into the machine, and downloads a
1511 second stage boot image from the network. Then, the second image will
1512 try to boot an operating system actually from the network.
1514 GRUB provides two second stage images, @file{nbgrub} and
1515 @file{pxegrub} (@pxref{Images}). These images are the same as the
1516 normal Stage 2, except that they set up a network automatically, and try
1517 to load a configuration file from the network, if specified. The usage
1518 is very simple: If the machine has a PXE @sc{rom}, use
1519 @file{pxegrub}. If the machine has an NBI loader such as Etherboot, use
1520 @file{nbgrub}. There is no difference between them except their
1521 formats. Since the way to load a second stage image you want to use
1522 should be described in the manual on your Net Boot @sc{rom}, please
1523 refer to the manual, for more information.
1525 However, there is one thing specific to GRUB. Namely, how to specify a
1526 configuration file in a BOOTP/DHCP server. For now, GRUB uses the tag
1527 @samp{150}, to get the name of a configuration file. The following is an
1528 example with a BOOTP configuration:
1532 .allhost:hd=/tmp:bf=null:\
1533 :ds=145.71.35.1 145.71.32.1:\
1538 foo:ht=1:ha=63655d0334a7:ip=145.71.35.127:\
1541 :T150="(nd)/tftpboot/menu.lst.foo":
1545 Note that you should specify the drive name @code{(nd)} in the name of
1546 the configuration file. This is because you might change the root drive
1547 before downloading the configuration from the TFTP server when the
1548 preset menu feature is used (@pxref{Preset Menu}).
1550 See the manual of your BOOTP/DHCP server for more information. The
1551 exact syntax should differ a little from the example.
1554 @node Serial terminal
1555 @chapter Using GRUB via a serial line
1557 This chapter describes how to use the serial terminal support in GRUB.
1559 If you have many computers or computers with no display/keyboard, it
1560 could be very useful to control the computers through serial
1561 communications. To connect one computer with another via a serial line,
1562 you need to prepare a null-modem (cross) serial cable, and you may need
1563 to have multiport serial boards, if your computer doesn't have extra
1564 serial ports. In addition, a terminal emulator is also required, such as
1565 minicom. Refer to a manual of your operating system, for more
1568 As for GRUB, the instruction to set up a serial terminal is quite
1569 simple. First of all, make sure that you haven't specified the option
1570 @option{--disable-serial} to the configure script when you built your
1571 GRUB images. If you get them in binary form, probably they have serial
1572 terminal support already.
1574 Then, initialize your serial terminal after GRUB starts up. Here is an
1579 grub> @kbd{serial --unit=0 --speed=9600}
1580 grub> @kbd{terminal serial}
1584 The command @command{serial} initializes the serial unit 0 with the
1585 speed 9600bps. The serial unit 0 is usually called @samp{COM1}, so, if
1586 you want to use COM2, you must specify @samp{--unit=1} instead. This
1587 command accepts many other options, so please refer to @ref{serial},
1590 The command @command{terminal} (@pxref{terminal}) chooses which type of
1591 terminal you want to use. In the case above, the terminal will be a
1592 serial terminal, but you can also pass @code{console} to the command,
1593 as @samp{terminal serial console}. In this case, a terminal in which
1594 you press any key will be selected as a GRUB terminal.
1596 However, note that GRUB assumes that your terminal emulator is
1597 compatible with VT100 by default. This is true for most terminal
1598 emulators nowadays, but you should pass the option @option{--dumb} to
1599 the command if your terminal emulator is not VT100-compatible or
1600 implements few VT100 escape sequences. If you specify this option then
1601 GRUB provides you with an alternative menu interface, because the normal
1602 menu requires several fancy features of your terminal.
1606 @chapter Embedding a configuration file into GRUB
1608 GRUB supports a @dfn{preset menu} which is to be always loaded before
1609 starting. The preset menu feature is useful, for example, when your
1610 computer has no console but a serial cable. In this case, it is
1611 critical to set up the serial terminal as soon as possible, since you
1612 cannot see any message until the serial terminal begins to work. So it
1613 is good to run the commands @command{serial} (@pxref{serial}) and
1614 @command{terminal} (@pxref{terminal}) before anything else at the
1617 How the preset menu works is slightly complicated:
1621 GRUB checks if the preset menu feature is used, and loads the preset
1622 menu, if available. This includes running commands and reading boot
1623 entries, like an ordinary configuration file.
1626 GRUB checks if the configuration file is available. Note that this check
1627 is performed @strong{regardless of the existence of the preset
1628 menu}. The configuration file is loaded even if the preset menu was
1632 If the preset menu includes any boot entries, they are cleared when
1633 the configuration file is loaded. It doesn't matter whether the
1634 configuration file has any entries or no entry. The boot entries in the
1635 preset menu are used only when GRUB fails in loading the configuration
1639 To enable the preset menu feature, you must rebuild GRUB specifying a
1640 file to the configure script with the option
1641 @option{--enable-preset-menu}. The file has the same semantics as
1642 normal configuration files (@pxref{Configuration}).
1644 Another point you should take care is that the diskless support
1645 (@pxref{Diskless}) diverts the preset menu. Diskless images embed a
1646 preset menu to execute the command @command{bootp} (@pxref{bootp})
1647 automatically, unless you specify your own preset menu to the configure
1648 script. This means that you must put commands to initialize a network in
1649 the preset menu yourself, because diskless images don't set it up
1650 implicitly, when you use the preset menu explicitly.
1652 Therefore, a typical preset menu used with diskless support would be
1657 # Set up the serial terminal, first of all.
1658 serial --unit=0 --speed=19200
1659 terminal --timeout=0 serial
1661 # Initialize the network.
1668 @chapter Protecting your computer from cracking
1670 You may be interested in how to prevent ordinary users from doing
1671 whatever they like, if you share your computer with other people. So
1672 this chapter describes how to improve the security of GRUB.
1674 One thing which could be a security hole is that the user can do too
1675 many things with GRUB, because GRUB allows one to modify its configuration
1676 and run arbitrary commands at run-time. For example, the user can even
1677 read @file{/etc/passwd} in the command-line interface by the command
1678 @command{cat} (@pxref{cat}). So it is necessary to disable all the
1679 interactive operations.
1681 Thus, GRUB provides a @dfn{password} feature, so that only administrators
1682 can start the interactive operations (i.e. editing menu entries and
1683 entering the command-line interface). To use this feature, you need to
1684 run the command @command{password} in your configuration file
1685 (@pxref{password}), like this:
1688 password --md5 PASSWORD
1691 If this is specified, GRUB disallows any interactive control, until you
1692 press the key @key{p} and enter a correct password. The option
1693 @option{--md5} tells GRUB that @samp{PASSWORD} is in MD5 format. If it
1694 is omitted, GRUB assumes the @samp{PASSWORD} is in clear text.
1696 You can encrypt your password with the command @command{md5crypt}
1697 (@pxref{md5crypt}). For example, run the grub shell (@pxref{Invoking the
1698 grub shell}), and enter your password:
1703 Password: **********
1704 Encrypted: $1$U$JK7xFegdxWH6VuppCUSIb.
1708 Then, cut and paste the encrypted password to your configuration file.
1710 Also, you can specify an optional argument to @command{password}. See
1714 password PASSWORD /boot/grub/menu-admin.lst
1717 In this case, GRUB will load @file{/boot/grub/menu-admin.lst} as a
1718 configuration file when you enter the valid password.
1720 Another thing which may be dangerous is that any user can choose any
1721 menu entry. Usually, this wouldn't be problematic, but you might want to
1722 permit only administrators to run some of your menu entries, such as an
1723 entry for booting an insecure OS like DOS.
1725 GRUB provides the command @command{lock} (@pxref{lock}). This command
1726 always fails until you enter the valid password, so you can use it, like
1733 rootnoverify (hd0,1)
1739 You should insert @command{lock} right after @command{title}, because
1740 any user can execute commands in an entry until GRUB encounters
1743 You can also use the command @command{password} instead of
1744 @command{lock}. In this case the boot process will ask for the password
1745 and stop if it was entered incorrectly. Since the @command{password}
1746 takes its own @var{PASSWORD} argument this is useful if you want
1747 different passwords for different entries.
1751 @chapter GRUB image files
1753 GRUB consists of several images: two essential stages, optional stages
1754 called @dfn{Stage 1.5}, one image for bootable CD-ROM, and two network
1755 boot images. Here is a short overview of them. @xref{Internals}, for
1760 This is an essential image used for booting up GRUB. Usually, this is
1761 embedded in an MBR or the boot sector of a partition. Because a PC boot
1762 sector is 512 bytes, the size of this image is exactly 512 bytes.
1764 All @file{stage1} must do is to load Stage 2 or Stage 1.5 from a local
1765 disk. Because of the size restriction, @file{stage1} encodes the
1766 location of Stage 2 (or Stage 1.5) in a block list format, so it never
1767 understand any filesystem structure.
1770 This is the core image of GRUB. It does everything but booting up
1771 itself. Usually, this is put in a filesystem, but that is not required.
1777 @itemx minix_stage1_5
1778 @itemx reiserfs_stage1_5
1779 @itemx vstafs_stage1_5
1782 These are called @dfn{Stage 1.5}, because they serve as a bridge
1783 between @file{stage1} and @file{stage2}, that is to say, Stage 1.5 is
1784 loaded by Stage 1 and Stage 1.5 loads Stage 2. The difference between
1785 @file{stage1} and @file{*_stage1_5} is that the former doesn't
1786 understand any filesystem while the latter understands one filesystem
1787 (e.g. @file{e2fs_stage1_5} understands ext2fs). So you can move the
1788 Stage 2 image to another location safely, even after GRUB has been
1791 While Stage 2 cannot generally be embedded in a fixed area as the size
1792 is so large, Stage 1.5 can be installed into the area right after an MBR,
1793 or the boot loader area of a ReiserFS or a FFS.
1795 @item stage2_eltorito
1796 This is a boot image for CD-ROMs using the @dfn{no emulation mode} in
1797 El Torito specification. This is identical to Stage 2, except that
1798 this boots up without Stage 1 and sets up a special drive @samp{(cd)}.
1801 This is a network boot image for the Network Image Proposal used by some
1802 network boot loaders, such as Etherboot. This is mostly the same as
1803 Stage 2, but it also sets up a network and loads a configuration file
1807 This is another network boot image for the Preboot Execution Environment
1808 used by several Netboot ROMs. This is identical to @file{nbgrub}, except
1814 @chapter Filesystem syntax and semantics
1816 GRUB uses a special syntax for specifying disk drives which can be
1817 accessed by BIOS. Because of BIOS limitations, GRUB cannot distinguish
1818 between IDE, ESDI, SCSI, or others. You must know yourself which BIOS
1819 device is equivalent to which OS device. Normally, that will be clear if
1820 you see the files in a device or use the command @command{find}
1824 * Device syntax:: How to specify devices
1825 * File name syntax:: How to specify files
1826 * Block list syntax:: How to specify block lists
1831 @section How to specify devices
1833 The device syntax is like this:
1836 @code{(@var{device}[,@var{part-num}][,@var{bsd-subpart-letter}])}
1839 @samp{[]} means the parameter is optional. @var{device} should be
1840 either @samp{fd} or @samp{hd} followed by a digit, like @samp{fd0}.
1841 But you can also set @var{device} to a hexadecimal or a decimal number
1842 which is a BIOS drive number, so the following are equivalent:
1850 @var{part-num} represents the partition number of @var{device}, starting
1851 from zero for primary partitions and from four for extended partitions,
1852 and @var{bsd-subpart-letter} represents the BSD disklabel subpartition,
1853 such as @samp{a} or @samp{e}.
1855 A shortcut for specifying BSD subpartitions is
1856 @code{(@var{device},@var{bsd-subpart-letter})}, in this case, GRUB
1857 searches for the first PC partition containing a BSD disklabel, then
1858 finds the subpartition @var{bsd-subpart-letter}. Here is an example:
1864 The syntax @samp{(hd0)} represents using the entire disk (or the
1865 MBR when installing GRUB), while the syntax @samp{(hd0,0)}
1866 represents using the first partition of the disk (or the boot sector
1867 of the partition when installing GRUB).
1869 If you enabled the network support, the special drive, @samp{(nd)}, is
1870 also available. Before using the network drive, you must initialize the
1871 network. @xref{Network}, for more information.
1873 If you boot GRUB from a CD-ROM, @samp{(cd)} is available. @xref{Making
1874 a GRUB bootable CD-ROM}, for details.
1877 @node File name syntax
1878 @section How to specify files
1880 There are two ways to specify files, by @dfn{absolute file name} and by
1883 An absolute file name resembles a Unix absolute file name, using
1884 @samp{/} for the directory separator (not @samp{\} as in DOS). One
1885 example is @samp{(hd0,0)/boot/grub/menu.lst}. This means the file
1886 @file{/boot/grub/menu.lst} in the first partition of the first hard
1887 disk. If you omit the device name in an absolute file name, GRUB uses
1888 GRUB's @dfn{root device} implicitly. So if you set the root device to,
1889 say, @samp{(hd1,0)} by the command @command{root} (@pxref{root}), then
1890 @code{/boot/kernel} is the same as @code{(hd1,0)/boot/kernel}.
1893 @node Block list syntax
1894 @section How to specify block lists
1896 A block list is used for specifying a file that doesn't appear in the
1897 filesystem, like a chainloader. The syntax is
1898 @code{[@var{offset}]+@var{length}[,[@var{offset}]+@var{length}]@dots{}}.
1902 @code{0+100,200+1,300+300}
1905 This represents that GRUB should read blocks 0 through 99, block 200,
1906 and blocks 300 through 599. If you omit an offset, then GRUB assumes
1909 Like the file name syntax (@pxref{File name syntax}), if a blocklist
1910 does not contain a device name, then GRUB uses GRUB's @dfn{root
1911 device}. So @code{(hd0,1)+1} is the same as @code{+1} when the root
1912 device is @samp{(hd0,1)}.
1916 @chapter GRUB's user interface
1918 GRUB has both a simple menu interface for choosing preset entries from a
1919 configuration file, and a highly flexible command-line for performing
1920 any desired combination of boot commands.
1922 GRUB looks for its configuration file as soon as it is loaded. If one
1923 is found, then the full menu interface is activated using whatever
1924 entries were found in the file. If you choose the @dfn{command-line} menu
1925 option, or if the configuration file was not found, then GRUB drops to
1926 the command-line interface.
1929 * Command-line interface:: The flexible command-line interface
1930 * Menu interface:: The simple menu interface
1931 * Menu entry editor:: Editing a menu entry
1932 * Hidden menu interface:: The hidden menu interface
1936 @node Command-line interface
1937 @section The flexible command-line interface
1939 The command-line interface provides a prompt and after it an editable
1940 text area much like a command-line in Unix or DOS. Each command is
1941 immediately executed after it is entered@footnote{However, this
1942 behavior will be changed in the future version, in a user-invisible
1943 way.}. The commands (@pxref{Command-line and menu entry commands}) are a
1944 subset of those available in the configuration file, used with exactly
1947 Cursor movement and editing of the text on the line can be done via a
1948 subset of the functions available in the Bash shell:
1953 Move forward one character.
1957 Move back one character.
1961 Move to the start of the line.
1965 Move the the end of the line.
1969 Delete the character underneath the cursor.
1973 Delete the character to the left of the cursor.
1976 Kill the text from the current cursor position to the end of the line.
1979 Kill backward from the cursor to the beginning of the line.
1982 Yank the killed text back into the buffer at the cursor.
1986 Move up through the history list.
1990 Move down through the history list.
1993 When typing commands interactively, if the cursor is within or before
1994 the first word in the command-line, pressing the @key{TAB} key (or
1995 @key{C-i}) will display a listing of the available commands, and if the
1996 cursor is after the first word, the @kbd{@key{TAB}} will provide a
1997 completion listing of disks, partitions, and file names depending on the
1998 context. Note that to obtain a list of drives, one must open a
1999 parenthesis, as @command{root (}.
2001 Note that you cannot use the completion functionality in the TFTP
2002 filesystem. This is because TFTP doesn't support file name listing for
2006 @node Menu interface
2007 @section The simple menu interface
2009 The menu interface is quite easy to use. Its commands are both
2010 reasonably intuitive and described on screen.
2012 Basically, the menu interface provides a list of @dfn{boot entries} to
2013 the user to choose from. Use the arrow keys to select the entry of
2014 choice, then press @key{RET} to run it. An optional timeout is
2015 available to boot the default entry (the first one if not set), which is
2016 aborted by pressing any key.
2018 Commands are available to enter a bare command-line by pressing @key{c}
2019 (which operates exactly like the non-config-file version of GRUB, but
2020 allows one to return to the menu if desired by pressing @key{ESC}) or to
2021 edit any of the @dfn{boot entries} by pressing @key{e}.
2023 If you protect the menu interface with a password (@pxref{Security}),
2024 all you can do is choose an entry by pressing @key{RET}, or press
2025 @key{p} to enter the password.
2028 @node Menu entry editor
2029 @section Editing a menu entry
2031 The menu entry editor looks much like the main menu interface, but the
2032 lines in the menu are individual commands in the selected entry instead
2035 If an @key{ESC} is pressed in the editor, it aborts all the changes made
2036 to the configuration entry and returns to the main menu interface.
2038 When a particular line is selected, the editor places the user in a
2039 special version of the GRUB command-line to edit that line. When the
2040 user hits @key{RET}, GRUB replaces the line in question in the boot
2041 entry with the changes (unless it was aborted via @key{ESC},
2042 in which case the changes are thrown away).
2044 If you want to add a new line to the menu entry, press @key{o} if adding
2045 a line after the current line or press @key{O} if before the current
2048 To delete a line, hit the key @key{d}. Although GRUB unfortunately
2049 does not support @dfn{undo}, you can do almost the same thing by just
2050 returning to the main menu.
2053 @node Hidden menu interface
2054 @section The hidden menu interface
2056 When your terminal is dumb or you request GRUB to hide the menu
2057 interface explicitly with the command @command{hiddenmenu}
2058 (@pxref{hiddenmenu}), GRUB doesn't show the menu interface (@pxref{Menu
2059 interface}) and automatically boots the default entry, unless
2060 interrupted by pressing @key{ESC}.
2062 When you interrupt the timeout and your terminal is dumb, GRUB falls
2063 back to the command-line interface (@pxref{Command-line interface}).
2067 @chapter The list of available commands
2069 In this chapter, we list all commands that are available in GRUB.
2071 Commands belong to different groups. A few can only be used in
2072 the global section of the configuration file (or ``menu''); most
2073 of them can be entered on the command-line and can be used either
2074 anywhere in the menu or specifically in the menu entries.
2077 * Menu-specific commands::
2078 * General commands::
2079 * Command-line and menu entry commands::
2083 @node Menu-specific commands
2084 @section The list of commands for the menu only
2086 The semantics used in parsing the configuration file are the following:
2090 The menu-specific commands have to be used before any others.
2093 The files @emph{must} be in plain-text format.
2096 @samp{#} at the beginning of a line in a configuration file means it is
2100 Options are separated by spaces.
2103 All numbers can be either decimal or hexadecimal. A hexadecimal number
2104 must be preceded by @samp{0x}, and is case-insensitive.
2107 Extra options or text at the end of the line are ignored unless otherwise
2111 Unrecognized commands are added to the current entry, except before entries
2112 start, where they are ignored.
2115 These commands can only be used in the menu:
2118 * default:: Set the default entry
2119 * fallback:: Set the fallback entry
2120 * hiddenmenu:: Hide the menu interface
2121 * timeout:: Set the timeout
2122 * title:: Start a menu entry
2129 @deffn Command default num
2130 Set the default entry to the entry number @var{num}. Numbering starts
2131 from 0, and the entry number 0 is the default if the command is not
2134 You can specify @samp{saved} instead of a number. In this case, the
2135 default entry is the entry saved with the command
2136 @command{savedefault}. @xref{savedefault}, for more information.
2141 @subsection fallback
2143 @deffn Command fallback num...
2144 Go into unattended boot mode: if the default boot entry has any errors,
2145 instead of waiting for the user to do something, immediately start
2146 over using the @var{num} entry (same numbering as the @code{default}
2147 command (@pxref{default})). This obviously won't help if the machine was
2148 rebooted by a kernel that GRUB loaded. You can specify multiple
2149 fallback entry numbers.
2154 @subsection hiddenmenu
2156 @deffn Command hiddenmenu
2157 Don't display the menu. If the command is used, no menu will be
2158 displayed on the control terminal, and the default entry will be
2159 booted after the timeout expired. The user can still request the
2160 menu to be displayed by pressing @key{ESC} before the timeout
2161 expires. See also @ref{Hidden menu interface}.
2168 @deffn Command timeout sec
2169 Set a timeout, in @var{sec} seconds, before automatically booting the
2170 default entry (normally the first entry defined).
2177 @deffn Command title name @dots{}
2178 Start a new boot entry, and set its name to the contents of the rest of
2179 the line, starting with the first non-space character.
2183 @node General commands
2184 @section The list of general commands
2186 Commands usable anywhere in the menu and in the command-line.
2189 * bootp:: Initialize a network device via BOOTP
2190 * color:: Color the menu interface
2191 * device:: Specify a file as a drive
2192 * dhcp:: Initialize a network device via DHCP
2193 * hide:: Hide a partition
2194 * ifconfig:: Configure a network device manually
2195 * pager:: Change the state of the internal pager
2196 * partnew:: Make a primary partition
2197 * parttype:: Change the type of a partition
2198 * password:: Set a password for the menu interface
2199 * rarp:: Initialize a network device via RARP
2200 * serial:: Set up a serial device
2201 * setkey:: Configure the key map
2202 * terminal:: Choose a terminal
2203 * terminfo:: Define escape sequences for a terminal
2204 * tftpserver:: Specify a TFTP server
2205 * unhide:: Unhide a partition
2212 @deffn Command bootp [@option{--with-configfile}]
2213 Initialize a network device via the @dfn{BOOTP} protocol. This command
2214 is only available if GRUB is compiled with netboot support. See also
2217 If you specify @option{--with-configfile} to this command, GRUB will
2218 fetch and load a configuration file specified by your BOOTP server
2219 with the vendor tag @samp{150}.
2226 @deffn Command color normal [highlight]
2227 Change the menu colors. The color @var{normal} is used for most
2228 lines in the menu (@pxref{Menu interface}), and the color
2229 @var{highlight} is used to highlight the line where the cursor
2230 points. If you omit @var{highlight}, then the inverted color of
2231 @var{normal} is used for the highlighted line. The format of a color is
2232 @code{@var{foreground}/@var{background}}. @var{foreground} and
2233 @var{background} are symbolic color names. A symbolic color name must be
2261 @strong{These below can be specified only for the foreground.}
2288 But only the first eight names can be used for @var{background}. You can
2289 prefix @code{blink-} to @var{foreground} if you want a blinking
2292 This command can be used in the configuration file and on the command
2293 line, so you may write something like this in your configuration file:
2297 # Set default colors.
2298 color light-gray/blue black/light-gray
2300 # Change the colors.
2302 color magenta/blue black/magenta
2311 @deffn Command device drive file
2312 In the grub shell, specify the file @var{file} as the actual drive for a
2313 @sc{bios} drive @var{drive}. You can use this command to create a disk
2314 image, and/or to fix the drives guessed by GRUB when GRUB fails to
2315 determine them correctly, like this:
2319 grub> @kbd{device (fd0) /floppy-image}
2320 grub> @kbd{device (hd0) /dev/sd0}
2324 This command can be used only in the grub shell (@pxref{Invoking the
2332 @deffn Command dhcp [--with-configfile]
2333 Initialize a network device via the @dfn{DHCP} protocol. Currently,
2334 this command is just an alias for @command{bootp}, since the two
2335 protocols are very similar. This command is only available if GRUB is
2336 compiled with netboot support. See also @ref{Network}.
2338 If you specify @option{--with-configfile} to this command, GRUB will
2339 fetch and load a configuration file specified by your DHCP server
2340 with the vendor tag @samp{150}.
2347 @deffn Command hide partition
2348 Hide the partition @var{partition} by setting the @dfn{hidden} bit in
2349 its partition type code. This is useful only when booting DOS or Windows
2350 and multiple primary FAT partitions exist in one disk. See also
2356 @subsection ifconfig
2358 @deffn Command ifconfig [@option{--server=server}] [@option{--gateway=gateway}] [@option{--mask=mask}] [@option{--address=address}]
2359 Configure the IP address, the netmask, the gateway, and the server
2360 address of a network device manually. The values must be in dotted
2361 decimal format, like @samp{192.168.11.178}. The order of the options is
2362 not important. This command shows current network configuration, if no
2363 option is specified. See also @ref{Network}.
2370 @deffn Command pager [flag]
2371 Toggle or set the state of the internal pager. If @var{flag} is
2372 @samp{on}, the internal pager is enabled. If @var{flag} is @samp{off},
2373 it is disabled. If no argument is given, the state is toggled.
2380 @deffn Command partnew part type from len
2381 Create a new primary partition. @var{part} is a partition specification
2382 in GRUB syntax (@pxref{Naming convention}); @var{type} is the partition
2383 type and must be a number in the range @code{0-0xff}; @var{from} is
2384 the starting address and @var{len} is the length, both in sector units.
2389 @subsection parttype
2391 @deffn Command parttype part type
2392 Change the type of an existing partition. @var{part} is a partition
2393 specification in GRUB syntax (@pxref{Naming convention}); @var{type}
2394 is the new partition type and must be a number in the range 0-0xff.
2399 @subsection password
2401 @deffn Command password [@option{--md5}] passwd [new-config-file]
2402 If used in the first section of a menu file, disable all interactive
2403 editing control (menu entry editor and command-line) and entries
2404 protected by the command @command{lock}. If the password @var{passwd} is
2405 entered, it loads the @var{new-config-file} as a new config file and
2406 restarts the GRUB Stage 2, if @var{new-config-file} is
2407 specified. Otherwise, GRUB will just unlock the privileged instructions.
2408 You can also use this command in the script section, in which case it
2409 will ask for the password, before continuing. The option
2410 @option{--md5} tells GRUB that @var{passwd} is encrypted with
2411 @command{md5crypt} (@pxref{md5crypt}).
2419 Initialize a network device via the @dfn{RARP} protocol. This command
2420 is only available if GRUB is compiled with netboot support. See also
2428 @deffn Command serial [@option{--unit=unit}] [@option{--port=port}] [@option{--speed=speed}] [@option{--word=word}] [@option{--parity=parity}] [@option{--stop=stop}] [@option{--device=dev}]
2429 Initialize a serial device. @var{unit} is a number in the range 0-3
2430 specifying which serial port to use; default is 0, which corresponds to
2431 the port often called COM1. @var{port} is the I/O port where the UART
2432 is to be found; if specified it takes precedence over @var{unit}.
2433 @var{speed} is the transmission speed; default is 9600. @var{word} and
2434 @var{stop} are the number of data bits and stop bits. Data bits must
2435 be in the range 5-8 and stop bits must be 1 or 2. Default is 8 data
2436 bits and one stop bit. @var{parity} is one of @samp{no}, @samp{odd},
2437 @samp{even} and defaults to @samp{no}. The option @option{--device}
2438 can only be used in the grub shell and is used to specify the
2439 tty device to be used in the host operating system (@pxref{Invoking the
2442 The serial port is not used as a communication channel unless the
2443 @command{terminal} command is used (@pxref{terminal}).
2445 This command is only available if GRUB is compiled with serial
2446 support. See also @ref{Serial terminal}.
2453 @deffn Command setkey [to_key from_key]
2454 Change the keyboard map. The key @var{from_key} is mapped to the key
2455 @var{to_key}. If no argument is specified, reset key mappings. Note that
2456 this command @emph{does not} exchange the keys. If you want to exchange
2457 the keys, run this command again with the arguments exchanged, like this:
2460 grub> @kbd{setkey capslock control}
2461 grub> @kbd{setkey control capslock}
2464 A key must be an alphabet letter, a digit, or one of these symbols:
2465 @samp{escape}, @samp{exclam}, @samp{at}, @samp{numbersign},
2466 @samp{dollar}, @samp{percent}, @samp{caret}, @samp{ampersand},
2467 @samp{asterisk}, @samp{parenleft}, @samp{parenright}, @samp{minus},
2468 @samp{underscore}, @samp{equal}, @samp{plus}, @samp{backspace},
2469 @samp{tab}, @samp{bracketleft}, @samp{braceleft}, @samp{bracketright},
2470 @samp{braceright}, @samp{enter}, @samp{control}, @samp{semicolon},
2471 @samp{colon}, @samp{quote}, @samp{doublequote}, @samp{backquote},
2472 @samp{tilde}, @samp{shift}, @samp{backslash}, @samp{bar}, @samp{comma},
2473 @samp{less}, @samp{period}, @samp{greater}, @samp{slash},
2474 @samp{question}, @samp{alt}, @samp{space}, @samp{capslock}, @samp{FX}
2475 (@samp{X} is a digit), and @samp{delete}. This table describes to which
2476 character each of the symbols corresponds:
2582 @subsection terminal
2584 @deffn Command terminal [@option{--dumb}] [@option{--no-echo}] [@option{--no-edit}] [@option{--timeout=secs}] [@option{--lines=lines}] [@option{--silent}] [@option{console}] [@option{serial}] [@option{hercules}]
2585 Select a terminal for user interaction. The terminal is assumed to be
2586 VT100-compatible unless @option{--dumb} is specified. If both
2587 @option{console} and @option{serial} are specified, then GRUB will use
2588 the one where a key is entered first or the first when the timeout
2589 expires. If neither are specified, the current setting is
2590 reported. This command is only available if GRUB is compiled with serial
2591 support. See also @ref{Serial terminal}.
2593 This may not make sense for most users, but GRUB supports Hercules
2594 console as well. Hercules console is usable like the ordinary console,
2595 and the usage is quite similar to that for serial terminals: specify
2596 @option{hercules} as the argument.
2598 The option @option{--lines} defines the number of lines in your
2599 terminal, and it is used for the internal pager function. If you don't
2600 specify this option, the number is assumed as 24.
2602 The option @option{--silent} suppresses the message to prompt you to
2603 hit any key. This might be useful if your system has no terminal
2606 The option @option{--no-echo} has GRUB not to echo back input
2607 characters. This implies the option @option{--no-edit}.
2609 The option @option{--no-edit} disables the BASH-like editing feature.
2614 @subsection terminfo
2616 @deffn Command terminfo @option{--name=name} @option{--cursor-address=seq} [@option{--clear-screen=seq}] [@option{--enter-standout-mode=seq}] [@option{--exit-standout-mode=seq}]
2617 Define the capabilities of your terminal. Use this command to define
2618 escape sequences, if it is not vt100-compatible. You may use @samp{\e}
2619 for @key{ESC} and @samp{^X} for a control character.
2621 You can use the utility @command{grub-terminfo} to generate
2622 appropriate arguments to this command. @xref{Invoking grub-terminfo}.
2624 If no option is specified, the current settings are printed.
2629 @subsection tftpserver
2631 @deffn Command tftpserver ipaddr
2632 @strong{Caution:} This command exists only for backward
2633 compatibility. Use @command{ifconfig} (@pxref{ifconfig}) instead.
2635 Override a TFTP server address returned by a BOOTP/DHCP/RARP server. The
2636 argument @var{ipaddr} must be in dotted decimal format, like
2637 @samp{192.168.0.15}. This command is only available if GRUB is compiled
2638 with netboot support. See also @ref{Network}.
2645 @deffn Command unhide partition
2646 Unhide the partition @var{partition} by clearing the @dfn{hidden} bit in
2647 its partition type code. This is useful only when booting DOS or Windows
2648 and multiple primary partitions exist on one disk. See also
2653 @node Command-line and menu entry commands
2654 @section The list of command-line and menu entry commands
2656 These commands are usable in the command-line and in menu entries. If
2657 you forget a command, you can run the command @command{help}
2661 * blocklist:: Get the block list notation of a file
2662 * boot:: Start up your operating system
2663 * cat:: Show the contents of a file
2664 * chainloader:: Chain-load another boot loader
2665 * cmp:: Compare two files
2666 * configfile:: Load a configuration file
2667 * debug:: Toggle the debug flag
2668 * displayapm:: Display APM information
2669 * displaymem:: Display memory configuration
2670 * embed:: Embed Stage 1.5
2671 * find:: Find a file
2672 * fstest:: Test a filesystem
2673 * geometry:: Manipulate the geometry of a drive
2674 * halt:: Shut down your computer
2675 * help:: Show help messages
2676 * impsprobe:: Probe SMP
2677 * initrd:: Load an initrd
2678 * install:: Install GRUB
2679 * ioprobe:: Probe I/O ports used for a drive
2680 * kernel:: Load a kernel
2681 * lock:: Lock a menu entry
2682 * makeactive:: Make a partition active
2683 * map:: Map a drive to another
2684 * md5crypt:: Encrypt a password in MD5 format
2685 * module:: Load a module
2686 * modulenounzip:: Load a module without decompression
2687 * pause:: Wait for a key press
2688 * quit:: Exit from the grub shell
2689 * reboot:: Reboot your computer
2690 * read:: Read data from memory
2691 * root:: Set GRUB's root device
2692 * rootnoverify:: Set GRUB's root device without mounting
2693 * savedefault:: Save current entry as the default entry
2694 * setup:: Set up GRUB's installation automatically
2695 * testload:: Load a file for testing a filesystem
2696 * testvbe:: Test VESA BIOS EXTENSION
2697 * uppermem:: Set the upper memory size
2698 * vbeprobe:: Probe VESA BIOS EXTENSION
2703 @subsection blocklist
2705 @deffn Command blocklist file
2706 Print the block list notation of the file @var{file}. @xref{Block list
2715 Boot the OS or chain-loader which has been loaded. Only necessary if
2716 running the fully interactive command-line (it is implicit at the end of
2724 @deffn Command cat file
2725 Display the contents of the file @var{file}. This command may be useful
2726 to remind you of your OS's root partition:
2729 grub> @kbd{cat /etc/fstab}
2735 @subsection chainloader
2737 @deffn Command chainloader [@option{--force}] file
2738 Load @var{file} as a chain-loader. Like any other file loaded by the
2739 filesystem code, it can use the blocklist notation to grab the first
2740 sector of the current partition with @samp{+1}. If you specify the
2741 option @option{--force}, then load @var{file} forcibly, whether it has a
2742 correct signature or not. This is required when you want to load a
2743 defective boot loader, such as SCO UnixWare 7.1 (@pxref{SCO UnixWare}).
2750 @deffn Command cmp file1 file2
2751 Compare the file @var{file1} with the file @var{file2}. If they differ
2752 in size, print the sizes like this:
2755 Differ in size: 0x1234 [foo], 0x4321 [bar]
2758 If the sizes are equal but the bytes at an offset differ, then print the
2762 Differ at the offset 777: 0xbe [foo], 0xef [bar]
2765 If they are completely identical, nothing will be printed.
2770 @subsection configfile
2772 @deffn Command configfile file
2773 Load @var{file} as a configuration file.
2780 @deffn Command debug
2781 Toggle debug mode (by default it is off). When debug mode is on, some
2782 extra messages are printed to show disk activity. This global debug flag
2783 is mainly useful for GRUB developers when testing new code.
2788 @subsection displayapm
2790 @deffn Command displayapm
2791 Display APM BIOS information.
2796 @subsection displaymem
2798 @deffn Command displaymem
2799 Display what GRUB thinks the system address space map of the machine is,
2800 including all regions of physical @sc{ram} installed. GRUB's
2801 @dfn{upper/lower memory} display uses the standard BIOS interface for
2802 the available memory in the first megabyte, or @dfn{lower memory}, and a
2803 synthesized number from various BIOS interfaces of the memory starting
2804 at 1MB and going up to the first chipset hole for @dfn{upper memory}
2805 (the standard PC @dfn{upper memory} interface is limited to reporting a
2813 @deffn Command embed stage1_5 device
2814 Embed the Stage 1.5 @var{stage1_5} in the sectors after the MBR if
2815 @var{device} is a drive, or in the @dfn{boot loader} area if @var{device}
2816 is a FFS partition or a ReiserFS partition.@footnote{The latter feature
2817 has not been implemented yet.} Print the number of sectors which
2818 @var{stage1_5} occupies, if successful.
2820 Usually, you don't need to run this command directly. @xref{setup}.
2827 @deffn Command find filename
2828 Search for the file name @var{filename} in all mountable partitions
2829 and print the list of the devices which contain the file. The file
2830 name @var{filename} should be an absolute file name like
2831 @code{/boot/grub/stage1}.
2838 @deffn Command fstest
2839 Toggle filesystem test mode.
2840 Filesystem test mode, when turned on, prints out data corresponding to
2841 all the device reads and what values are being sent to the low-level
2842 routines. The format is @samp{<@var{partition-offset-sector},
2843 @var{byte-offset}, @var{byte-length}>} for high-level reads inside a
2844 partition, and @samp{[@var{disk-offset-sector}]} for low-level sector
2845 requests from the disk.
2846 Filesystem test mode is turned off by any use of the @command{install}
2847 (@pxref{install}) or @command{testload} (@pxref{testload}) commands.
2852 @subsection geometry
2854 @deffn Command geometry drive [cylinder head sector [total_sector]]
2855 Print the information for the drive @var{drive}. In the grub shell, you
2856 can set the geometry of the drive arbitrarily. The number of
2857 cylinders, the number of heads, the number of sectors and the number of
2858 total sectors are set to CYLINDER, HEAD, SECTOR and TOTAL_SECTOR,
2859 respectively. If you omit TOTAL_SECTOR, then it will be calculated
2860 based on the C/H/S values automatically.
2867 @deffn Command halt @option{--no-apm}
2868 The command halts the computer. If the @option{--no-apm} option
2869 is specified, no APM BIOS call is performed. Otherwise, the computer
2870 is shut down using APM.
2877 @deffn Command help @option{--all} [pattern @dots{}]
2878 Display helpful information about builtin commands. If you do not
2879 specify @var{pattern}, this command shows short descriptions of most of
2880 available commands. If you specify the option @option{--all} to this
2881 command, short descriptions of rarely used commands (such as
2882 @ref{testload}) are displayed as well.
2884 If you specify any @var{patterns}, it displays longer information
2885 about each of the commands which match those @var{patterns}.
2890 @subsection impsprobe
2892 @deffn Command impsprobe
2893 Probe the Intel Multiprocessor Specification 1.1 or 1.4 configuration
2894 table and boot the various CPUs which are found into a tight loop. This
2895 command can be used only in the Stage 2, but not in the grub shell.
2902 @deffn Command initrd file @dots{}
2903 Load an initial ramdisk for a Linux format boot image and set the
2904 appropriate parameters in the Linux setup area in memory. See also
2912 @deffn Command install [@option{--force-lba}] [@option{--stage2=os_stage2_file}] stage1_file [@option{d}] dest_dev stage2_file [addr] [@option{p}] [config_file] [real_config_file]
2913 This command is fairly complex, and you should not use this command
2914 unless you are familiar with GRUB. Use @command{setup} (@pxref{setup})
2917 In short, it will perform a full install presuming the Stage 2 or Stage
2918 1.5@footnote{They're loaded the same way, so we will refer to the Stage
2919 1.5 as a Stage 2 from now on.} is in its final install location.
2921 In slightly more detail, it will load @var{stage1_file}, validate that
2922 it is a GRUB Stage 1 of the right version number, install in it a
2923 blocklist for loading @var{stage2_file} as a Stage 2. If the option
2924 @option{d} is present, the Stage 1 will always look for the actual
2925 disk @var{stage2_file} was installed on, rather than using the booting
2926 drive. The Stage 2 will be loaded at address @var{addr}, which must be
2927 @samp{0x8000} for a true Stage 2, and @samp{0x2000} for a Stage 1.5. If
2928 @var{addr} is not present, GRUB will determine the address
2929 automatically. It then writes the completed Stage 1 to the first block
2930 of the device @var{dest_dev}. If the options @option{p} or
2931 @var{config_file} are present, then it reads the first block of stage2,
2932 modifies it with the values of the partition @var{stage2_file} was found
2933 on (for @option{p}) or places the string @var{config_file} into the area
2934 telling the stage2 where to look for a configuration file at boot
2935 time. Likewise, if @var{real_config_file} is present and
2936 @var{stage2_file} is a Stage 1.5, then the Stage 2 @var{config_file} is
2937 patched with the configuration file name @var{real_config_file}. This
2938 command preserves the DOS BPB (and for hard disks, the partition table)
2939 of the sector the Stage 1 is to be installed into.
2941 @strong{Caution:} Several buggy BIOSes don't pass a booting drive
2942 properly when booting from a hard disk drive. Therefore, you will
2943 unfortunately have to specify the option @option{d}, whether your
2944 Stage2 resides at the booting drive or not, if you have such a
2945 BIOS. We know these are defective in this way:
2949 Fujitsu LifeBook 400 BIOS version 31J0103A
2952 HP Vectra XU 6/200 BIOS version GG.06.11
2955 @strong{Caution2:} A number of BIOSes don't return a correct LBA support
2956 bitmap even if they do have the support. So GRUB provides a solution to
2957 ignore the wrong bitmap, that is, the option @option{--force-lba}. Don't
2958 use this option if you know that your BIOS doesn't have LBA support.
2960 @strong{Caution3:} You must specify the option @option{--stage2} in the
2961 grub shell, if you cannot unmount the filesystem where your stage2 file
2962 resides. The argument should be the file name in your operating system.
2969 @deffn Command ioprobe drive
2970 Probe I/O ports used for the drive @var{drive}. This command will list
2971 the I/O ports on the screen. For technical information,
2979 @deffn Command kernel [@option{--type=type}] [@option{--no-mem-option}] file @dots{}
2980 Attempt to load the primary boot image (Multiboot a.out or @sc{elf},
2981 Linux zImage or bzImage, FreeBSD a.out, NetBSD a.out, etc.) from
2982 @var{file}. The rest of the line is passed verbatim as the @dfn{kernel
2983 command-line}. Any modules must be reloaded after using this command.
2985 This command also accepts the option @option{--type} so that you can
2986 specify the kernel type of @var{file} explicitly. The argument
2987 @var{type} must be one of these: @samp{netbsd}, @samp{freebsd},
2988 @samp{openbsd}, @samp{linux}, @samp{biglinux}, and
2989 @samp{multiboot}. However, you need to specify it only if you want to
2990 load a NetBSD @sc{elf} kernel, because GRUB can automatically determine
2991 a kernel type in the other cases, quite safely.
2993 The option @option{--no-mem-option} is effective only for Linux. If the
2994 option is specified, GRUB doesn't pass the option @option{mem=} to the
2995 kernel. This option is implied for Linux kernels 2.4.18 and newer.
3003 Prevent normal users from executing arbitrary menu entries. You must use
3004 the command @command{password} if you really want this command to be
3005 useful (@pxref{password}).
3007 This command is used in a menu, as shown in this example:
3011 title This entry is too dangerous to be executed by normal users
3014 kernel /no-security-os
3018 See also @ref{Security}.
3023 @subsection makeactive
3025 @deffn Command makeactive
3026 Set the active partition on the root disk to GRUB's root device.
3027 This command is limited to @emph{primary} PC partitions on a hard disk.
3034 @deffn Command map to_drive from_drive
3035 Map the drive @var{from_drive} to the drive @var{to_drive}. This is
3036 necessary when you chain-load some operating systems, such as DOS, if
3037 such an OS resides at a non-first drive. Here is an example:
3041 grub> @kbd{map (hd0) (hd1)}
3042 grub> @kbd{map (hd1) (hd0)}
3046 The example exchanges the order between the first hard disk and the
3047 second hard disk. See also @ref{DOS/Windows}.
3052 @subsection md5crypt
3054 @deffn Command md5crypt
3055 Prompt to enter a password, and encrypt it in MD5 format. The encrypted
3056 password can be used with the command @command{password}
3057 (@pxref{password}). See also @ref{Security}.
3064 @deffn Command module file @dots{}
3065 Load a boot module @var{file} for a Multiboot format boot image (no
3066 interpretation of the file contents are made, so the user of this
3067 command must know what the kernel in question expects). The rest of the
3068 line is passed as the @dfn{module command-line}, like the
3069 @command{kernel} command. You must load a Multiboot kernel image before
3070 loading any module. See also @ref{modulenounzip}.
3075 @subsection modulenounzip
3077 @deffn Command modulenounzip file @dots{}
3078 The same as @command{module} (@pxref{module}), except that automatic
3079 decompression is disabled.
3086 @deffn Command pause message @dots{}
3087 Print the @var{message}, then wait until a key is pressed. Note that
3088 placing @key{^G} (ASCII code 7) in the message will cause the speaker to
3089 emit the standard beep sound, which is useful when prompting the user to
3098 Exit from the grub shell @command{grub} (@pxref{Invoking the grub
3099 shell}). This command can be used only in the grub shell.
3106 @deffn Command reboot
3107 Reboot the computer.
3114 @deffn Command read addr
3115 Read a 32-bit value from memory at address @var{addr} and display it in
3123 @deffn Command root device [hdbias]
3124 Set the current @dfn{root device} to the device @var{device}, then
3125 attempt to mount it to get the partition size (for passing the partition
3126 descriptor in @code{ES:ESI}, used by some chain-loaded boot loaders), the
3127 BSD drive-type (for booting BSD kernels using their native boot format),
3128 and correctly determine the PC partition where a BSD sub-partition is
3129 located. The optional @var{hdbias} parameter is a number to tell a BSD
3130 kernel how many BIOS drive numbers are on controllers before the current
3131 one. For example, if there is an IDE disk and a SCSI disk, and your
3132 FreeBSD root partition is on the SCSI disk, then use a @samp{1} for
3135 See also @ref{rootnoverify}.
3140 @subsection rootnoverify
3142 @deffn Command rootnoverify device [hdbias]
3143 Similar to @command{root} (@pxref{root}), but don't attempt to mount the
3144 partition. This is useful for when an OS is outside of the area of the
3145 disk that GRUB can read, but setting the correct root device is still
3146 desired. Note that the items mentioned in @command{root} above which
3147 derived from attempting the mount will @emph{not} work correctly.
3152 @subsection savedefault
3154 @deffn Command savedefault num
3155 Save the current menu entry or @var{num} if specified as a default
3156 entry. Here is an example:
3165 kernel /boot/vmlinuz root=/dev/sda1 vga=ext
3176 With this configuration, GRUB will choose the entry booted previously as
3179 You can specify @samp{fallback} instead of a number. Then, next
3180 fallback entry is saved. Next fallback entry is chosen from fallback
3181 entries. Normally, this will be the first entry in fallback ones.
3183 See also @ref{default} and @ref{Invoking grub-set-default}.
3190 @deffn Command setup [@option{--force-lba}] [@option{--stage2=os_stage2_file}] [@option{--prefix=dir}] install_device [image_device]
3191 Set up the installation of GRUB automatically. This command uses the
3192 more flexible command @command{install} (@pxref{install}) in the backend
3193 and installs GRUB into the device @var{install_device}. If
3194 @var{image_device} is specified, then find the GRUB images
3195 (@pxref{Images}) in the device @var{image_device}, otherwise use the
3196 current @dfn{root device}, which can be set by the command
3197 @command{root}. If @var{install_device} is a hard disk, then embed a
3198 Stage 1.5 in the disk if possible.
3200 The option @option{--prefix} specifies the directory under which GRUB
3201 images are put. If it is not specified, GRUB automatically searches them
3202 in @file{/boot/grub} and @file{/grub}.
3204 The options @option{--force-lba} and @option{--stage2} are just passed
3205 to @command{install} if specified. @xref{install}, for more
3211 @subsection testload
3213 @deffn Command testload file
3214 Read the entire contents of @var{file} in several different ways and
3215 compare them, to test the filesystem code. The output is somewhat
3216 cryptic, but if no errors are reported and the final @samp{i=@var{X},
3217 filepos=@var{Y}} reading has @var{X} and @var{Y} equal, then it is
3218 definitely consistent, and very likely works correctly subject to a
3219 consistent offset error. If this test succeeds, then a good next step is
3220 to try loading a kernel.
3227 @deffn Command testvbe mode
3228 Test the VESA BIOS EXTENSION mode @var{mode}. This command will switch
3229 your video card to the graphics mode, and show an endless animation. Hit
3230 any key to return. See also @ref{vbeprobe}.
3235 @subsection uppermem
3237 @deffn Command uppermem kbytes
3238 Force GRUB to assume that only @var{kbytes} kilobytes of upper memory
3239 are installed. Any system address range maps are discarded.
3241 @strong{Caution:} This should be used with great caution, and should
3242 only be necessary on some old machines. GRUB's BIOS probe can pick up
3243 all @sc{ram} on all new machines the author has ever heard of. It can
3244 also be used for debugging purposes to lie to an OS.
3249 @subsection vbeprobe
3251 @deffn Command vbeprobe [mode]
3252 Probe VESA BIOS EXTENSION information. If the mode @var{mode} is
3253 specified, show only the information about @var{mode}. Otherwise, this
3254 command lists up available VBE modes on the screen. See also
3259 @node Troubleshooting
3260 @chapter Error messages reported by GRUB
3262 This chapter describes error messages reported by GRUB when you
3263 encounter trouble. @xref{Invoking the grub shell}, if your problem is
3264 specific to the grub shell.
3267 * Stage1 errors:: Errors reported by the Stage 1
3268 * Stage1.5 errors:: Errors reported by the Stage 1.5
3269 * Stage2 errors:: Errors reported by the Stage 2
3274 @section Errors reported by the Stage 1
3276 The general way that the Stage 1 handles errors is to print an error
3277 string and then halt. Pressing @kbd{@key{CTRL}-@key{ALT}-@key{DEL}} will
3280 The following is a comprehensive list of error messages for the Stage 1:
3283 @item Hard Disk Error
3284 The stage2 or stage1.5 is being read from a hard disk, and the attempt
3285 to determine the size and geometry of the hard disk failed.
3288 The stage2 or stage1.5 is being read from a floppy disk, and the attempt
3289 to determine the size and geometry of the floppy disk failed. It's listed
3290 as a separate error since the probe sequence is different than for hard
3294 A disk read error happened while trying to read the stage2 or stage1.5.
3297 The location of the stage2 or stage1.5 is not in the portion of the disk
3298 supported directly by the BIOS read calls. This could occur because the
3299 BIOS translated geometry has been changed by the user or the disk is
3300 moved to another machine or controller after installation, or GRUB was
3301 not installed using itself (if it was, the Stage 2 version of this error
3302 would have been seen during that process and it would not have completed
3307 @node Stage1.5 errors
3308 @section Errors reported by the Stage 1.5
3310 The general way that the Stage 1.5 handles errors is to print an error
3311 number in the form @code{Error @var{num}} and then halt. Pressing
3312 @kbd{@key{CTRL}-@key{ALT}-@key{DEL}} will reboot.
3314 The error numbers correspond to the errors reported by Stage
3315 2. @xref{Stage2 errors}.
3319 @section Errors reported by the Stage 2
3321 The general way that the Stage 2 handles errors is to abort the
3322 operation in question, print an error string, then (if possible) either
3323 continue based on the fact that an error occurred or wait for the user to
3324 deal with the error.
3326 The following is a comprehensive list of error messages for the Stage 2
3327 (error numbers for the Stage 1.5 are listed before the colon in each
3331 @item 1 : Filename must be either an absolute filename or blocklist
3332 This error is returned if a file name is requested which doesn't fit the
3333 syntax/rules listed in the @ref{Filesystem}.
3335 @item 2 : Bad file or directory type
3336 This error is returned if a file requested is not a regular file, but
3337 something like a symbolic link, directory, or FIFO.
3339 @item 3 : Bad or corrupt data while decompressing file
3340 This error is returned if the run-length decompression code gets an
3341 internal error. This is usually from a corrupt file.
3343 @item 4 : Bad or incompatible header in compressed file
3344 This error is returned if the file header for a supposedly compressed
3347 @item 5 : Partition table invalid or corrupt
3348 This error is returned if the sanity checks on the integrity of the
3349 partition table fail. This is a bad sign.
3351 @item 6 : Mismatched or corrupt version of stage1/stage2
3352 This error is returned if the install command points to incompatible
3353 or corrupt versions of the stage1 or stage2. It can't detect corruption
3354 in general, but this is a sanity check on the version numbers, which
3357 @item 7 : Loading below 1MB is not supported
3358 This error is returned if the lowest address in a kernel is below the
3359 1MB boundary. The Linux zImage format is a special case and can be
3360 handled since it has a fixed loading address and maximum size.
3362 @item 8 : Kernel must be loaded before booting
3363 This error is returned if GRUB is told to execute the boot sequence
3364 without having a kernel to start.
3366 @item 9 : Unknown boot failure
3367 This error is returned if the boot attempt did not succeed for reasons
3370 @item 10 : Unsupported Multiboot features requested
3371 This error is returned when the Multiboot features word in the Multiboot
3372 header requires a feature that is not recognized. The point of this is
3373 that the kernel requires special handling which GRUB is probably
3376 @item 11 : Unrecognized device string
3377 This error is returned if a device string was expected, and the string
3378 encountered didn't fit the syntax/rules listed in the @ref{Filesystem}.
3380 @item 12 : Invalid device requested
3381 This error is returned if a device string is recognizable but does not
3382 fall under the other device errors.
3384 @item 13 : Invalid or unsupported executable format
3385 This error is returned if the kernel image being loaded is not
3386 recognized as Multiboot or one of the supported native formats (Linux
3387 zImage or bzImage, FreeBSD, or NetBSD).
3389 @item 14 : Filesystem compatibility error, cannot read whole file
3390 Some of the filesystem reading code in GRUB has limits on the length of
3391 the files it can read. This error is returned when the user runs into
3394 @item 15 : File not found
3395 This error is returned if the specified file name cannot be found, but
3396 everything else (like the disk/partition info) is OK.
3398 @item 16 : Inconsistent filesystem structure
3399 This error is returned by the filesystem code to denote an internal
3400 error caused by the sanity checks of the filesystem structure on disk
3401 not matching what it expects. This is usually caused by a corrupt
3402 filesystem or bugs in the code handling it in GRUB.
3404 @item 17 : Cannot mount selected partition
3405 This error is returned if the partition requested exists, but the
3406 filesystem type cannot be recognized by GRUB.
3408 @item 18 : Selected cylinder exceeds maximum supported by BIOS
3409 This error is returned when a read is attempted at a linear block
3410 address beyond the end of the BIOS translated area. This generally
3411 happens if your disk is larger than the BIOS can handle (512MB for
3412 (E)IDE disks on older machines or larger than 8GB in general).
3414 @item 19 : Linux kernel must be loaded before initrd
3415 This error is returned if the initrd command is used before loading a
3418 @item 20 : Multiboot kernel must be loaded before modules
3419 This error is returned if the module load command is used before loading
3420 a Multiboot kernel. It only makes sense in this case anyway, as GRUB has
3421 no idea how to communicate the presence of such modules to a
3422 non-Multiboot-aware kernel.
3424 @item 21 : Selected disk does not exist
3425 This error is returned if the device part of a device- or full file name
3426 refers to a disk or BIOS device that is not present or not recognized by
3427 the BIOS in the system.
3429 @item 22 : No such partition
3430 This error is returned if a partition is requested in the device part of
3431 a device- or full file name which isn't on the selected disk.
3433 @item 23 : Error while parsing number
3434 This error is returned if GRUB was expecting to read a number and
3435 encountered bad data.
3437 @item 24 : Attempt to access block outside partition
3438 This error is returned if a linear block address is outside of the disk
3439 partition. This generally happens because of a corrupt filesystem on the
3440 disk or a bug in the code handling it in GRUB (it's a great debugging
3443 @item 25 : Disk read error
3444 This error is returned if there is a disk read error when trying to
3445 probe or read data from a particular disk.
3447 @item 26 : Too many symbolic links
3448 This error is returned if the link count is beyond the maximum
3449 (currently 5), possibly the symbolic links are looped.
3451 @item 27 : Unrecognized command
3452 This error is returned if an unrecognized command is entered on the
3453 command-line or in a boot sequence section of a configuration file and
3454 that entry is selected.
3456 @item 28 : Selected item cannot fit into memory
3457 This error is returned if a kernel, module, or raw file load command is
3458 either trying to load its data such that it won't fit into memory or it
3461 @item 29 : Disk write error
3462 This error is returned if there is a disk write error when trying to
3463 write to a particular disk. This would generally only occur during an
3464 install of set active partition command.
3466 @item 30 : Invalid argument
3467 This error is returned if an argument specified to a command is invalid.
3469 @item 31 : File is not sector aligned
3470 This error may occur only when you access a ReiserFS partition by
3471 block-lists (e.g. the command @command{install}). In this case, you
3472 should mount the partition with the @samp{-o notail} option.
3474 @item 32 : Must be authenticated
3475 This error is returned if you try to run a locked entry. You should
3476 enter a correct password before running such an entry.
3478 @item 33 : Serial device not configured
3479 This error is returned if you try to change your terminal to a serial
3480 one before initializing any serial device.
3482 @item 34 : No spare sectors on the disk
3483 This error is returned if a disk doesn't have enough spare space. This
3484 happens when you try to embed Stage 1.5 into the unused sectors after
3485 the MBR, but the first partition starts right after the MBR or they are
3490 @node Invoking the grub shell
3491 @chapter Invoking the grub shell
3493 This chapter documents the grub shell @command{grub}. Note that the grub
3494 shell is an emulator; it doesn't run under the native environment, so it
3495 sometimes does something wrong. Therefore, you shouldn't trust it too
3496 much. If there is anything wrong with it, don't hesitate to try the
3497 native GRUB environment, especially when it guesses a wrong map between
3498 BIOS drives and OS devices.
3501 * Basic usage:: How to use the grub shell
3502 * Installation under UNIX:: How to install GRUB via @command{grub}
3503 * Device map:: The map between BIOS drives and OS devices
3508 @section Introduction into the grub shell
3510 You can use the command @command{grub} for installing GRUB under your
3511 operating systems and for a testbed when you add a new feature into GRUB
3512 or when fixing a bug. @command{grub} is almost the same as the Stage 2,
3513 and, in fact, it shares the source code with the Stage 2 and you can use
3514 the same commands (@pxref{Commands}) in @command{grub}. It is emulated by
3515 replacing BIOS calls with UNIX system calls and libc functions.
3517 The command @command{grub} accepts the following options:
3521 Print a summary of the command-line options and exit.
3524 Print the version number of GRUB and exit.
3527 Print some verbose messages for debugging purpose.
3529 @item --device-map=@var{file}
3530 Use the device map file @var{file}. The format is described in
3534 Do not probe any floppy drive. This option has no effect if the option
3535 @option{--device-map} is specified (@pxref{Device map}).
3537 @item --probe-second-floppy
3538 Probe the second floppy drive. If this option is not specified, the grub
3539 shell does not probe it, as that sometimes takes a long time. If you
3540 specify the device map file (@pxref{Device map}), the grub shell just
3541 ignores this option.
3543 @item --config-file=@var{file}
3544 Read the configuration file @var{file} instead of
3545 @file{/boot/grub/menu.lst}. The format is the same as the normal GRUB
3546 syntax. See @ref{Filesystem}, for more information.
3548 @item --boot-drive=@var{drive}
3549 Set the stage2 @var{boot_drive} to @var{drive}. This argument should be
3550 an integer (decimal, octal or hexadecimal).
3552 @item --install-partition=@var{par}
3553 Set the stage2 @var{install_partition} to @var{par}. This argument
3554 should be an integer (decimal, octal or hexadecimal).
3556 @item --no-config-file
3557 Do not use the configuration file even if it can be read.
3560 Do not use the screen handling interface by the curses even if it is
3564 This option has the same meaning as @samp{--no-config-file --no-curses}.
3567 Disable writing to any disk.
3570 Wait until a debugger will attach. This option is useful when you want
3571 to debug the startup code.
3575 @node Installation under UNIX
3576 @section How to install GRUB via @command{grub}
3578 The installation procedure is the same as under the @dfn{native} Stage
3579 2. @xref{Installation}, for more information. The command
3580 @command{grub}-specific information is described here.
3582 What you should be careful about is @dfn{buffer cache}. @command{grub}
3583 makes use of raw devices instead of filesystems that your operating
3584 systems serve, so there exists a potential problem that some cache
3585 inconsistency may corrupt your filesystems. What we recommend is:
3589 If you can unmount drives to which GRUB may write any amount of data,
3590 unmount them before running @command{grub}.
3593 If a drive cannot be unmounted but can be mounted with the read-only
3594 flag, mount it in read-only mode. That should be secure.
3597 If a drive must be mounted with the read-write flag, make sure that no
3598 activity is being done on it while the command @command{grub} is
3602 Reboot your operating system as soon as possible. This is probably not
3603 required if you follow the rules above, but reboot is the most secure
3607 In addition, enter the command @command{quit} when you finish the
3608 installation. That is @emph{very important} because @command{quit} makes
3609 the buffer cache consistent. Do not push @key{C-c}.
3611 If you want to install GRUB non-interactively, specify @samp{--batch}
3612 option in the command-line. This is a simple example:
3618 # Use /usr/sbin/grub if you are on an older system.
3619 /sbin/grub --batch <<EOT 1>/dev/null 2>/dev/null
3629 @section The map between BIOS drives and OS devices
3631 When you specify the option @option{--device-map} (@pxref{Basic usage}),
3632 the grub shell creates the @dfn{device map file} automatically unless it
3633 already exists. The file name @file{/boot/grub/device.map} is preferred.
3635 If the device map file exists, the grub shell reads it to map BIOS
3636 drives to OS devices. This file consists of lines like this:
3639 @var{device} @var{file}
3642 @var{device} is a drive specified in the GRUB syntax (@pxref{Device
3643 syntax}), and @var{file} is an OS file, which is normally a device
3646 The reason why the grub shell gives you the device map file is that it
3647 cannot guess the map between BIOS drives and OS devices correctly in
3648 some environments. For example, if you exchange the boot sequence
3649 between IDE and SCSI in your BIOS, it gets the order wrong.
3651 Thus, edit the file if the grub shell makes a mistake. You can put any
3652 comments in the file if needed, as the grub shell assumes that a line is
3653 just a comment if the first character is @samp{#}.
3656 @node Invoking grub-install
3657 @chapter Invoking grub-install
3659 The program @command{grub-install} installs GRUB on your drive using the
3660 grub shell (@pxref{Invoking the grub shell}). You must specify the
3661 device name on which you want to install GRUB, like this:
3664 grub-install @var{install_device}
3667 The device name @var{install_device} is an OS device name or a GRUB
3670 @command{grub-install} accepts the following options:
3674 Print a summary of the command-line options and exit.
3677 Print the version number of GRUB and exit.
3680 Force GRUB to use LBA mode even for a buggy BIOS. Use this option only
3681 if your BIOS doesn't work properly in LBA mode even though it supports
3684 @item --root-directory=@var{dir}
3685 Install GRUB images under the directory @var{dir} instead of the root
3686 directory. This option is useful when you want to install GRUB into a
3687 separate partition or a removable disk. Here is an example in which
3688 you have a separate @dfn{boot} partition which is mounted on
3692 @kbd{grub-install --root-directory=/boot hd0}
3695 @item --grub-shell=@var{file}
3696 Use @var{file} as the grub shell. You can append arbitrary options to
3697 @var{file} after the file name, like this:
3700 @kbd{grub-install --grub-shell="grub --read-only" /dev/fd0}
3704 Recheck the device map, even if @file{/boot/grub/device.map} already
3705 exists. You should use this option whenever you add/remove a disk
3706 into/from your computer.
3710 @node Invoking grub-md5-crypt
3711 @chapter Invoking grub-md5-crypt
3713 The program @command{grub-md5-crypt} encrypts a password in MD5 format.
3714 This is just a frontend of the grub shell (@pxref{Invoking the grub
3715 shell}). Passwords encrypted by this program can be used with the
3716 command @command{password} (@pxref{password}).
3718 @command{grub-md5-crypt} accepts the following options:
3722 Print a summary of the command-line options and exit.
3725 Print the version information and exit.
3727 @item --grub-shell=@var{file}
3728 Use @var{file} as the grub shell.
3732 @node Invoking grub-terminfo
3733 @chapter Invoking grub-terminfo
3735 The program @command{grub-terminfo} generates a terminfo command from
3736 a terminfo name (@pxref{terminfo}). The result can be used in the
3737 configuration file, to define escape sequences. Because GRUB assumes
3738 that your terminal is vt100-compatible by default, this would be
3739 useful only if your terminal is uncommon (such as vt52).
3741 @command{grub-terminfo} accepts the following options:
3745 Print a summary of the command-line options and exit.
3748 Print the version information and exit.
3751 You must specify one argument to this command. For example:
3754 @kbd{grub-terminfo vt52}
3758 @node Invoking grub-set-default
3759 @chapter Invoking grub-set-default
3761 The program @command{grub-set-default} sets the default boot entry for
3762 GRUB. This automatically creates a file named @file{default} under
3763 your GRUB directory (i.e. @file{/boot/grub}), if it is not
3764 present. This file is used to determine the default boot entry when
3765 GRUB boots up your system when you use @samp{default saved} in your
3766 configuration file (@pxref{default}), and to save next default boot
3767 entry when you use @samp{savedefault} in a boot entry
3768 (@pxref{savedefault}).
3770 @command{grub-set-default} accepts the following options:
3774 Print a summary of the command-line options and exit.
3777 Print the version information and exit.
3779 @item --root-directory=@var{dir}
3780 Use the directory @var{dir} instead of the root directory
3781 (i.e. @file{/}) to define the location of the default file. This
3782 is useful when you mount a disk which is used for another system.
3785 You must specify a single argument to @command{grub-set-default}. This
3786 argument is normally the number of a default boot entry. For example,
3787 if you have this configuration file:
3804 and if you want to set the next default boot entry to GNU/Linux, you
3805 may execute this command:
3808 @kbd{grub-set-default 1}
3811 Because the entry for GNU/Linux is @samp{1}. Note that entries are
3812 counted from zero. So, if you want to specify GNU/Hurd here, then you
3813 should specify @samp{0}.
3815 This feature is very useful if you want to test a new kernel or to
3816 make your system quite robust. @xref{Making your system robust}, for
3817 more hints about how to set up a robust system.
3820 @node Invoking mbchk
3821 @chapter Invoking mbchk
3823 The program @command{mbchk} checks for the format of a Multiboot
3824 kernel. We recommend using this program before booting your own kernel
3827 @command{mbchk} accepts the following options:
3831 Print a summary of the command-line options and exit.
3834 Print the version number of GRUB and exit.
3837 Suppress all normal output.
3841 @node Obtaining and Building GRUB
3842 @appendix How to obtain and build GRUB
3845 @strong{Caution:} GRUB requires binutils-2.9.1.0.23 or later because the
3846 GNU assembler has been changed so that it can produce real 16bits
3847 machine code between 2.9.1 and 2.9.1.0.x. See
3848 @uref{http://sources.redhat.com/binutils/}, to obtain information on
3849 how to get the latest version.
3852 GRUB is available from the GNU alpha archive site
3853 @uref{ftp://alpha.gnu.org/gnu/grub} or any of its mirrors. The file
3854 will be named grub-version.tar.gz. The current version is
3855 @value{VERSION}, so the file you should grab is:
3857 @uref{ftp://alpha.gnu.org/gnu/grub/grub-@value{VERSION}.tar.gz}
3859 To unbundle GRUB use the instruction:
3862 @kbd{zcat grub-@value{VERSION}.tar.gz | tar xvf -}
3865 which will create a directory called @file{grub-@value{VERSION}} with
3866 all the sources. You can look at the file @file{INSTALL} for detailed
3867 instructions on how to build and install GRUB, but you should be able to
3872 @kbd{cd grub-@value{VERSION}}
3878 This will install the grub shell @file{grub} (@pxref{Invoking the grub
3879 shell}), the Multiboot checker @file{mbchk} (@pxref{Invoking mbchk}),
3880 and the GRUB images. This will also install the GRUB manual.
3882 Also, the latest version is available from the CVS. See
3883 @uref{http://savannah.gnu.org/cvs/?group=grub} for more information.
3886 @node Reporting bugs
3887 @appendix Reporting bugs
3889 These are the guideline for how to report bugs. Take a look at this
3890 list below before you submit bugs:
3894 Before getting unsettled, read this manual through and through. Also,
3895 see the @uref{http://www.gnu.org/software/grub/grub-faq.html, GNU GRUB FAQ}.
3898 Always mention the information on your GRUB. The version number and the
3899 configuration are quite important. If you build it yourself, write the
3900 options specified to the configure script and your operating system,
3901 including the versions of gcc and binutils.
3904 If you have trouble with the installation, inform us of how you
3905 installed GRUB. Don't omit error messages, if any. Just @samp{GRUB hangs
3906 up when it boots} is not enough.
3908 The information on your hardware is also essential. These are especially
3909 important: the geometries and the partition tables of your hard disk
3910 drives and your BIOS.
3913 If GRUB cannot boot your operating system, write down
3914 @emph{everything} you see on the screen. Don't paraphrase them, like
3915 @samp{The foo OS crashes with GRUB, even though it can boot with the
3916 bar boot loader just fine}. Mention the commands you executed, the
3917 messages printed by them, and information on your operating system
3918 including the version number.
3921 Explain what you wanted to do. It is very useful to know your purpose
3922 and your wish, and how GRUB didn't satisfy you.
3925 If you can investigate the problem yourself, please do. That will give
3926 you and us much more information on the problem. Attaching a patch is
3929 When you attach a patch, make the patch in unified diff format, and
3930 write ChangeLog entries. But, even when you make a patch, don't forget
3931 to explain the problem, so that we can understand what your patch is
3935 Write down anything that you think might be related. Please understand
3936 that we often need to reproduce the same problem you encounterred in our
3937 environment. So your information should be sufficient for us to do the
3938 same thing---Don't forget that we cannot see your computer directly. If
3939 you are not sure whether to state a fact or leave it out, state it!
3940 Reporting too many things is much better than omitting something
3944 If you follow the guideline above, submit a report to the
3945 @uref{http://savannah.gnu.org/bugs/?group=grub, Bug Tracking System}.
3946 Alternatively, you can submit a report via electronic mail to
3947 @email{bug-grub@@gnu.org}, but we strongly recommend that you use the
3948 Bug Tracking System, because e-mail can be passed over easily.
3950 Once we get your report, we will try to fix the bugs.
3954 @appendix Where GRUB will go
3956 We started the next generation of GRUB, GRUB 2. This will include
3957 internationalization, dynamic module loading, real memory management,
3958 multiple architecture support, a scripting language, and many other
3959 nice feature. If you are interested in the development of GRUB 2, take
3960 a look at @uref{http://www.gnu.org/software/grub/grub.html, the
3964 @c Separate the programming guide.
3965 @include internals.texi
3971 @c Currently, we use only the Concept Index.
3979 This is the second attempt to rewrite the manual. The status is
3980 mostly complete, but I need to check the spelling by ispell, and add
3981 more indices. Perhaps I also have to let some English native speakers
3982 proofread this manual through. My English is syntactically almost
3983 perfect, but sometimes (often?) awful in the nuance. Hehe, I can't be an
3984 English poet for now.