]> git.proxmox.com Git - grub2.git/blame - docs/grub.texi
2009-07-01 Robert Millan <rmh.grub@aybabtu.com>
[grub2.git] / docs / grub.texi
CommitLineData
87a95d1f 1\input texinfo
2@c -*-texinfo-*-
3@c %**start of header
4@setfilename grub.info
5@include version.texi
6@settitle GNU GRUB Manual @value{VERSION}
7@c Unify all our little indices for now.
8@syncodeindex fn cp
9@syncodeindex vr cp
10@syncodeindex ky cp
11@syncodeindex pg cp
12@syncodeindex tp cp
13@c %**end of header
14
15@footnotestyle separate
16@paragraphindent 3
17@finalout
18
19@copying
20This manual is for GNU GRUB (version @value{VERSION},
21@value{UPDATED}).
22
23Copyright @copyright{} 1999,2000,2001,2002,2004,2006,2008 Free Software Foundation, Inc.
24
25@quotation
26Permission is granted to copy, distribute and/or modify this document
27under the terms of the GNU Free Documentation License, Version 1.2 or
28any later version published by the Free Software Foundation; with no
29Invariant Sections.
30@end quotation
31@end copying
32
33@dircategory Kernel
34@direntry
35* GRUB: (grub). The GRand Unified Bootloader
36* grub-install: (grub)Invoking grub-install. Install GRUB on your drive
37* grub-md5-crypt: (grub)Invoking grub-md5-crypt. Encrypt a password
38 in MD5 format
39* grub-terminfo: (grub)Invoking grub-terminfo. Generate a terminfo
40 command from a
41 terminfo name
42* grub-set-default: (grub)Invoking grub-set-default. Set a default boot
43 entry
44* mbchk: (grub)Invoking mbchk. Check for the format of a Multiboot kernel
45@end direntry
46
47@setchapternewpage odd
48
49@titlepage
50@sp 10
51@title the GNU GRUB manual
52@subtitle The GRand Unified Bootloader, version @value{VERSION}, @value{UPDATED}.
53@author Gordon Matzigkeit
54@author Yoshinori K. Okuji
55@c The following two commands start the copyright page.
56@page
57@vskip 0pt plus 1filll
58@insertcopying
59@end titlepage
60
61@c Output the table of contents at the beginning.
62@contents
63
64@finalout
65@headings double
66
67@ifnottex
68@node Top
69@top GNU GRUB manual
70
71This is the documentation of GNU GRUB, the GRand Unified Bootloader,
72a flexible and powerful boot loader program for a wide range of
73architectures.
74
75This edition documents version @value{VERSION}.
76
77@insertcopying
78@end ifnottex
79
80@menu
81* Introduction:: Capturing the spirit of GRUB
82* Naming convention:: Names of your drives in GRUB
83* Installation:: Installing GRUB on your drive
84* Booting:: How to boot different operating systems
85* Configuration:: Writing your own configuration file
86* Network:: Downloading OS images from a network
87* Serial terminal:: Using GRUB via a serial line
88* Preset Menu:: Embedding a configuration file into GRUB
89* Security:: Improving the security
90* Images:: GRUB image files
91* Filesystem:: Filesystem syntax and semantics
92* Interface:: The menu and the command-line
93* Commands:: The list of available builtin commands
94* Troubleshooting:: Error messages produced by GRUB
95* Invoking the grub shell:: How to use the grub shell
96* Invoking grub-install:: How to use the GRUB installer
97* Invoking grub-md5-crypt:: How to generate a cryptic password
98* Invoking grub-terminfo:: How to generate a terminfo command
99* Invoking grub-set-default:: How to set a default boot entry
100* Invoking mbchk:: How to use the Multiboot checker
101* Obtaining and Building GRUB:: How to obtain and build GRUB
102* Reporting bugs:: Where you should send a bug report
103* Future:: Some future plans on GRUB
104* Internals:: Hacking GRUB
105* Copying This Manual:: Copying This Manual
106* Index::
107@end menu
108
109
110@node Introduction
111@chapter Introduction to GRUB
112
113@menu
114* Overview:: What exactly GRUB is and how to use it
115* History:: From maggot to house fly
116* Features:: GRUB features
117* Role of a boot loader:: The role of a boot loader
118@end menu
119
120
121@node Overview
122@section Overview
123
124Briefly, a @dfn{boot loader} is the first software program that runs when
125a computer starts. It is responsible for loading and transferring
126control to an operating system @dfn{kernel} software (such as Linux or
127GNU Mach). The kernel, in turn, initializes the rest of the operating
128system (e.g. a GNU system).
129
130GNU GRUB is a very powerful boot loader, which can load a wide variety
131of free operating systems, as well as proprietary operating systems with
132chain-loading@footnote{@dfn{chain-load} is the mechanism for loading
133unsupported operating systems by loading another boot loader. It is
134typically used for loading DOS or Windows.}. GRUB is designed to
135address the complexity of booting a personal computer; both the
136program and this manual are tightly bound to that computer platform,
137although porting to other platforms may be addressed in the future.
138
139One of the important features in GRUB is flexibility; GRUB understands
140filesystems and kernel executable formats, so you can load an arbitrary
141operating system the way you like, without recording the physical
142position of your kernel on the disk. Thus you can load the kernel
143just by specifying its file name and the drive and partition where the
144kernel resides.
145
146When booting with GRUB, you can use either a command-line interface
147(@pxref{Command-line interface}), or a menu interface (@pxref{Menu
148interface}). Using the command-line interface, you type the drive
149specification and file name of the kernel manually. In the menu
150interface, you just select an OS using the arrow keys. The menu is
151based on a configuration file which you prepare beforehand
152(@pxref{Configuration}). While in the menu, you can switch to the
153command-line mode, and vice-versa. You can even edit menu entries
154before using them.
155
156In the following chapters, you will learn how to specify a drive, a
157partition, and a file name (@pxref{Naming convention}) to GRUB, how to
158install GRUB on your drive (@pxref{Installation}), and how to boot your
159OSes (@pxref{Booting}), step by step.
160
161Besides the GRUB boot loader itself, there is a @dfn{grub shell}
162@command{grub} (@pxref{Invoking the grub shell}) which can be run when
163you are in your operating system. It emulates the boot loader and can
164be used for installing the boot loader.
165
166
167@node History
168@section History of GRUB
169
170GRUB originated in 1995 when Erich Boleyn was trying to boot the GNU
171Hurd with the University of Utah's Mach 4 microkernel (now known as GNU
172Mach). Erich and Brian Ford designed the Multiboot Specification
173(@pxref{Top, Multiboot Specification, Motivation, multiboot, The Multiboot
174Specification}), because they were determined not to add to the large
175number of mutually-incompatible PC boot methods.
176
177Erich then began modifying the FreeBSD boot loader so that it would
178understand Multiboot. He soon realized that it would be a lot easier
179to write his own boot loader from scratch than to keep working on the
180FreeBSD boot loader, and so GRUB was born.
181
182Erich added many features to GRUB, but other priorities prevented him
183from keeping up with the demands of its quickly-expanding user base. In
1841999, Gordon Matzigkeit and Yoshinori K. Okuji adopted GRUB as an
185official GNU package, and opened its development by making the latest
186sources available via anonymous CVS. @xref{Obtaining and Building
187GRUB}, for more information.
188
189
190@node Features
191@section GRUB features
192
193The primary requirement for GRUB is that it be compliant with the
194@dfn{Multiboot Specification}, which is described in @ref{Top, Multiboot
195Specification, Motivation, multiboot, The Multiboot Specification}.
196
197The other goals, listed in approximate order of importance, are:
198
199@itemize @bullet{}
200@item
201Basic functions must be straightforward for end-users.
202
203@item
204Rich functionality to support kernel experts and designers.
205
206@item
207Backward compatibility for booting FreeBSD, NetBSD, OpenBSD, and
208Linux. Proprietary kernels (such as DOS, Windows NT, and OS/2) are
209supported via a chain-loading function.
210@end itemize
211
212Except for specific compatibility modes (chain-loading and the Linux
213@dfn{piggyback} format), all kernels will be started in much the same
214state as in the Multiboot Specification. Only kernels loaded at 1 megabyte
215or above are presently supported. Any attempt to load below that
216boundary will simply result in immediate failure and an error message
217reporting the problem.
218
219In addition to the requirements above, GRUB has the following features
220(note that the Multiboot Specification doesn't require all the features
221that GRUB supports):
222
223@table @asis
224@item Recognize multiple executable formats
225Support many of the @dfn{a.out} variants plus @dfn{ELF}. Symbol
226tables are also loaded.
227
228@item Support non-Multiboot kernels
229Support many of the various free 32-bit kernels that lack Multiboot
230compliance (primarily FreeBSD, NetBSD, OpenBSD, and
231Linux). Chain-loading of other boot loaders is also supported.
232
233@item Load multiples modules
234Fully support the Multiboot feature of loading multiple modules.
235
236@item Load a configuration file
237Support a human-readable text configuration file with preset boot
238commands. You can also load another configuration file dynamically and
239embed a preset configuration file in a GRUB image file. The list of
240commands (@pxref{Commands}) are a superset of those supported on the
241command-line. An example configuration file is provided in
242@ref{Configuration}.
243
244@item Provide a menu interface
245A menu interface listing preset boot commands, with a programmable
246timeout, is available. There is no fixed limit on the number of boot
247entries, and the current implementation has space for several hundred.
248
249@item Have a flexible command-line interface
250A fairly flexible command-line interface, accessible from the menu,
251is available to edit any preset commands, or write a new boot command
252set from scratch. If no configuration file is present, GRUB drops to
253the command-line.
254
255The list of commands (@pxref{Commands}) are a subset of those supported
256for configuration files. Editing commands closely resembles the Bash
257command-line (@pxref{Command Line Editing, Bash, Command Line Editing,
258features, Bash Features}), with @key{TAB}-completion of commands,
259devices, partitions, and files in a directory depending on context.
260
261@item Support multiple filesystem types
262Support multiple filesystem types transparently, plus a useful explicit
263blocklist notation. The currently supported filesystem types are
264@dfn{BSD FFS}, @dfn{DOS FAT16 and FAT32}, @dfn{Minix fs}, @dfn{Linux
265ext2fs}, @dfn{ReiserFS}, @dfn{JFS}, @dfn{XFS}, and @dfn{VSTa
266fs}. @xref{Filesystem}, for more information.
267
268@item Support automatic decompression
269Can decompress files which were compressed by @command{gzip}. This
270function is both automatic and transparent to the user (i.e. all
271functions operate upon the uncompressed contents of the specified
272files). This greatly reduces a file size and loading time, a
273particularly great benefit for floppies.@footnote{There are a few
274pathological cases where loading a very badly organized ELF kernel might
275take longer, but in practice this never happen.}
276
277It is conceivable that some kernel modules should be loaded in a
278compressed state, so a different module-loading command can be specified
279to avoid uncompressing the modules.
280
281@item Access data on any installed device
282Support reading data from any or all floppies or hard disk(s) recognized
283by the BIOS, independent of the setting of the root device.
284
285@item Be independent of drive geometry translations
286Unlike many other boot loaders, GRUB makes the particular drive
287translation irrelevant. A drive installed and running with one
288translation may be converted to another translation without any adverse
289effects or changes in GRUB's configuration.
290
291@item Detect all installed @sc{ram}
292GRUB can generally find all the installed @sc{ram} on a PC-compatible
293machine. It uses an advanced BIOS query technique for finding all
294memory regions. As described on the Multiboot Specification (@pxref{Top,
295Multiboot Specification, Motivation, multiboot, The Multiboot
296Specification}), not all kernels make use of this information, but GRUB
297provides it for those who do.
298
299@item Support Logical Block Address mode
300In traditional disk calls (called @dfn{CHS mode}), there is a geometry
301translation problem, that is, the BIOS cannot access over 1024
302cylinders, so the accessible space is limited to at least 508 MB and to
303at most 8GB. GRUB can't universally solve this problem, as there is no
304standard interface used in all machines. However, several newer machines
305have the new interface, Logical Block Address (@dfn{LBA}) mode. GRUB
306automatically detects if LBA mode is available and uses it if
307available. In LBA mode, GRUB can access the entire disk.
308
309@item Support network booting
310GRUB is basically a disk-based boot loader but also has network
311support. You can load OS images from a network by using the @dfn{TFTP}
312protocol.
313
314@item Support remote terminals
315To support computers with no console, GRUB provides remote terminal
316support, so that you can control GRUB from a remote host. Only serial
317terminal support is implemented at the moment.
318@end table
319
320
321@node Role of a boot loader
322@section The role of a boot loader
323
324The following is a quotation from Gordon Matzigkeit, a GRUB fanatic:
325
326@quotation
327Some people like to acknowledge both the operating system and kernel when
328they talk about their computers, so they might say they use
329``GNU/Linux'' or ``GNU/Hurd''. Other people seem to think that the
330kernel is the most important part of the system, so they like to call
331their GNU operating systems ``Linux systems.''
332
333I, personally, believe that this is a grave injustice, because the
334@emph{boot loader} is the most important software of all. I used to
335refer to the above systems as either ``LILO''@footnote{The LInux LOader,
336a boot loader that everybody uses, but nobody likes.} or ``GRUB''
337systems.
338
339Unfortunately, nobody ever understood what I was talking about; now I
340just use the word ``GNU'' as a pseudonym for GRUB.
341
342So, if you ever hear people talking about their alleged ``GNU'' systems,
343remember that they are actually paying homage to the best boot loader
344around@dots{} GRUB!
345@end quotation
346
347We, the GRUB maintainers, do not (usually) encourage Gordon's level of
348fanaticism, but it helps to remember that boot loaders deserve
349recognition. We hope that you enjoy using GNU GRUB as much as we did
350writing it.
351
352
353@node Naming convention
354@chapter Naming convention
355
356The device syntax used in GRUB is a wee bit different from what you may
357have seen before in your operating system(s), and you need to know it so
358that you can specify a drive/partition.
359
360Look at the following examples and explanations:
361
362@example
363(fd0)
364@end example
365
366First of all, GRUB requires that the device name be enclosed with
367@samp{(} and @samp{)}. The @samp{fd} part means that it is a floppy
368disk. The number @samp{0} is the drive number, which is counted from
369@emph{zero}. This expression means that GRUB will use the whole floppy
370disk.
371
372@example
373(hd0,1)
374@end example
375
376Here, @samp{hd} means it is a hard disk drive. The first integer
377@samp{0} indicates the drive number, that is, the first hard disk, while
378the second integer, @samp{1}, indicates the partition number (or the
379@sc{pc} slice number in the BSD terminology). Once again, please note
380that the partition numbers are counted from @emph{zero}, not from
381one. This expression means the second partition of the first hard disk
382drive. In this case, GRUB uses one partition of the disk, instead of the
383whole disk.
384
385@example
386(hd0,4)
387@end example
388
389This specifies the first @dfn{extended partition} of the first hard disk
390drive. Note that the partition numbers for extended partitions are
391counted from @samp{4}, regardless of the actual number of primary
392partitions on your hard disk.
393
394@example
395(hd1,a)
396@end example
397
398This means the BSD @samp{a} partition of the second hard disk. If you
399need to specify which @sc{pc} slice number should be used, use something
400like this: @samp{(hd1,0,a)}. If the @sc{pc} slice number is omitted,
401GRUB searches for the first @sc{pc} slice which has a BSD @samp{a}
402partition.
403
404Of course, to actually access the disks or partitions with GRUB, you
405need to use the device specification in a command, like @samp{root
406(fd0)} or @samp{unhide (hd0,2)}. To help you find out which number
407specifies a partition you want, the GRUB command-line
408(@pxref{Command-line interface}) options have argument
409completion. This means that, for example, you only need to type
410
411@example
412root (
413@end example
414
415followed by a @key{TAB}, and GRUB will display the list of drives,
416partitions, or file names. So it should be quite easy to determine the
417name of your target partition, even with minimal knowledge of the
418syntax.
419
420Note that GRUB does @emph{not} distinguish IDE from SCSI - it simply
421counts the drive numbers from zero, regardless of their type. Normally,
422any IDE drive number is less than any SCSI drive number, although that
423is not true if you change the boot sequence by swapping IDE and SCSI
424drives in your BIOS.
425
426Now the question is, how to specify a file? Again, consider an
427example:
428
429@example
430(hd0,0)/vmlinuz
431@end example
432
433This specifies the file named @samp{vmlinuz}, found on the first
434partition of the first hard disk drive. Note that the argument
435completion works with file names, too.
436
437That was easy, admit it. Now read the next chapter, to find out how to
438actually install GRUB on your drive.
439
440
441@node Installation
442@chapter Installation
443
444In order to install GRUB as your boot loader, you need to first
445install the GRUB system and utilities under your UNIX-like operating
446system (@pxref{Obtaining and Building GRUB}). You can do this either
447from the source tarball, or as a package for your OS.
448
449After you have done that, you need to install the boot loader on a
450drive (floppy or hard disk). There are two ways of doing that - either
451using the utility @command{grub-install} (@pxref{Invoking
452grub-install}) on a UNIX-like OS, or by running GRUB itself from a
453floppy. These are quite similar, however the utility might probe a
454wrong BIOS drive, so you should be careful.
455
456Also, if you install GRUB on a UNIX-like OS, please make sure that you
457have an emergency boot disk ready, so that you can rescue your computer
458if, by any chance, your hard drive becomes unusable (unbootable).
459
460GRUB comes with boot images, which are normally put in the directory
461@file{/usr/lib/grub/i386-pc}. If you do not use grub-install, then
462you need to copy the files @file{stage1}, @file{stage2}, and
463@file{*stage1_5} to the directory @file{/boot/grub}, and run the
464@command{grub-set-default} (@pxref{Invoking grub-set-default}) if you
465intend to use @samp{default saved} (@pxref{default}) in your
466configuration file. Hereafter, the directory where GRUB images are
467initially placed (normally @file{/usr/lib/grub/i386-pc}) will be
468called the @dfn{image directory}, and the directory where the boot
469loader needs to find them (usually @file{/boot/grub}) will be called
470the @dfn{boot directory}.
471
472@menu
473* Creating a GRUB boot floppy::
474* Installing GRUB natively::
475* Installing GRUB using grub-install::
476* Making a GRUB bootable CD-ROM::
477@end menu
478
479
480@node Creating a GRUB boot floppy
481@section Creating a GRUB boot floppy
482
483To create a GRUB boot floppy, you need to take the files @file{stage1}
484and @file{stage2} from the image directory, and write them to the first
485and the second block of the floppy disk, respectively.
486
487@strong{Caution:} This procedure will destroy any data currently stored
488on the floppy.
489
490On a UNIX-like operating system, that is done with the following
491commands:
492
493@example
494@group
495# @kbd{cd /usr/lib/grub/i386-pc}
496# @kbd{dd if=stage1 of=/dev/fd0 bs=512 count=1}
4971+0 records in
4981+0 records out
499# @kbd{dd if=stage2 of=/dev/fd0 bs=512 seek=1}
500153+1 records in
501153+1 records out
502#
503@end group
504@end example
505
506The device file name may be different. Consult the manual for your OS.
507
508
509@node Installing GRUB natively
510@section Installing GRUB natively
511
512@strong{Caution:} Installing GRUB's stage1 in this manner will erase the
513normal boot-sector used by an OS.
514
515GRUB can currently boot GNU Mach, Linux, FreeBSD, NetBSD, and OpenBSD
516directly, so using it on a boot sector (the first sector of a
517partition) should be okay. But generally, it would be a good idea to
518back up the first sector of the partition on which you are installing
519GRUB's stage1. This isn't as important if you are installing GRUB on
520the first sector of a hard disk, since it's easy to reinitialize it
521(e.g. by running @samp{FDISK /MBR} from DOS).
522
523If you decide to install GRUB in the native environment, which is
524definitely desirable, you'll need to create a GRUB boot disk, and
525reboot your computer with it. Otherwise, see @ref{Installing GRUB using
526grub-install}.
527
528Once started, GRUB will show the command-line interface
529(@pxref{Command-line interface}). First, set the GRUB's @dfn{root
530device}@footnote{Note that GRUB's root device doesn't necessarily mean
531your OS's root partition; if you need to specify a root partition for
532your OS, add the argument into the command @command{kernel}.} to the
533partition containing the boot directory, like this:
534
535@example
536grub> @kbd{root (hd0,0)}
537@end example
538
539If you are not sure which partition actually holds this directory, use the
540command @command{find} (@pxref{find}), like this:
541
542@example
543grub> @kbd{find /boot/grub/stage1}
544@end example
545
546This will search for the file name @file{/boot/grub/stage1} and show the
547devices which contain the file.
548
549Once you've set the root device correctly, run the command
550@command{setup} (@pxref{setup}):
551
552@example
553grub> @kbd{setup (hd0)}
554@end example
555
556This command will install the GRUB boot loader on the Master Boot
557Record (MBR) of the first drive. If you want to put GRUB into the boot
558sector of a partition instead of putting it in the MBR, specify the
559partition into which you want to install GRUB:
560
561@example
562grub> @kbd{setup (hd0,0)}
563@end example
564
565If you install GRUB into a partition or a drive other than the first
566one, you must chain-load GRUB from another boot loader. Refer to the
567manual for the boot loader to know how to chain-load GRUB.
568
569After using the setup command, you will boot into GRUB without the
570GRUB floppy. See the chapter @ref{Booting} to find out how to boot
571your operating systems from GRUB.
572
573
574@node Installing GRUB using grub-install
575@section Installing GRUB using grub-install
576
577@strong{Caution:} This procedure is definitely less safe, because
578there are several ways in which your computer can become
579unbootable. For example, most operating systems don't tell GRUB how to
580map BIOS drives to OS devices correctly---GRUB merely @dfn{guesses}
581the mapping. This will succeed in most cases, but not
582always. Therefore, GRUB provides you with a map file called the
583@dfn{device map}, which you must fix if it is wrong. @xref{Device
584map}, for more details.
585
586If you still do want to install GRUB under a UNIX-like OS (such
587as @sc{gnu}), invoke the program @command{grub-install} (@pxref{Invoking
588grub-install}) as the superuser (@dfn{root}).
589
590The usage is basically very simple. You only need to specify one
591argument to the program, namely, where to install the boot loader. The
592argument can be either a device file (like @samp{/dev/hda}) or a
593partition specified in GRUB's notation. For example, under Linux the
594following will install GRUB into the MBR of the first IDE disk:
595
596@example
597# @kbd{grub-install /dev/hda}
598@end example
599
600Likewise, under GNU/Hurd, this has the same effect:
601
602@example
603# @kbd{grub-install /dev/hd0}
604@end example
605
606If it is the first BIOS drive, this is the same as well:
607
608@example
609# @kbd{grub-install '(hd0)'}
610@end example
611
612Or you can omit the parentheses:
613
614@example
615# @kbd{grub-install hd0}
616@end example
617
618But all the above examples assume that GRUB should use images under
619the root directory. If you want GRUB to use images under a directory
620other than the root directory, you need to specify the option
621@option{--root-directory}. The typical usage is that you create a GRUB
622boot floppy with a filesystem. Here is an example:
623
624@example
625@group
626# @kbd{mke2fs /dev/fd0}
627# @kbd{mount -t ext2 /dev/fd0 /mnt}
628# @kbd{grub-install --root-directory=/mnt fd0}
629# @kbd{umount /mnt}
630@end group
631@end example
632
633Another example is when you have a separate boot partition
634which is mounted at @file{/boot}. Since GRUB is a boot loader, it
635doesn't know anything about mountpoints at all. Thus, you need to run
636@command{grub-install} like this:
637
638@example
639# @kbd{grub-install --root-directory=/boot /dev/hda}
640@end example
641
642By the way, as noted above, it is quite difficult to guess BIOS drives
643correctly under a UNIX-like OS. Thus, @command{grub-install} will prompt
644you to check if it could really guess the correct mappings, after the
645installation. The format is defined in @ref{Device map}. Please be
646quite careful. If the output is wrong, it is unlikely that your
647computer will be able to boot with no problem.
648
649Note that @command{grub-install} is actually just a shell script and the
650real task is done by the grub shell @command{grub} (@pxref{Invoking the
651grub shell}). Therefore, you may run @command{grub} directly to install
652GRUB, without using @command{grub-install}. Don't do that, however,
653unless you are very familiar with the internals of GRUB. Installing a
654boot loader on a running OS may be extremely dangerous.
655
656
657@node Making a GRUB bootable CD-ROM
658@section Making a GRUB bootable CD-ROM
659
660GRUB supports the @dfn{no emulation mode} in the El Torito
661specification@footnote{El Torito is a specification for bootable CD
662using BIOS functions.}. This means that you can use the whole CD-ROM
663from GRUB and you don't have to make a floppy or hard disk image file,
664which can cause compatibility problems.
665
666For booting from a CD-ROM, GRUB uses a special Stage 2 called
b39f9d20 667@file{stage2_eltorito}. The only GRUB files you need to have in your
87a95d1f 668bootable CD-ROM are this @file{stage2_eltorito} and optionally a config file
669@file{menu.lst}. You don't need to use @file{stage1} or @file{stage2},
670because El Torito is quite different from the standard boot process.
671
672Here is an example of procedures to make a bootable CD-ROM
673image. First, make a top directory for the bootable image, say,
674@samp{iso}:
675
676@example
677$ @kbd{mkdir iso}
678@end example
679
680Make a directory for GRUB:
681
682@example
683$ @kbd{mkdir -p iso/boot/grub}
684@end example
685
686Copy the file @file{stage2_eltorito}:
687
688@example
689$ @kbd{cp /usr/lib/grub/i386-pc/stage2_eltorito iso/boot/grub}
690@end example
691
692If desired, make the config file @file{menu.lst} under @file{iso/boot/grub}
693(@pxref{Configuration}), and copy any files and directories for the disc to the
694directory @file{iso/}.
695
696Finally, make a ISO9660 image file like this:
697
698@example
699$ @kbd{mkisofs -R -b boot/grub/stage2_eltorito -no-emul-boot \
700 -boot-load-size 4 -boot-info-table -o grub.iso iso}
701@end example
702
703This produces a file named @file{grub.iso}, which then can be burned
704into a CD (or a DVD). @kbd{mkisofs} has already set up the disc to boot
b39f9d20 705from the @kbd{boot/grub/stage2_eltorito} file, so there is no need to
87a95d1f 706setup GRUB on the disc. (Note that the @kbd{-boot-load-size 4} bit is
707required for compatibility with the BIOS on many older machines.)
708
709You can use the device @samp{(cd)} to access a CD-ROM in your
b39f9d20 710config file. This is not required; GRUB automatically sets the root device
711to @samp{(cd)} when booted from a CD-ROM. It is only necessary to refer to
87a95d1f 712@samp{(cd)} if you want to access other drives as well.
713
714
715@node Booting
716@chapter Booting
717
718GRUB can load Multiboot-compliant kernels in a consistent way,
719but for some free operating systems you need to use some OS-specific
720magic.
721
722@menu
723* General boot methods:: How to boot OSes with GRUB generally
724* OS-specific notes:: Notes on some operating systems
725* Making your system robust:: How to make your system robust
726@end menu
727
728
729@node General boot methods
730@section How to boot operating systems
731
732GRUB has two distinct boot methods. One of the two is to load an
733operating system directly, and the other is to chain-load another boot
734loader which then will load an operating system actually. Generally
735speaking, the former is more desirable, because you don't need to
736install or maintain other boot loaders and GRUB is flexible enough to
737load an operating system from an arbitrary disk/partition. However,
738the latter is sometimes required, since GRUB doesn't support all the
739existing operating systems natively.
740
741@menu
742* Loading an operating system directly::
743* Chain-loading::
744@end menu
745
746
747@node Loading an operating system directly
748@subsection How to boot an OS directly with GRUB
749
750Multiboot (@pxref{Top, Multiboot Specification, Motivation, multiboot,
751The Multiboot Specification}) is the native format supported by GRUB.
752For the sake of convenience, there is also support for Linux, FreeBSD,
753NetBSD and OpenBSD. If you want to boot other operating systems, you
754will have to chain-load them (@pxref{Chain-loading}).
755
756Generally, GRUB can boot any Multiboot-compliant OS in the following
757steps:
758
759@enumerate
760@item
761Set GRUB's root device to the drive where the OS images are stored with
762the command @command{root} (@pxref{root}).
763
764@item
765Load the kernel image with the command @command{kernel} (@pxref{kernel}).
766
767@item
768If you need modules, load them with the command @command{module}
769(@pxref{module}) or @command{modulenounzip} (@pxref{modulenounzip}).
770
771@item
772Run the command @command{boot} (@pxref{boot}).
773@end enumerate
774
775Linux, FreeBSD, NetBSD and OpenBSD can be booted in a similar
776manner. You load a kernel image with the command @command{kernel} and
777then run the command @command{boot}. If the kernel requires some
778parameters, just append the parameters to @command{kernel}, after the
779file name of the kernel. Also, please refer to @ref{OS-specific notes},
780for information on your OS-specific issues.
781
782
783@node Chain-loading
784@subsection Load another boot loader to boot unsupported operating systems
785
786If you want to boot an unsupported operating system (e.g. Windows 95),
787chain-load a boot loader for the operating system. Normally, the boot
788loader is embedded in the @dfn{boot sector} of the partition on which
789the operating system is installed.
790
791@enumerate
792@item
793Set GRUB's root device to the partition by the command
794@command{rootnoverify} (@pxref{rootnoverify}):
795
796@example
797grub> @kbd{rootnoverify (hd0,0)}
798@end example
799
800@item
801Set the @dfn{active} flag in the partition using the command
802@command{makeactive}@footnote{This is not necessary for most of the
803modern operating systems.} (@pxref{makeactive}):
804
805@example
806grub> @kbd{makeactive}
807@end example
808
809@item
810Load the boot loader with the command @command{chainloader}
811(@pxref{chainloader}):
812
813@example
814grub> @kbd{chainloader +1}
815@end example
816
817@samp{+1} indicates that GRUB should read one sector from the start of
818the partition. The complete description about this syntax can be found
819in @ref{Block list syntax}.
820
821@item
822Run the command @command{boot} (@pxref{boot}).
823@end enumerate
824
825However, DOS and Windows have some deficiencies, so you might have to
826use more complicated instructions. @xref{DOS/Windows}, for more
827information.
828
829
830@node OS-specific notes
831@section Some caveats on OS-specific issues
832
833Here, we describe some caveats on several operating systems.
834
835@menu
836* GNU/Hurd::
837* GNU/Linux::
838* FreeBSD::
839* NetBSD::
840* OpenBSD::
841* DOS/Windows::
842* SCO UnixWare::
843* QNX::
844@end menu
845
846
847@node GNU/Hurd
848@subsection GNU/Hurd
849
850Since GNU/Hurd is Multiboot-compliant, it is easy to boot it; there is
851nothing special about it. But do not forget that you have to specify a
852root partition to the kernel.
853
854@enumerate
855@item
856Set GRUB's root device to the same drive as GNU/Hurd's. Probably the
857command @code{find /boot/gnumach} or similar can help you
858(@pxref{find}).
859
860@item
861Load the kernel and the module, like this:
862
863@example
864@group
865grub> @kbd{kernel /boot/gnumach root=hd0s1}
866grub> @kbd{module /boot/serverboot}
867@end group
868@end example
869
870@item
871Run the command @command{boot} (@pxref{boot}).
872@end enumerate
873
874
875@node GNU/Linux
876@subsection GNU/Linux
877
878It is relatively easy to boot GNU/Linux from GRUB, because it somewhat
879resembles to boot a Multiboot-compliant OS.
880
881@enumerate
882@item
883Set GRUB's root device to the same drive as GNU/Linux's. Probably the
884command @code{find /vmlinuz} or similar can help you (@pxref{find}).
885
886@item
887Load the kernel:
888
889@example
890grub> @kbd{kernel /vmlinuz root=/dev/hda1}
891@end example
892
893If you need to specify some kernel parameters, just append them to the
894command. For example, to set @option{vga} to @samp{ext}, do this:
895
896@example
897grub> @kbd{kernel /vmlinuz root=/dev/hda1 vga=ext}
898@end example
899
900See the documentation in the Linux source tree for complete
901information on the available options.
902
903@item
904If you use an initrd, execute the command @command{initrd}
905(@pxref{initrd}) after @command{kernel}:
906
907@example
908grub> @kbd{initrd /initrd}
909@end example
910
911@item
912Finally, run the command @command{boot} (@pxref{boot}).
913@end enumerate
914
915@strong{Caution:} If you use an initrd and specify the @samp{mem=}
916option to the kernel to let it use less than actual memory size, you
917will also have to specify the same memory size to GRUB. To let GRUB know
918the size, run the command @command{uppermem} @emph{before} loading the
919kernel. @xref{uppermem}, for more information.
920
921
922@node FreeBSD
923@subsection FreeBSD
924
925GRUB can load the kernel directly, either in ELF or a.out format. But
926this is not recommended, since FreeBSD's bootstrap interface sometimes
927changes heavily, so GRUB can't guarantee to pass kernel parameters
928correctly.
929
930Thus, we'd recommend loading the very flexible loader
931@file{/boot/loader} instead. See this example:
932
933@example
934@group
935grub> @kbd{root (hd0,a)}
936grub> @kbd{kernel /boot/loader}
937grub> @kbd{boot}
938@end group
939@end example
940
941
942@node NetBSD
943@subsection NetBSD
944
945GRUB can load NetBSD a.out and ELF directly, follow these steps:
946
947@enumerate
948@item
949Set GRUB's root device with @command{root} (@pxref{root}).
950
951@item
952Load the kernel with @command{kernel} (@pxref{kernel}). You should
953append the ugly option @option{--type=netbsd}, if you want to load an
954ELF kernel, like this:
955
956@example
957grub> @kbd{kernel --type=netbsd /netbsd-elf}
958@end example
959
960@item
961Run @command{boot} (@pxref{boot}).
962@end enumerate
963
964For now, however, GRUB doesn't allow you to pass kernel parameters, so
965it may be better to chain-load it instead. For more information, please
966see @ref{Chain-loading}.
967
968
969@node OpenBSD
970@subsection OpenBSD
971
972The booting instruction is exactly the same as for NetBSD
973(@pxref{NetBSD}).
974
975
976@node DOS/Windows
977@subsection DOS/Windows
978
979GRUB cannot boot DOS or Windows directly, so you must chain-load them
980(@pxref{Chain-loading}). However, their boot loaders have some critical
981deficiencies, so it may not work to just chain-load them. To overcome
982the problems, GRUB provides you with two helper functions.
983
984If you have installed DOS (or Windows) on a non-first hard disk, you
985have to use the disk swapping technique, because that OS cannot boot
986from any disks but the first one. The workaround used in GRUB is the
987command @command{map} (@pxref{map}), like this:
988
989@example
990@group
991grub> @kbd{map (hd0) (hd1)}
992grub> @kbd{map (hd1) (hd0)}
993@end group
994@end example
995
996This performs a @dfn{virtual} swap between your first and second hard
997drive.
998
999@strong{Caution:} This is effective only if DOS (or Windows) uses BIOS
1000to access the swapped disks. If that OS uses a special driver for the
1001disks, this probably won't work.
1002
1003Another problem arises if you installed more than one set of DOS/Windows
1004onto one disk, because they could be confused if there are more than one
1005primary partitions for DOS/Windows. Certainly you should avoid doing
1006this, but there is a solution if you do want to do so. Use the partition
1007hiding/unhiding technique.
1008
1009If GRUB @dfn{hide}s a DOS (or Windows) partition (@pxref{hide}), DOS (or
1010Windows) will ignore the partition. If GRUB @dfn{unhide}s a DOS (or
1011Windows) partition (@pxref{unhide}), DOS (or Windows) will detect the
1012partition. Thus, if you have installed DOS (or Windows) on the first
1013and the second partition of the first hard disk, and you want to boot
1014the copy on the first partition, do the following:
1015
1016@example
1017@group
1018grub> @kbd{unhide (hd0,0)}
1019grub> @kbd{hide (hd0,1)}
1020grub> @kbd{rootnoverify (hd0,0)}
1021grub> @kbd{chainloader +1}
1022grub> @kbd{makeactive}
1023grub> @kbd{boot}
1024@end group
1025@end example
1026
1027
1028@node SCO UnixWare
1029@subsection SCO UnixWare
1030
1031It is known that the signature in the boot loader for SCO UnixWare is
1032wrong, so you will have to specify the option @option{--force} to
1033@command{chainloader} (@pxref{chainloader}), like this:
1034
1035@example
1036@group
1037grub> @kbd{rootnoverify (hd1,0)}
1038grub> @kbd{chainloader --force +1}
1039grub> @kbd{makeactive}
1040grub> @kbd{boot}
1041@end group
1042@end example
1043
1044
1045@node QNX
1046@subsection QNX
1047
1048QNX seems to use a bigger boot loader, so you need to boot it up, like
1049this:
1050
1051@example
1052@group
1053grub> @kbd{rootnoverify (hd1,1)}
1054grub> @kbd{chainloader +4}
1055grub> @kbd{boot}
1056@end group
1057@end example
1058
1059
1060@node Making your system robust
1061@section How to make your system robust
1062
1063When you test a new kernel or a new OS, it is important to make sure
1064that your computer can boot even if the new system is unbootable. This
1065is crucial especially if you maintain servers or remote systems. To
1066accomplish this goal, you need to set up two things:
1067
1068@enumerate
1069@item
1070You must maintain a system which is always bootable. For instance, if
1071you test a new kernel, you need to keep a working kernel in a
1072different place. And, it would sometimes be very nice to even have a
1073complete copy of a working system in a different partition or disk.
1074
1075@item
1076You must direct GRUB to boot a working system when the new system
1077fails. This is possible with the @dfn{fallback} system in GRUB.
1078@end enumerate
1079
1080The former requirement is very specific to each OS, so this
1081documentation does not cover that topic. It is better to consult some
1082backup tools.
1083
1084So let's see the GRUB part. There are two possibilities: one of them
1085is quite simple but not very robust, and the other is a bit complex to
1086set up but probably the best solution to make sure that your system
1087can start as long as GRUB itself is bootable.
1088
1089@menu
1090* Booting once-only::
1091* Booting fallback systems::
1092@end menu
1093
1094
1095@node Booting once-only
1096@subsection Booting once-only
1097
1098You can teach GRUB to boot an entry only at next boot time. Suppose
1099that your have an old kernel @file{old_kernel} and a new kernel
1100@file{new_kernel}. You know that @file{old_kernel} can boot
1101your system correctly, and you want to test @file{new_kernel}.
1102
1103To ensure that your system will go back to the old kernel even if the
1104new kernel fails (e.g. it panics), you can specify that GRUB should
1105try the new kernel only once and boot the old kernel after that.
1106
1107First, modify your configuration file. Here is an example:
1108
1109@example
1110@group
1111default saved # This is important!!!
1112timeout 10
1113
1114title the old kernel
1115root (hd0,0)
1116kernel /old_kernel
1117savedefault
1118
1119title the new kernel
1120root (hd0,0)
1121kernel /new_kernel
1122savedefault 0 # This is important!!!
1123@end group
1124@end example
1125
1126Note that this configuration file uses @samp{default saved}
1127(@pxref{default}) at the head and @samp{savedefault 0}
1128(@pxref{savedefault}) in the entry for the new kernel. This means
1129that GRUB boots a saved entry by default, and booting the entry for the
1130new kernel saves @samp{0} as the saved entry.
1131
1132With this configuration file, after all, GRUB always tries to boot the
1133old kernel after it booted the new one, because @samp{0} is the entry
1134of @code{the old kernel}.
1135
1136The next step is to tell GRUB to boot the new kernel at next boot
1137time. For this, execute @command{grub-set-default} (@pxref{Invoking
1138grub-set-default}):
1139
1140@example
1141# @kbd{grub-set-default 1}
1142@end example
1143
1144This command sets the saved entry to @samp{1}, that is, to the new
1145kernel.
1146
1147This method is useful, but still not very robust, because GRUB stops
1148booting, if there is any error in the boot entry, such that the new
1149kernel has an invalid executable format. Thus, it it even better to
1150use the @dfn{fallback} mechanism of GRUB. Look at next subsection for
1151this feature.
1152
1153
1154@node Booting fallback systems
1155@subsection Booting fallback systems
1156
1157GRUB supports a fallback mechanism of booting one or more other
1158entries if a default boot entry fails. You can specify multiple
1159fallback entries if you wish.
1160
1161Suppose that you have three systems, @samp{A}, @samp{B} and
1162@samp{C}. @samp{A} is a system which you want to boot by
1163default. @samp{B} is a backup system which is supposed to boot
1164safely. @samp{C} is another backup system which is used in case where
1165@samp{B} is broken.
1166
1167Then you may want GRUB to boot the first system which is bootable
1168among @samp{A}, @samp{B} and @samp{C}. A configuration file can be
1169written in this way:
1170
1171@example
1172@group
1173default saved # This is important!!!
1174timeout 10
1175fallback 1 2 # This is important!!!
1176
1177title A
1178root (hd0,0)
1179kernel /kernel
1180savedefault fallback # This is important!!!
1181
1182title B
1183root (hd1,0)
1184kernel /kernel
1185savedefault fallback # This is important!!!
1186
1187title C
1188root (hd2,0)
1189kernel /kernel
1190savedefault
1191@end group
1192@end example
1193
1194Note that @samp{default saved} (@pxref{default}), @samp{fallback 1 2}
1195and @samp{savedefault fallback} are used. GRUB will boot a saved entry
1196by default and save a fallback entry as next boot entry with this
1197configuration.
1198
1199When GRUB tries to boot @samp{A}, GRUB saves @samp{1} as next boot
1200entry, because the command @command{fallback} specifies that @samp{1}
1201is the first fallback entry. The entry @samp{1} is @samp{B}, so GRUB
1202will try to boot @samp{B} at next boot time.
1203
1204Likewise, when GRUB tries to boot @samp{B}, GRUB saves @samp{2} as
1205next boot entry, because @command{fallback} specifies @samp{2} as next
1206fallback entry. This makes sure that GRUB will boot @samp{C} after
1207booting @samp{B}.
1208
1209It is noteworthy that GRUB uses fallback entries both when GRUB
1210itself fails in booting an entry and when @samp{A} or @samp{B} fails
1211in starting up your system. So this solution ensures that your system
1212is started even if GRUB cannot find your kernel or if your kernel
1213panics.
1214
1215However, you need to run @command{grub-set-default} (@pxref{Invoking
1216grub-set-default}) when @samp{A} starts correctly or you fix @samp{A}
1217after it crashes, since GRUB always sets next boot entry to a fallback
1218entry. You should run this command in a startup script such as
1219@file{rc.local} to boot @samp{A} by default:
1220
1221@example
1222# @kbd{grub-set-default 0}
1223@end example
1224
1225where @samp{0} is the number of the boot entry for the system
1226@samp{A}.
1227
1228If you want to see what is current default entry, you can look at the
1229file @file{/boot/grub/default} (or @file{/grub/default} in
1230some systems). Because this file is plain-text, you can just
1231@command{cat} this file. But it is strongly recommended @strong{not to
1232modify this file directly}, because GRUB may fail in saving a default
1233entry in this file, if you change this file in an unintended
1234manner. Therefore, you should use @command{grub-set-default} when you
1235need to change the default entry.
1236
1237
1238@node Configuration
1239@chapter Configuration
1240
1241You've probably noticed that you need to type several commands to boot your
1242OS. There's a solution to that - GRUB provides a menu interface
1243(@pxref{Menu interface}) from which you can select an item (using arrow
1244keys) that will do everything to boot an OS.
1245
1246To enable the menu, you need a configuration file,
1247@file{menu.lst} under the boot directory. We'll analyze an example
1248file.
1249
1250The file first contains some general settings, the menu interface
1251related options. You can put these commands (@pxref{Menu-specific
1252commands}) before any of the items (starting with @command{title}
1253(@pxref{title})).
1254
1255@example
1256@group
1257#
1258# Sample boot menu configuration file
1259#
1260@end group
1261@end example
1262
1263As you may have guessed, these lines are comments. Lines starting with a
1264hash character (@samp{#}), and blank lines, are ignored by GRUB.
1265
1266@example
1267@group
1268# By default, boot the first entry.
1269default 0
1270@end group
1271@end example
1272
1273The first entry (here, counting starts with number zero, not one!) will
1274be the default choice.
1275
1276@example
1277@group
1278# Boot automatically after 30 secs.
1279timeout 30
1280@end group
1281@end example
1282
1283As the comment says, GRUB will boot automatically in 30 seconds, unless
1284interrupted with a keypress.
1285
1286@example
1287@group
1288# Fallback to the second entry.
1289fallback 1
1290@end group
1291@end example
1292
1293If, for any reason, the default entry doesn't work, fall back to the
1294second one (this is rarely used, for obvious reasons).
1295
1296Note that the complete descriptions of these commands, which are menu
1297interface specific, can be found in @ref{Menu-specific
1298commands}. Other descriptions can be found in @ref{Commands}.
1299
1300Now, on to the actual OS definitions. You will see that each entry
1301begins with a special command, @command{title} (@pxref{title}), and the
1302action is described after it. Note that there is no command
1303@command{boot} (@pxref{boot}) at the end of each item. That is because
1304GRUB automatically executes @command{boot} if it loads other commands
1305successfully.
1306
1307The argument for the command @command{title} is used to display a short
1308title/description of the entry in the menu. Since @command{title}
1309displays the argument as is, you can write basically anything there.
1310
1311@example
1312@group
1313# For booting GNU/Hurd
1314title GNU/Hurd
1315root (hd0,0)
1316kernel /boot/gnumach.gz root=hd0s1
1317module /boot/serverboot.gz
1318@end group
1319@end example
1320
1321This boots GNU/Hurd from the first hard disk.
1322
1323@example
1324@group
1325# For booting GNU/Linux
1326title GNU/Linux
1327kernel (hd1,0)/vmlinuz root=/dev/hdb1
1328@end group
1329@end example
1330
1331This boots GNU/Linux, but from the second hard disk.
1332
1333@example
1334@group
1335# For booting Mach (getting kernel from floppy)
1336title Utah Mach4 multiboot
1337root (hd0,2)
1338pause Insert the diskette now^G!!
1339kernel (fd0)/boot/kernel root=hd0s3
1340module (fd0)/boot/bootstrap
1341@end group
1342@end example
1343
1344This boots Mach with a kernel on a floppy, but the root filesystem at
1345hd0s3. It also contains a @command{pause} line (@pxref{pause}), which
1346will cause GRUB to display a prompt and delay, before actually executing
1347the rest of the commands and booting.
1348
1349@example
1350@group
1351# For booting FreeBSD
1352title FreeBSD
1353root (hd0,2,a)
1354kernel /boot/loader
1355@end group
1356@end example
1357
1358This item will boot FreeBSD kernel loaded from the @samp{a} partition of
1359the third @sc{pc} slice of the first hard disk.
1360
1361@example
1362@group
1363# For booting OS/2
1364title OS/2
1365root (hd0,1)
1366makeactive
1367# chainload OS/2 bootloader from the first sector
1368chainloader +1
1369# This is similar to "chainload", but loads a specific file
1370#chainloader /boot/chain.os2
1371@end group
1372@end example
1373
1374This will boot OS/2, using a chain-loader (@pxref{Chain-loading}).
1375
1376@example
1377@group
1378# For booting Windows NT or Windows95
1379title Windows NT / Windows 95 boot menu
1380root (hd0,0)
1381makeactive
1382chainloader +1
1383# For loading DOS if Windows NT is installed
1384# chainload /bootsect.dos
1385@end group
1386@end example
1387
1388The same as the above, but for Windows.
1389
1390@example
1391@group
1392# For installing GRUB into the hard disk
1393title Install GRUB into the hard disk
1394root (hd0,0)
1395setup (hd0)
1396@end group
1397@end example
1398
1399This will just (re)install GRUB onto the hard disk.
1400
1401@example
1402# Change the colors.
1403title Change the colors
1404color light-green/brown blink-red/blue
1405@end example
1406
1407In the last entry, the command @command{color} is used (@pxref{color}),
1408to change the menu colors (try it!). This command is somewhat special,
1409because it can be used both in the command-line and in the menu. GRUB
1410has several such commands, see @ref{General commands}.
1411
1412We hope that you now understand how to use the basic features of
1413GRUB. To learn more about GRUB, see the following chapters.
1414
1415
1416@node Network
1417@chapter Downloading OS images from a network
1418
1419Although GRUB is a disk-based boot loader, it does provide network
1420support. To use the network support, you need to enable at least one
1421network driver in the GRUB build process. For more information please
1422see @file{netboot/README.netboot} in the source distribution.
1423
1424@menu
1425* General usage of network support::
1426* Diskless::
1427@end menu
1428
1429
1430@node General usage of network support
1431@section How to set up your network
1432
1433GRUB requires a file server and optionally a server that will assign an
1434IP address to the machine on which GRUB is running. For the former, only
1435TFTP is supported at the moment. The latter is either BOOTP, DHCP or a
1436RARP server@footnote{RARP is not advised, since it cannot serve much
1437information}. It is not necessary to run both the servers on one
1438computer. How to configure these servers is beyond the scope of this
1439document, so please refer to the manuals specific to those
1440protocols/servers.
1441
1442If you decided to use a server to assign an IP address, set up the
1443server and run @command{bootp} (@pxref{bootp}), @command{dhcp}
1444(@pxref{dhcp}) or @command{rarp} (@pxref{rarp}) for BOOTP, DHCP or RARP,
1445respectively. Each command will show an assigned IP address, a netmask,
1446an IP address for your TFTP server and a gateway. If any of the
1447addresses is wrong or it causes an error, probably the configuration of
1448your servers isn't set up properly.
1449
1450Otherwise, run @command{ifconfig}, like this:
1451
1452@example
1453grub> @kbd{ifconfig --address=192.168.110.23 --server=192.168.110.14}
1454@end example
1455
1456You can also use @command{ifconfig} in conjuction with @command{bootp},
1457@command{dhcp} or @command{rarp} (e.g. to reassign the server address
1458manually). @xref{ifconfig}, for more details.
1459
1460Finally, download your OS images from your network. The network can be
1461accessed using the network drive @samp{(nd)}. Everything else is very
1462similar to the normal instructions (@pxref{Booting}).
1463
1464Here is an example:
1465
1466@example
1467@group
1468grub> @kbd{bootp}
1469Probing... [NE*000]
1470NE2000 base ...
1471Address: 192.168.110.23 Netmask: 255.255.255.0
1472Server: 192.168.110.14 Gateway: 192.168.110.1
1473
1474grub> @kbd{root (nd)}
1475grub> @kbd{kernel /tftproot/gnumach.gz root=sd0s1}
1476grub> @kbd{module /tftproot/serverboot.gz}
1477grub> @kbd{boot}
1478@end group
1479@end example
1480
1481
1482@node Diskless
1483@section Booting from a network
1484
1485It is sometimes very useful to boot from a network, especially when you
1486use a machine which has no local disk. In this case, you need to obtain
1487a kind of Net Boot @sc{rom}, such as a PXE @sc{rom} or a free software
1488package like Etherboot. Such a Boot @sc{rom} first boots the machine,
1489sets up the network card installed into the machine, and downloads a
1490second stage boot image from the network. Then, the second image will
1491try to boot an operating system actually from the network.
1492
1493GRUB provides two second stage images, @file{nbgrub} and
1494@file{pxegrub} (@pxref{Images}). These images are the same as the
1495normal Stage 2, except that they set up a network automatically, and try
1496to load a configuration file from the network, if specified. The usage
1497is very simple: If the machine has a PXE @sc{rom}, use
1498@file{pxegrub}. If the machine has an NBI loader such as Etherboot, use
1499@file{nbgrub}. There is no difference between them except their
1500formats. Since the way to load a second stage image you want to use
1501should be described in the manual on your Net Boot @sc{rom}, please
1502refer to the manual, for more information.
1503
1504However, there is one thing specific to GRUB. Namely, how to specify a
1505configuration file in a BOOTP/DHCP server. For now, GRUB uses the tag
1506@samp{150}, to get the name of a configuration file. The following is an
1507example with a BOOTP configuration:
1508
1509@example
1510@group
1511.allhost:hd=/tmp:bf=null:\
1512 :ds=145.71.35.1 145.71.32.1:\
1513 :sm=255.255.254.0:\
1514 :gw=145.71.35.1:\
1515 :sa=145.71.35.5:
1516
1517foo:ht=1:ha=63655d0334a7:ip=145.71.35.127:\
1518 :bf=/nbgrub:\
1519 :tc=.allhost:\
1520 :T150="(nd)/tftpboot/menu.lst.foo":
1521@end group
1522@end example
1523
1524Note that you should specify the drive name @code{(nd)} in the name of
1525the configuration file. This is because you might change the root drive
1526before downloading the configuration from the TFTP server when the
1527preset menu feature is used (@pxref{Preset Menu}).
1528
1529See the manual of your BOOTP/DHCP server for more information. The
1530exact syntax should differ a little from the example.
1531
1532
1533@node Serial terminal
1534@chapter Using GRUB via a serial line
1535
1536This chapter describes how to use the serial terminal support in GRUB.
1537
1538If you have many computers or computers with no display/keyboard, it
1539could be very useful to control the computers through serial
1540communications. To connect one computer with another via a serial line,
1541you need to prepare a null-modem (cross) serial cable, and you may need
1542to have multiport serial boards, if your computer doesn't have extra
1543serial ports. In addition, a terminal emulator is also required, such as
1544minicom. Refer to a manual of your operating system, for more
1545information.
1546
1547As for GRUB, the instruction to set up a serial terminal is quite
1548simple. First of all, make sure that you haven't specified the option
1549@option{--disable-serial} to the configure script when you built your
1550GRUB images. If you get them in binary form, probably they have serial
1551terminal support already.
1552
1553Then, initialize your serial terminal after GRUB starts up. Here is an
1554example:
1555
1556@example
1557@group
1558grub> @kbd{serial --unit=0 --speed=9600}
1559grub> @kbd{terminal serial}
1560@end group
1561@end example
1562
1563The command @command{serial} initializes the serial unit 0 with the
1564speed 9600bps. The serial unit 0 is usually called @samp{COM1}, so, if
1565you want to use COM2, you must specify @samp{--unit=1} instead. This
1566command accepts many other options, so please refer to @ref{serial},
1567for more details.
1568
1569The command @command{terminal} (@pxref{terminal}) chooses which type of
1570terminal you want to use. In the case above, the terminal will be a
1571serial terminal, but you can also pass @code{console} to the command,
1572as @samp{terminal serial console}. In this case, a terminal in which
1573you press any key will be selected as a GRUB terminal.
1574
1575However, note that GRUB assumes that your terminal emulator is
1576compatible with VT100 by default. This is true for most terminal
1577emulators nowadays, but you should pass the option @option{--dumb} to
1578the command if your terminal emulator is not VT100-compatible or
1579implements few VT100 escape sequences. If you specify this option then
1580GRUB provides you with an alternative menu interface, because the normal
1581menu requires several fancy features of your terminal.
1582
1583
1584@node Preset Menu
1585@chapter Embedding a configuration file into GRUB
1586
1587GRUB supports a @dfn{preset menu} which is to be always loaded before
1588starting. The preset menu feature is useful, for example, when your
1589computer has no console but a serial cable. In this case, it is
1590critical to set up the serial terminal as soon as possible, since you
1591cannot see any message until the serial terminal begins to work. So it
1592is good to run the commands @command{serial} (@pxref{serial}) and
1593@command{terminal} (@pxref{terminal}) before anything else at the
1594start-up time.
1595
1596How the preset menu works is slightly complicated:
1597
1598@enumerate
1599@item
1600GRUB checks if the preset menu feature is used, and loads the preset
1601menu, if available. This includes running commands and reading boot
1602entries, like an ordinary configuration file.
1603
1604@item
1605GRUB checks if the configuration file is available. Note that this check
1606is performed @strong{regardless of the existence of the preset
1607menu}. The configuration file is loaded even if the preset menu was
1608loaded.
1609
1610@item
1611If the preset menu includes any boot entries, they are cleared when
1612the configuration file is loaded. It doesn't matter whether the
1613configuration file has any entries or no entry. The boot entries in the
1614preset menu are used only when GRUB fails in loading the configuration
1615file.
1616@end enumerate
1617
1618To enable the preset menu feature, you must rebuild GRUB specifying a
1619file to the configure script with the option
1620@option{--enable-preset-menu}. The file has the same semantics as
1621normal configuration files (@pxref{Configuration}).
1622
1623Another point you should take care is that the diskless support
1624(@pxref{Diskless}) diverts the preset menu. Diskless images embed a
1625preset menu to execute the command @command{bootp} (@pxref{bootp})
1626automatically, unless you specify your own preset menu to the configure
1627script. This means that you must put commands to initialize a network in
1628the preset menu yourself, because diskless images don't set it up
1629implicitly, when you use the preset menu explicitly.
1630
1631Therefore, a typical preset menu used with diskless support would be
1632like this:
1633
1634@example
1635@group
1636# Set up the serial terminal, first of all.
1637serial --unit=0 --speed=19200
1638terminal --timeout=0 serial
1639
1640# Initialize the network.
1641dhcp
1642@end group
1643@end example
1644
1645
1646@node Security
1647@chapter Protecting your computer from cracking
1648
1649You may be interested in how to prevent ordinary users from doing
1650whatever they like, if you share your computer with other people. So
1651this chapter describes how to improve the security of GRUB.
1652
1653One thing which could be a security hole is that the user can do too
1654many things with GRUB, because GRUB allows one to modify its configuration
1655and run arbitrary commands at run-time. For example, the user can even
1656read @file{/etc/passwd} in the command-line interface by the command
1657@command{cat} (@pxref{cat}). So it is necessary to disable all the
1658interactive operations.
1659
1660Thus, GRUB provides a @dfn{password} feature, so that only administrators
1661can start the interactive operations (i.e. editing menu entries and
1662entering the command-line interface). To use this feature, you need to
1663run the command @command{password} in your configuration file
1664(@pxref{password}), like this:
1665
1666@example
1667password --md5 PASSWORD
1668@end example
1669
1670If this is specified, GRUB disallows any interactive control, until you
1671press the key @key{p} and enter a correct password. The option
1672@option{--md5} tells GRUB that @samp{PASSWORD} is in MD5 format. If it
1673is omitted, GRUB assumes the @samp{PASSWORD} is in clear text.
1674
1675You can encrypt your password with the command @command{md5crypt}
1676(@pxref{md5crypt}). For example, run the grub shell (@pxref{Invoking the
1677grub shell}), and enter your password:
1678
1679@example
1680@group
1681grub> md5crypt
1682Password: **********
1683Encrypted: $1$U$JK7xFegdxWH6VuppCUSIb.
1684@end group
1685@end example
1686
1687Then, cut and paste the encrypted password to your configuration file.
1688
1689Also, you can specify an optional argument to @command{password}. See
1690this example:
1691
1692@example
1693password PASSWORD /boot/grub/menu-admin.lst
1694@end example
1695
1696In this case, GRUB will load @file{/boot/grub/menu-admin.lst} as a
1697configuration file when you enter the valid password.
1698
1699Another thing which may be dangerous is that any user can choose any
1700menu entry. Usually, this wouldn't be problematic, but you might want to
1701permit only administrators to run some of your menu entries, such as an
1702entry for booting an insecure OS like DOS.
1703
1704GRUB provides the command @command{lock} (@pxref{lock}). This command
1705always fails until you enter the valid password, so you can use it, like
1706this:
1707
1708@example
1709@group
1710title Boot DOS
1711lock
1712rootnoverify (hd0,1)
1713makeactive
1714chainload +1
1715@end group
1716@end example
1717
1718You should insert @command{lock} right after @command{title}, because
1719any user can execute commands in an entry until GRUB encounters
1720@command{lock}.
1721
1722You can also use the command @command{password} instead of
1723@command{lock}. In this case the boot process will ask for the password
1724and stop if it was entered incorrectly. Since the @command{password}
1725takes its own @var{PASSWORD} argument this is useful if you want
1726different passwords for different entries.
1727
1728
1729@node Images
1730@chapter GRUB image files
1731
1732GRUB consists of several images: two essential stages, optional stages
1733called @dfn{Stage 1.5}, one image for bootable CD-ROM, and two network
1734boot images. Here is a short overview of them. @xref{Internals}, for
1735more details.
1736
1737@table @file
1738@item stage1
1739This is an essential image used for booting up GRUB. Usually, this is
1740embedded in an MBR or the boot sector of a partition. Because a PC boot
1741sector is 512 bytes, the size of this image is exactly 512 bytes.
1742
1743All @file{stage1} must do is to load Stage 2 or Stage 1.5 from a local
1744disk. Because of the size restriction, @file{stage1} encodes the
1745location of Stage 2 (or Stage 1.5) in a block list format, so it never
1746understand any filesystem structure.
1747
1748@item stage2
1749This is the core image of GRUB. It does everything but booting up
1750itself. Usually, this is put in a filesystem, but that is not required.
1751
1752@item e2fs_stage1_5
1753@itemx fat_stage1_5
1754@itemx ffs_stage1_5
1755@itemx jfs_stage1_5
1756@itemx minix_stage1_5
1757@itemx reiserfs_stage1_5
1758@itemx vstafs_stage1_5
1759@itemx xfs_stage1_5
1760
1761These are called @dfn{Stage 1.5}, because they serve as a bridge
1762between @file{stage1} and @file{stage2}, that is to say, Stage 1.5 is
1763loaded by Stage 1 and Stage 1.5 loads Stage 2. The difference between
1764@file{stage1} and @file{*_stage1_5} is that the former doesn't
1765understand any filesystem while the latter understands one filesystem
1766(e.g. @file{e2fs_stage1_5} understands ext2fs). So you can move the
1767Stage 2 image to another location safely, even after GRUB has been
1768installed.
1769
1770While Stage 2 cannot generally be embedded in a fixed area as the size
1771is so large, Stage 1.5 can be installed into the area right after an MBR,
1772or the boot loader area of a ReiserFS or a FFS.
1773
1774@item stage2_eltorito
1775This is a boot image for CD-ROMs using the @dfn{no emulation mode} in
1776El Torito specification. This is identical to Stage 2, except that
1777this boots up without Stage 1 and sets up a special drive @samp{(cd)}.
1778
1779@item nbgrub
1780This is a network boot image for the Network Image Proposal used by some
1781network boot loaders, such as Etherboot. This is mostly the same as
1782Stage 2, but it also sets up a network and loads a configuration file
1783from the network.
1784
1785@item pxegrub
1786This is another network boot image for the Preboot Execution Environment
1787used by several Netboot ROMs. This is identical to @file{nbgrub}, except
1788for the format.
1789@end table
1790
1791
1792@node Filesystem
1793@chapter Filesystem syntax and semantics
1794
1795GRUB uses a special syntax for specifying disk drives which can be
1796accessed by BIOS. Because of BIOS limitations, GRUB cannot distinguish
1797between IDE, ESDI, SCSI, or others. You must know yourself which BIOS
1798device is equivalent to which OS device. Normally, that will be clear if
1799you see the files in a device or use the command @command{find}
1800(@pxref{find}).
1801
1802@menu
1803* Device syntax:: How to specify devices
1804* File name syntax:: How to specify files
1805* Block list syntax:: How to specify block lists
1806@end menu
1807
1808
1809@node Device syntax
1810@section How to specify devices
1811
1812The device syntax is like this:
1813
1814@example
1815@code{(@var{device}[,@var{part-num}][,@var{bsd-subpart-letter}])}
1816@end example
1817
1818@samp{[]} means the parameter is optional. @var{device} should be
1819either @samp{fd} or @samp{hd} followed by a digit, like @samp{fd0}.
1820But you can also set @var{device} to a hexadecimal or a decimal number
1821which is a BIOS drive number, so the following are equivalent:
1822
1823@example
1824(hd0)
1825(0x80)
1826(128)
1827@end example
1828
1829@var{part-num} represents the partition number of @var{device}, starting
1830from zero for primary partitions and from four for extended partitions,
1831and @var{bsd-subpart-letter} represents the BSD disklabel subpartition,
1832such as @samp{a} or @samp{e}.
1833
1834A shortcut for specifying BSD subpartitions is
1835@code{(@var{device},@var{bsd-subpart-letter})}, in this case, GRUB
1836searches for the first PC partition containing a BSD disklabel, then
1837finds the subpartition @var{bsd-subpart-letter}. Here is an example:
1838
1839@example
1840(hd0,a)
1841@end example
1842
1843The syntax @samp{(hd0)} represents using the entire disk (or the
1844MBR when installing GRUB), while the syntax @samp{(hd0,0)}
1845represents using the first partition of the disk (or the boot sector
1846of the partition when installing GRUB).
1847
1848If you enabled the network support, the special drive, @samp{(nd)}, is
1849also available. Before using the network drive, you must initialize the
1850network. @xref{Network}, for more information.
1851
1852If you boot GRUB from a CD-ROM, @samp{(cd)} is available. @xref{Making
1853a GRUB bootable CD-ROM}, for details.
1854
1855
1856@node File name syntax
1857@section How to specify files
1858
1859There are two ways to specify files, by @dfn{absolute file name} and by
1860@dfn{block list}.
1861
1862An absolute file name resembles a Unix absolute file name, using
1863@samp{/} for the directory separator (not @samp{\} as in DOS). One
1864example is @samp{(hd0,0)/boot/grub/menu.lst}. This means the file
1865@file{/boot/grub/menu.lst} in the first partition of the first hard
1866disk. If you omit the device name in an absolute file name, GRUB uses
1867GRUB's @dfn{root device} implicitly. So if you set the root device to,
1868say, @samp{(hd1,0)} by the command @command{root} (@pxref{root}), then
1869@code{/boot/kernel} is the same as @code{(hd1,0)/boot/kernel}.
1870
1871
1872@node Block list syntax
1873@section How to specify block lists
1874
1875A block list is used for specifying a file that doesn't appear in the
1876filesystem, like a chainloader. The syntax is
1877@code{[@var{offset}]+@var{length}[,[@var{offset}]+@var{length}]@dots{}}.
1878Here is an example:
1879
1880@example
1881@code{0+100,200+1,300+300}
1882@end example
1883
1884This represents that GRUB should read blocks 0 through 99, block 200,
1885and blocks 300 through 599. If you omit an offset, then GRUB assumes
1886the offset is zero.
1887
1888Like the file name syntax (@pxref{File name syntax}), if a blocklist
1889does not contain a device name, then GRUB uses GRUB's @dfn{root
1890device}. So @code{(hd0,1)+1} is the same as @code{+1} when the root
1891device is @samp{(hd0,1)}.
1892
1893
1894@node Interface
1895@chapter GRUB's user interface
1896
1897GRUB has both a simple menu interface for choosing preset entries from a
1898configuration file, and a highly flexible command-line for performing
1899any desired combination of boot commands.
1900
1901GRUB looks for its configuration file as soon as it is loaded. If one
1902is found, then the full menu interface is activated using whatever
1903entries were found in the file. If you choose the @dfn{command-line} menu
1904option, or if the configuration file was not found, then GRUB drops to
1905the command-line interface.
1906
1907@menu
1908* Command-line interface:: The flexible command-line interface
1909* Menu interface:: The simple menu interface
1910* Menu entry editor:: Editing a menu entry
1911* Hidden menu interface:: The hidden menu interface
1912@end menu
1913
1914
1915@node Command-line interface
1916@section The flexible command-line interface
1917
1918The command-line interface provides a prompt and after it an editable
1919text area much like a command-line in Unix or DOS. Each command is
1920immediately executed after it is entered@footnote{However, this
1921behavior will be changed in the future version, in a user-invisible
1922way.}. The commands (@pxref{Command-line and menu entry commands}) are a
1923subset of those available in the configuration file, used with exactly
1924the same syntax.
1925
1926Cursor movement and editing of the text on the line can be done via a
1927subset of the functions available in the Bash shell:
1928
1929@table @key
1930@item C-f
1931@itemx PC right key
1932Move forward one character.
1933
1934@item C-b
1935@itemx PC left key
1936Move back one character.
1937
1938@item C-a
1939@itemx HOME
1940Move to the start of the line.
1941
1942@item C-e
1943@itemx END
1944Move the the end of the line.
1945
1946@item C-d
1947@itemx DEL
1948Delete the character underneath the cursor.
1949
1950@item C-h
1951@itemx BS
1952Delete the character to the left of the cursor.
1953
1954@item C-k
1955Kill the text from the current cursor position to the end of the line.
1956
1957@item C-u
1958Kill backward from the cursor to the beginning of the line.
1959
1960@item C-y
1961Yank the killed text back into the buffer at the cursor.
1962
1963@item C-p
1964@itemx PC up key
1965Move up through the history list.
1966
1967@item C-n
1968@itemx PC down key
1969Move down through the history list.
1970@end table
1971
1972When typing commands interactively, if the cursor is within or before
1973the first word in the command-line, pressing the @key{TAB} key (or
1974@key{C-i}) will display a listing of the available commands, and if the
1975cursor is after the first word, the @kbd{@key{TAB}} will provide a
1976completion listing of disks, partitions, and file names depending on the
1977context. Note that to obtain a list of drives, one must open a
1978parenthesis, as @command{root (}.
1979
1980Note that you cannot use the completion functionality in the TFTP
1981filesystem. This is because TFTP doesn't support file name listing for
1982the security.
1983
1984
1985@node Menu interface
1986@section The simple menu interface
1987
1988The menu interface is quite easy to use. Its commands are both
1989reasonably intuitive and described on screen.
1990
1991Basically, the menu interface provides a list of @dfn{boot entries} to
1992the user to choose from. Use the arrow keys to select the entry of
1993choice, then press @key{RET} to run it. An optional timeout is
1994available to boot the default entry (the first one if not set), which is
1995aborted by pressing any key.
1996
1997Commands are available to enter a bare command-line by pressing @key{c}
1998(which operates exactly like the non-config-file version of GRUB, but
1999allows one to return to the menu if desired by pressing @key{ESC}) or to
2000edit any of the @dfn{boot entries} by pressing @key{e}.
2001
2002If you protect the menu interface with a password (@pxref{Security}),
2003all you can do is choose an entry by pressing @key{RET}, or press
2004@key{p} to enter the password.
2005
2006
2007@node Menu entry editor
2008@section Editing a menu entry
2009
2010The menu entry editor looks much like the main menu interface, but the
2011lines in the menu are individual commands in the selected entry instead
2012of entry names.
2013
2014If an @key{ESC} is pressed in the editor, it aborts all the changes made
2015to the configuration entry and returns to the main menu interface.
2016
2017When a particular line is selected, the editor places the user in a
2018special version of the GRUB command-line to edit that line. When the
2019user hits @key{RET}, GRUB replaces the line in question in the boot
2020entry with the changes (unless it was aborted via @key{ESC},
2021in which case the changes are thrown away).
2022
2023If you want to add a new line to the menu entry, press @key{o} if adding
2024a line after the current line or press @key{O} if before the current
2025line.
2026
2027To delete a line, hit the key @key{d}. Although GRUB unfortunately
2028does not support @dfn{undo}, you can do almost the same thing by just
2029returning to the main menu.
2030
2031
2032@node Hidden menu interface
2033@section The hidden menu interface
2034
2035When your terminal is dumb or you request GRUB to hide the menu
2036interface explicitly with the command @command{hiddenmenu}
2037(@pxref{hiddenmenu}), GRUB doesn't show the menu interface (@pxref{Menu
2038interface}) and automatically boots the default entry, unless
2039interrupted by pressing @key{ESC}.
2040
2041When you interrupt the timeout and your terminal is dumb, GRUB falls
2042back to the command-line interface (@pxref{Command-line interface}).
2043
2044
2045@node Commands
2046@chapter The list of available commands
2047
2048In this chapter, we list all commands that are available in GRUB.
2049
2050Commands belong to different groups. A few can only be used in
2051the global section of the configuration file (or ``menu''); most
2052of them can be entered on the command-line and can be used either
2053anywhere in the menu or specifically in the menu entries.
2054
2055@menu
2056* Menu-specific commands::
2057* General commands::
2058* Command-line and menu entry commands::
2059@end menu
2060
2061
2062@node Menu-specific commands
2063@section The list of commands for the menu only
2064
2065The semantics used in parsing the configuration file are the following:
2066
2067@itemize @bullet
2068@item
2069The menu-specific commands have to be used before any others.
2070
2071@item
2072The files @emph{must} be in plain-text format.
2073
2074@item
2075@samp{#} at the beginning of a line in a configuration file means it is
2076only a comment.
2077
2078@item
2079Options are separated by spaces.
2080
2081@item
2082All numbers can be either decimal or hexadecimal. A hexadecimal number
2083must be preceded by @samp{0x}, and is case-insensitive.
2084
2085@item
2086Extra options or text at the end of the line are ignored unless otherwise
2087specified.
2088
2089@item
2090Unrecognized commands are added to the current entry, except before entries
2091start, where they are ignored.
2092@end itemize
2093
2094These commands can only be used in the menu:
2095
2096@menu
2097* default:: Set the default entry
2098* fallback:: Set the fallback entry
2099* hiddenmenu:: Hide the menu interface
2100* timeout:: Set the timeout
2101* title:: Start a menu entry
2102@end menu
2103
2104
2105@node default
2106@subsection default
2107
2108@deffn Command default num
2109Set the default entry to the entry number @var{num}. Numbering starts
2110from 0, and the entry number 0 is the default if the command is not
2111used.
2112
2113You can specify @samp{saved} instead of a number. In this case, the
2114default entry is the entry saved with the command
2115@command{savedefault}. @xref{savedefault}, for more information.
2116@end deffn
2117
2118
2119@node fallback
2120@subsection fallback
2121
2122@deffn Command fallback num...
2123Go into unattended boot mode: if the default boot entry has any errors,
2124instead of waiting for the user to do something, immediately start
2125over using the @var{num} entry (same numbering as the @code{default}
2126command (@pxref{default})). This obviously won't help if the machine was
2127rebooted by a kernel that GRUB loaded. You can specify multiple
2128fallback entry numbers.
2129@end deffn
2130
2131
2132@node hiddenmenu
2133@subsection hiddenmenu
2134
2135@deffn Command hiddenmenu
2136Don't display the menu. If the command is used, no menu will be
2137displayed on the control terminal, and the default entry will be
2138booted after the timeout expired. The user can still request the
2139menu to be displayed by pressing @key{ESC} before the timeout
2140expires. See also @ref{Hidden menu interface}.
2141@end deffn
2142
2143
2144@node timeout
2145@subsection timeout
2146
2147@deffn Command timeout sec
2148Set a timeout, in @var{sec} seconds, before automatically booting the
2149default entry (normally the first entry defined).
2150@end deffn
2151
2152
2153@node title
2154@subsection title
2155
2156@deffn Command title name @dots{}
2157Start a new boot entry, and set its name to the contents of the rest of
2158the line, starting with the first non-space character.
2159@end deffn
2160
2161
2162@node General commands
2163@section The list of general commands
2164
2165Commands usable anywhere in the menu and in the command-line.
2166
2167@menu
2168* bootp:: Initialize a network device via BOOTP
2169* color:: Color the menu interface
2170* device:: Specify a file as a drive
2171* dhcp:: Initialize a network device via DHCP
2172* hide:: Hide a partition
2173* ifconfig:: Configure a network device manually
2174* pager:: Change the state of the internal pager
2175* partnew:: Make a primary partition
2176* parttype:: Change the type of a partition
2177* password:: Set a password for the menu interface
2178* rarp:: Initialize a network device via RARP
2179* serial:: Set up a serial device
2180* setkey:: Configure the key map
2181* terminal:: Choose a terminal
2182* terminfo:: Define escape sequences for a terminal
2183* tftpserver:: Specify a TFTP server
2184* unhide:: Unhide a partition
2185@end menu
2186
2187
2188@node bootp
2189@subsection bootp
2190
2191@deffn Command bootp [@option{--with-configfile}]
2192Initialize a network device via the @dfn{BOOTP} protocol. This command
2193is only available if GRUB is compiled with netboot support. See also
2194@ref{Network}.
2195
2196If you specify @option{--with-configfile} to this command, GRUB will
2197fetch and load a configuration file specified by your BOOTP server
2198with the vendor tag @samp{150}.
2199@end deffn
2200
2201
2202@node color
2203@subsection color
2204
2205@deffn Command color normal [highlight]
2206Change the menu colors. The color @var{normal} is used for most
2207lines in the menu (@pxref{Menu interface}), and the color
2208@var{highlight} is used to highlight the line where the cursor
2209points. If you omit @var{highlight}, then the inverted color of
2210@var{normal} is used for the highlighted line. The format of a color is
2211@code{@var{foreground}/@var{background}}. @var{foreground} and
2212@var{background} are symbolic color names. A symbolic color name must be
2213one of these:
2214
2215@itemize @bullet
2216@item
2217black
2218
2219@item
2220blue
2221
2222@item
2223green
2224
2225@item
2226cyan
2227
2228@item
2229red
2230
2231@item
2232magenta
2233
2234@item
2235brown
2236
2237@item
2238light-gray
2239
2240@strong{These below can be specified only for the foreground.}
2241
2242@item
2243dark-gray
2244
2245@item
2246light-blue
2247
2248@item
2249light-green
2250
2251@item
2252light-cyan
2253
2254@item
2255light-red
2256
2257@item
2258light-magenta
2259
2260@item
2261yellow
2262
2263@item
2264white
2265@end itemize
2266
2267But only the first eight names can be used for @var{background}. You can
2268prefix @code{blink-} to @var{foreground} if you want a blinking
2269foreground color.
2270
2271This command can be used in the configuration file and on the command
2272line, so you may write something like this in your configuration file:
2273
2274@example
2275@group
2276# Set default colors.
2277color light-gray/blue black/light-gray
2278
2279# Change the colors.
2280title OS-BS like
2281color magenta/blue black/magenta
2282@end group
2283@end example
2284@end deffn
2285
2286
2287@node device
2288@subsection device
2289
2290@deffn Command device drive file
2291In the grub shell, specify the file @var{file} as the actual drive for a
2292@sc{bios} drive @var{drive}. You can use this command to create a disk
2293image, and/or to fix the drives guessed by GRUB when GRUB fails to
2294determine them correctly, like this:
2295
2296@example
2297@group
2298grub> @kbd{device (fd0) /floppy-image}
2299grub> @kbd{device (hd0) /dev/sd0}
2300@end group
2301@end example
2302
2303This command can be used only in the grub shell (@pxref{Invoking the
2304grub shell}).
2305@end deffn
2306
2307
2308@node dhcp
2309@subsection dhcp
2310
2311@deffn Command dhcp [--with-configfile]
2312Initialize a network device via the @dfn{DHCP} protocol. Currently,
2313this command is just an alias for @command{bootp}, since the two
2314protocols are very similar. This command is only available if GRUB is
2315compiled with netboot support. See also @ref{Network}.
2316
2317If you specify @option{--with-configfile} to this command, GRUB will
2318fetch and load a configuration file specified by your DHCP server
2319with the vendor tag @samp{150}.
2320@end deffn
2321
2322
2323@node hide
2324@subsection hide
2325
2326@deffn Command hide partition
2327Hide the partition @var{partition} by setting the @dfn{hidden} bit in
2328its partition type code. This is useful only when booting DOS or Windows
2329and multiple primary FAT partitions exist in one disk. See also
2330@ref{DOS/Windows}.
2331@end deffn
2332
2333
2334@node ifconfig
2335@subsection ifconfig
2336
2337@deffn Command ifconfig [@option{--server=server}] [@option{--gateway=gateway}] [@option{--mask=mask}] [@option{--address=address}]
2338Configure the IP address, the netmask, the gateway, and the server
2339address of a network device manually. The values must be in dotted
2340decimal format, like @samp{192.168.11.178}. The order of the options is
2341not important. This command shows current network configuration, if no
2342option is specified. See also @ref{Network}.
2343@end deffn
2344
2345
2346@node pager
2347@subsection pager
2348
2349@deffn Command pager [flag]
2350Toggle or set the state of the internal pager. If @var{flag} is
2351@samp{on}, the internal pager is enabled. If @var{flag} is @samp{off},
2352it is disabled. If no argument is given, the state is toggled.
2353@end deffn
2354
2355
2356@node partnew
2357@subsection partnew
2358
2359@deffn Command partnew part type from len
2360Create a new primary partition. @var{part} is a partition specification
2361in GRUB syntax (@pxref{Naming convention}); @var{type} is the partition
2362type and must be a number in the range @code{0-0xff}; @var{from} is
2363the starting address and @var{len} is the length, both in sector units.
2364@end deffn
2365
2366
2367@node parttype
2368@subsection parttype
2369
2370@deffn Command parttype part type
2371Change the type of an existing partition. @var{part} is a partition
2372specification in GRUB syntax (@pxref{Naming convention}); @var{type}
2373is the new partition type and must be a number in the range 0-0xff.
2374@end deffn
2375
2376
2377@node password
2378@subsection password
2379
2380@deffn Command password [@option{--md5}] passwd [new-config-file]
2381If used in the first section of a menu file, disable all interactive
2382editing control (menu entry editor and command-line) and entries
2383protected by the command @command{lock}. If the password @var{passwd} is
2384entered, it loads the @var{new-config-file} as a new config file and
2385restarts the GRUB Stage 2, if @var{new-config-file} is
2386specified. Otherwise, GRUB will just unlock the privileged instructions.
2387You can also use this command in the script section, in which case it
2388will ask for the password, before continuing. The option
2389@option{--md5} tells GRUB that @var{passwd} is encrypted with
2390@command{md5crypt} (@pxref{md5crypt}).
2391@end deffn
2392
2393
2394@node rarp
2395@subsection rarp
2396
2397@deffn Command rarp
2398Initialize a network device via the @dfn{RARP} protocol. This command
2399is only available if GRUB is compiled with netboot support. See also
2400@ref{Network}.
2401@end deffn
2402
2403
2404@node serial
2405@subsection serial
2406
2407@deffn Command serial [@option{--unit=unit}] [@option{--port=port}] [@option{--speed=speed}] [@option{--word=word}] [@option{--parity=parity}] [@option{--stop=stop}] [@option{--device=dev}]
2408Initialize a serial device. @var{unit} is a number in the range 0-3
2409specifying which serial port to use; default is 0, which corresponds to
2410the port often called COM1. @var{port} is the I/O port where the UART
2411is to be found; if specified it takes precedence over @var{unit}.
2412@var{speed} is the transmission speed; default is 9600. @var{word} and
2413@var{stop} are the number of data bits and stop bits. Data bits must
2414be in the range 5-8 and stop bits must be 1 or 2. Default is 8 data
2415bits and one stop bit. @var{parity} is one of @samp{no}, @samp{odd},
2416@samp{even} and defaults to @samp{no}. The option @option{--device}
b39f9d20 2417can only be used in the grub shell and is used to specify the
87a95d1f 2418tty device to be used in the host operating system (@pxref{Invoking the
2419grub shell}).
2420
2421The serial port is not used as a communication channel unless the
2422@command{terminal} command is used (@pxref{terminal}).
2423
2424This command is only available if GRUB is compiled with serial
2425support. See also @ref{Serial terminal}.
2426@end deffn
2427
2428
2429@node setkey
2430@subsection setkey
2431
2432@deffn Command setkey [to_key from_key]
2433Change the keyboard map. The key @var{from_key} is mapped to the key
b39f9d20 2434@var{to_key}. If no argument is specified, reset key mappings. Note that
2435this command @emph{does not} exchange the keys. If you want to exchange
87a95d1f 2436the keys, run this command again with the arguments exchanged, like this:
2437
2438@example
2439grub> @kbd{setkey capslock control}
2440grub> @kbd{setkey control capslock}
2441@end example
2442
2443A key must be an alphabet letter, a digit, or one of these symbols:
2444@samp{escape}, @samp{exclam}, @samp{at}, @samp{numbersign},
2445@samp{dollar}, @samp{percent}, @samp{caret}, @samp{ampersand},
2446@samp{asterisk}, @samp{parenleft}, @samp{parenright}, @samp{minus},
2447@samp{underscore}, @samp{equal}, @samp{plus}, @samp{backspace},
2448@samp{tab}, @samp{bracketleft}, @samp{braceleft}, @samp{bracketright},
2449@samp{braceright}, @samp{enter}, @samp{control}, @samp{semicolon},
2450@samp{colon}, @samp{quote}, @samp{doublequote}, @samp{backquote},
2451@samp{tilde}, @samp{shift}, @samp{backslash}, @samp{bar}, @samp{comma},
2452@samp{less}, @samp{period}, @samp{greater}, @samp{slash},
2453@samp{question}, @samp{alt}, @samp{space}, @samp{capslock}, @samp{FX}
2454(@samp{X} is a digit), and @samp{delete}. This table describes to which
2455character each of the symbols corresponds:
2456
2457@table @samp
2458@item exclam
2459@samp{!}
2460
2461@item at
2462@samp{@@}
2463
2464@item numbersign
2465@samp{#}
2466
2467@item dollar
2468@samp{$}
2469
2470@item percent
2471@samp{%}
2472
2473@item caret
2474@samp{^}
2475
2476@item ampersand
2477@samp{&}
2478
2479@item asterisk
2480@samp{*}
2481
2482@item parenleft
2483@samp{(}
2484
2485@item parenright
2486@samp{)}
2487
2488@item minus
2489@samp{-}
2490
2491@item underscore
2492@samp{_}
2493
2494@item equal
2495@samp{=}
2496
2497@item plus
2498@samp{+}
2499
2500@item bracketleft
2501@samp{[}
2502
2503@item braceleft
2504@samp{@{}
2505
2506@item bracketright
2507@samp{]}
2508
2509@item braceright
2510@samp{@}}
2511
2512@item semicolon
2513@samp{;}
2514
2515@item colon
2516@samp{:}
2517
2518@item quote
2519@samp{'}
2520
2521@item doublequote
2522@samp{"}
2523
2524@item backquote
2525@samp{`}
2526
2527@item tilde
2528@samp{~}
2529
2530@item backslash
2531@samp{\}
2532
2533@item bar
2534@samp{|}
2535
2536@item comma
2537@samp{,}
2538
2539@item less
2540@samp{<}
2541
2542@item period
2543@samp{.}
2544
2545@item greater
2546@samp{>}
2547
2548@item slash
2549@samp{/}
2550
2551@item question
2552@samp{?}
2553
2554@item space
2555@samp{ }
2556@end table
2557@end deffn
2558
2559
2560@node terminal
2561@subsection terminal
2562
2563@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}]
2564Select a terminal for user interaction. The terminal is assumed to be
2565VT100-compatible unless @option{--dumb} is specified. If both
2566@option{console} and @option{serial} are specified, then GRUB will use
2567the one where a key is entered first or the first when the timeout
2568expires. If neither are specified, the current setting is
2569reported. This command is only available if GRUB is compiled with serial
2570support. See also @ref{Serial terminal}.
2571
2572This may not make sense for most users, but GRUB supports Hercules
2573console as well. Hercules console is usable like the ordinary console,
2574and the usage is quite similar to that for serial terminals: specify
2575@option{hercules} as the argument.
2576
2577The option @option{--lines} defines the number of lines in your
2578terminal, and it is used for the internal pager function. If you don't
2579specify this option, the number is assumed as 24.
2580
2581The option @option{--silent} suppresses the message to prompt you to
2582hit any key. This might be useful if your system has no terminal
2583device.
2584
2585The option @option{--no-echo} has GRUB not to echo back input
2586characters. This implies the option @option{--no-edit}.
2587
2588The option @option{--no-edit} disables the BASH-like editing feature.
2589@end deffn
2590
2591
2592@node terminfo
2593@subsection terminfo
2594
2595@deffn Command terminfo @option{--name=name} @option{--cursor-address=seq} [@option{--clear-screen=seq}] [@option{--enter-standout-mode=seq}] [@option{--exit-standout-mode=seq}]
2596Define the capabilities of your terminal. Use this command to define
2597escape sequences, if it is not vt100-compatible. You may use @samp{\e}
2598for @key{ESC} and @samp{^X} for a control character.
2599
2600You can use the utility @command{grub-terminfo} to generate
2601appropriate arguments to this command. @xref{Invoking grub-terminfo}.
2602
2603If no option is specified, the current settings are printed.
2604@end deffn
2605
2606
2607@node tftpserver
2608@subsection tftpserver
2609
2610@deffn Command tftpserver ipaddr
2611@strong{Caution:} This command exists only for backward
2612compatibility. Use @command{ifconfig} (@pxref{ifconfig}) instead.
2613
2614Override a TFTP server address returned by a BOOTP/DHCP/RARP server. The
2615argument @var{ipaddr} must be in dotted decimal format, like
2616@samp{192.168.0.15}. This command is only available if GRUB is compiled
2617with netboot support. See also @ref{Network}.
2618@end deffn
2619
2620
2621@node unhide
2622@subsection unhide
2623
2624@deffn Command unhide partition
2625Unhide the partition @var{partition} by clearing the @dfn{hidden} bit in
2626its partition type code. This is useful only when booting DOS or Windows
2627and multiple primary partitions exist on one disk. See also
2628@ref{DOS/Windows}.
2629@end deffn
2630
2631
2632@node Command-line and menu entry commands
2633@section The list of command-line and menu entry commands
2634
2635These commands are usable in the command-line and in menu entries. If
2636you forget a command, you can run the command @command{help}
2637(@pxref{help}).
2638
2639@menu
2640* blocklist:: Get the block list notation of a file
2641* boot:: Start up your operating system
2642* cat:: Show the contents of a file
2643* chainloader:: Chain-load another boot loader
2644* cmp:: Compare two files
2645* configfile:: Load a configuration file
2646* debug:: Toggle the debug flag
2647* displayapm:: Display APM information
2648* displaymem:: Display memory configuration
2649* embed:: Embed Stage 1.5
2650* find:: Find a file
2651* fstest:: Test a filesystem
2652* geometry:: Manipulate the geometry of a drive
2653* halt:: Shut down your computer
2654* help:: Show help messages
2655* impsprobe:: Probe SMP
2656* initrd:: Load an initrd
2657* install:: Install GRUB
2658* ioprobe:: Probe I/O ports used for a drive
2659* kernel:: Load a kernel
2660* lock:: Lock a menu entry
2661* makeactive:: Make a partition active
2662* map:: Map a drive to another
2663* md5crypt:: Encrypt a password in MD5 format
2664* module:: Load a module
2665* modulenounzip:: Load a module without decompression
2666* pause:: Wait for a key press
2667* quit:: Exit from the grub shell
2668* reboot:: Reboot your computer
2669* read:: Read data from memory
2670* root:: Set GRUB's root device
2671* rootnoverify:: Set GRUB's root device without mounting
2672* savedefault:: Save current entry as the default entry
2673* setup:: Set up GRUB's installation automatically
2674* testload:: Load a file for testing a filesystem
2675* testvbe:: Test VESA BIOS EXTENSION
2676* uppermem:: Set the upper memory size
2677* vbeprobe:: Probe VESA BIOS EXTENSION
2678@end menu
2679
2680
2681@node blocklist
2682@subsection blocklist
2683
2684@deffn Command blocklist file
2685Print the block list notation of the file @var{file}. @xref{Block list
2686syntax}.
2687@end deffn
2688
2689
2690@node boot
2691@subsection boot
2692
2693@deffn Command boot
2694Boot the OS or chain-loader which has been loaded. Only necessary if
2695running the fully interactive command-line (it is implicit at the end of
2696a menu entry).
2697@end deffn
2698
2699
2700@node cat
2701@subsection cat
2702
2703@deffn Command cat file
2704Display the contents of the file @var{file}. This command may be useful
2705to remind you of your OS's root partition:
2706
2707@example
2708grub> @kbd{cat /etc/fstab}
2709@end example
2710@end deffn
2711
2712
2713@node chainloader
2714@subsection chainloader
2715
2716@deffn Command chainloader [@option{--force}] file
2717Load @var{file} as a chain-loader. Like any other file loaded by the
2718filesystem code, it can use the blocklist notation to grab the first
2719sector of the current partition with @samp{+1}. If you specify the
2720option @option{--force}, then load @var{file} forcibly, whether it has a
2721correct signature or not. This is required when you want to load a
2722defective boot loader, such as SCO UnixWare 7.1 (@pxref{SCO UnixWare}).
2723@end deffn
2724
2725
2726@node cmp
2727@subsection cmp
2728
2729@deffn Command cmp file1 file2
2730Compare the file @var{file1} with the file @var{file2}. If they differ
2731in size, print the sizes like this:
2732
2733@example
2734Differ in size: 0x1234 [foo], 0x4321 [bar]
2735@end example
2736
2737If the sizes are equal but the bytes at an offset differ, then print the
2738bytes like this:
2739
2740@example
2741Differ at the offset 777: 0xbe [foo], 0xef [bar]
2742@end example
2743
2744If they are completely identical, nothing will be printed.
2745@end deffn
2746
2747
2748@node configfile
2749@subsection configfile
2750
2751@deffn Command configfile file
2752Load @var{file} as a configuration file.
2753@end deffn
2754
2755
2756@node debug
2757@subsection debug
2758
2759@deffn Command debug
2760Toggle debug mode (by default it is off). When debug mode is on, some
2761extra messages are printed to show disk activity. This global debug flag
2762is mainly useful for GRUB developers when testing new code.
2763@end deffn
2764
2765
2766@node displayapm
2767@subsection displayapm
2768
2769@deffn Command displayapm
2770Display APM BIOS information.
2771@end deffn
2772
2773
2774@node displaymem
2775@subsection displaymem
2776
2777@deffn Command displaymem
2778Display what GRUB thinks the system address space map of the machine is,
2779including all regions of physical @sc{ram} installed. GRUB's
2780@dfn{upper/lower memory} display uses the standard BIOS interface for
2781the available memory in the first megabyte, or @dfn{lower memory}, and a
2782synthesized number from various BIOS interfaces of the memory starting
2783at 1MB and going up to the first chipset hole for @dfn{upper memory}
2784(the standard PC @dfn{upper memory} interface is limited to reporting a
2785maximum of 64MB).
2786@end deffn
2787
2788
2789@node embed
2790@subsection embed
2791
2792@deffn Command embed stage1_5 device
2793Embed the Stage 1.5 @var{stage1_5} in the sectors after the MBR if
2794@var{device} is a drive, or in the @dfn{boot loader} area if @var{device}
2795is a FFS partition or a ReiserFS partition.@footnote{The latter feature
2796has not been implemented yet.} Print the number of sectors which
2797@var{stage1_5} occupies, if successful.
2798
2799Usually, you don't need to run this command directly. @xref{setup}.
2800@end deffn
2801
2802
2803@node find
2804@subsection find
2805
2806@deffn Command find filename
2807Search for the file name @var{filename} in all mountable partitions
2808and print the list of the devices which contain the file. The file
2809name @var{filename} should be an absolute file name like
2810@code{/boot/grub/stage1}.
2811@end deffn
2812
2813
2814@node fstest
2815@subsection fstest
2816
2817@deffn Command fstest
2818Toggle filesystem test mode.
2819Filesystem test mode, when turned on, prints out data corresponding to
2820all the device reads and what values are being sent to the low-level
2821routines. The format is @samp{<@var{partition-offset-sector},
2822@var{byte-offset}, @var{byte-length}>} for high-level reads inside a
2823partition, and @samp{[@var{disk-offset-sector}]} for low-level sector
2824requests from the disk.
2825Filesystem test mode is turned off by any use of the @command{install}
2826(@pxref{install}) or @command{testload} (@pxref{testload}) commands.
2827@end deffn
2828
2829
2830@node geometry
2831@subsection geometry
2832
2833@deffn Command geometry drive [cylinder head sector [total_sector]]
2834Print the information for the drive @var{drive}. In the grub shell, you
2835can set the geometry of the drive arbitrarily. The number of
2836cylinders, the number of heads, the number of sectors and the number of
2837total sectors are set to CYLINDER, HEAD, SECTOR and TOTAL_SECTOR,
2838respectively. If you omit TOTAL_SECTOR, then it will be calculated
2839based on the C/H/S values automatically.
2840@end deffn
2841
2842
2843@node halt
2844@subsection halt
2845
2846@deffn Command halt @option{--no-apm}
2847The command halts the computer. If the @option{--no-apm} option
2848is specified, no APM BIOS call is performed. Otherwise, the computer
2849is shut down using APM.
2850@end deffn
2851
2852
2853@node help
2854@subsection help
2855
2856@deffn Command help @option{--all} [pattern @dots{}]
2857Display helpful information about builtin commands. If you do not
2858specify @var{pattern}, this command shows short descriptions of most of
2859available commands. If you specify the option @option{--all} to this
2860command, short descriptions of rarely used commands (such as
2861@ref{testload}) are displayed as well.
2862
2863If you specify any @var{patterns}, it displays longer information
2864about each of the commands which match those @var{patterns}.
2865@end deffn
2866
2867
2868@node impsprobe
2869@subsection impsprobe
2870
2871@deffn Command impsprobe
2872Probe the Intel Multiprocessor Specification 1.1 or 1.4 configuration
2873table and boot the various CPUs which are found into a tight loop. This
2874command can be used only in the Stage 2, but not in the grub shell.
2875@end deffn
2876
2877
2878@node initrd
2879@subsection initrd
2880
2881@deffn Command initrd file @dots{}
2882Load an initial ramdisk for a Linux format boot image and set the
2883appropriate parameters in the Linux setup area in memory. See also
2884@ref{GNU/Linux}.
2885@end deffn
2886
2887
2888@node install
2889@subsection install
2890
2891@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]
2892This command is fairly complex, and you should not use this command
2893unless you are familiar with GRUB. Use @command{setup} (@pxref{setup})
2894instead.
2895
2896In short, it will perform a full install presuming the Stage 2 or Stage
28971.5@footnote{They're loaded the same way, so we will refer to the Stage
28981.5 as a Stage 2 from now on.} is in its final install location.
2899
2900In slightly more detail, it will load @var{stage1_file}, validate that
2901it is a GRUB Stage 1 of the right version number, install in it a
2902blocklist for loading @var{stage2_file} as a Stage 2. If the option
2903@option{d} is present, the Stage 1 will always look for the actual
2904disk @var{stage2_file} was installed on, rather than using the booting
2905drive. The Stage 2 will be loaded at address @var{addr}, which must be
2906@samp{0x8000} for a true Stage 2, and @samp{0x2000} for a Stage 1.5. If
2907@var{addr} is not present, GRUB will determine the address
2908automatically. It then writes the completed Stage 1 to the first block
2909of the device @var{dest_dev}. If the options @option{p} or
2910@var{config_file} are present, then it reads the first block of stage2,
2911modifies it with the values of the partition @var{stage2_file} was found
2912on (for @option{p}) or places the string @var{config_file} into the area
2913telling the stage2 where to look for a configuration file at boot
2914time. Likewise, if @var{real_config_file} is present and
2915@var{stage2_file} is a Stage 1.5, then the Stage 2 @var{config_file} is
2916patched with the configuration file name @var{real_config_file}. This
2917command preserves the DOS BPB (and for hard disks, the partition table)
2918of the sector the Stage 1 is to be installed into.
2919
2920@strong{Caution:} Several buggy BIOSes don't pass a booting drive
2921properly when booting from a hard disk drive. Therefore, you will
2922unfortunately have to specify the option @option{d}, whether your
2923Stage2 resides at the booting drive or not, if you have such a
2924BIOS. We know these are defective in this way:
2925
2926@table @asis
2927@item
2928Fujitsu LifeBook 400 BIOS version 31J0103A
2929
2930@item
2931HP Vectra XU 6/200 BIOS version GG.06.11
2932@end table
2933
2934@strong{Caution2:} A number of BIOSes don't return a correct LBA support
2935bitmap even if they do have the support. So GRUB provides a solution to
2936ignore the wrong bitmap, that is, the option @option{--force-lba}. Don't
2937use this option if you know that your BIOS doesn't have LBA support.
2938
2939@strong{Caution3:} You must specify the option @option{--stage2} in the
2940grub shell, if you cannot unmount the filesystem where your stage2 file
2941resides. The argument should be the file name in your operating system.
2942@end deffn
2943
2944
2945@node ioprobe
2946@subsection ioprobe
2947
2948@deffn Command ioprobe drive
2949Probe I/O ports used for the drive @var{drive}. This command will list
2950the I/O ports on the screen. For technical information,
2951@xref{Internals}.
2952@end deffn
2953
2954
2955@node kernel
2956@subsection kernel
2957
2958@deffn Command kernel [@option{--type=type}] [@option{--no-mem-option}] file @dots{}
2959Attempt to load the primary boot image (Multiboot a.out or @sc{elf},
2960Linux zImage or bzImage, FreeBSD a.out, NetBSD a.out, etc.) from
2961@var{file}. The rest of the line is passed verbatim as the @dfn{kernel
2962command-line}. Any modules must be reloaded after using this command.
2963
2964This command also accepts the option @option{--type} so that you can
2965specify the kernel type of @var{file} explicitly. The argument
2966@var{type} must be one of these: @samp{netbsd}, @samp{freebsd},
2967@samp{openbsd}, @samp{linux}, @samp{biglinux}, and
2968@samp{multiboot}. However, you need to specify it only if you want to
2969load a NetBSD @sc{elf} kernel, because GRUB can automatically determine
2970a kernel type in the other cases, quite safely.
2971
2972The option @option{--no-mem-option} is effective only for Linux. If the
2973option is specified, GRUB doesn't pass the option @option{mem=} to the
2974kernel. This option is implied for Linux kernels 2.4.18 and newer.
2975@end deffn
2976
2977
2978@node lock
2979@subsection lock
2980
2981@deffn Command lock
2982Prevent normal users from executing arbitrary menu entries. You must use
2983the command @command{password} if you really want this command to be
2984useful (@pxref{password}).
2985
2986This command is used in a menu, as shown in this example:
2987
2988@example
2989@group
2990title This entry is too dangerous to be executed by normal users
2991lock
2992root (hd0,a)
2993kernel /no-security-os
2994@end group
2995@end example
2996
2997See also @ref{Security}.
2998@end deffn
2999
3000
3001@node makeactive
3002@subsection makeactive
3003
3004@deffn Command makeactive
3005Set the active partition on the root disk to GRUB's root device.
3006This command is limited to @emph{primary} PC partitions on a hard disk.
3007@end deffn
3008
3009
3010@node map
3011@subsection map
3012
3013@deffn Command map to_drive from_drive
3014Map the drive @var{from_drive} to the drive @var{to_drive}. This is
3015necessary when you chain-load some operating systems, such as DOS, if
3016such an OS resides at a non-first drive. Here is an example:
3017
3018@example
3019@group
3020grub> @kbd{map (hd0) (hd1)}
3021grub> @kbd{map (hd1) (hd0)}
3022@end group
3023@end example
3024
3025The example exchanges the order between the first hard disk and the
3026second hard disk. See also @ref{DOS/Windows}.
3027@end deffn
3028
3029
3030@node md5crypt
3031@subsection md5crypt
3032
3033@deffn Command md5crypt
3034Prompt to enter a password, and encrypt it in MD5 format. The encrypted
3035password can be used with the command @command{password}
3036(@pxref{password}). See also @ref{Security}.
3037@end deffn
3038
3039
3040@node module
3041@subsection module
3042
3043@deffn Command module file @dots{}
3044Load a boot module @var{file} for a Multiboot format boot image (no
3045interpretation of the file contents are made, so the user of this
3046command must know what the kernel in question expects). The rest of the
3047line is passed as the @dfn{module command-line}, like the
3048@command{kernel} command. You must load a Multiboot kernel image before
3049loading any module. See also @ref{modulenounzip}.
3050@end deffn
3051
3052
3053@node modulenounzip
3054@subsection modulenounzip
3055
3056@deffn Command modulenounzip file @dots{}
3057The same as @command{module} (@pxref{module}), except that automatic
3058decompression is disabled.
3059@end deffn
3060
3061
3062@node pause
3063@subsection pause
3064
3065@deffn Command pause message @dots{}
3066Print the @var{message}, then wait until a key is pressed. Note that
3067placing @key{^G} (ASCII code 7) in the message will cause the speaker to
3068emit the standard beep sound, which is useful when prompting the user to
3069change floppies.
3070@end deffn
3071
3072
3073@node quit
3074@subsection quit
3075
3076@deffn Command quit
3077Exit from the grub shell @command{grub} (@pxref{Invoking the grub
3078shell}). This command can be used only in the grub shell.
3079@end deffn
3080
3081
3082@node reboot
3083@subsection reboot
3084
3085@deffn Command reboot
3086Reboot the computer.
3087@end deffn
3088
3089
3090@node read
3091@subsection read
3092
3093@deffn Command read addr
3094Read a 32-bit value from memory at address @var{addr} and display it in
3095hex format.
3096@end deffn
3097
3098
3099@node root
3100@subsection root
3101
3102@deffn Command root device [hdbias]
3103Set the current @dfn{root device} to the device @var{device}, then
3104attempt to mount it to get the partition size (for passing the partition
3105descriptor in @code{ES:ESI}, used by some chain-loaded boot loaders), the
3106BSD drive-type (for booting BSD kernels using their native boot format),
3107and correctly determine the PC partition where a BSD sub-partition is
3108located. The optional @var{hdbias} parameter is a number to tell a BSD
3109kernel how many BIOS drive numbers are on controllers before the current
3110one. For example, if there is an IDE disk and a SCSI disk, and your
3111FreeBSD root partition is on the SCSI disk, then use a @samp{1} for
3112@var{hdbias}.
3113
3114See also @ref{rootnoverify}.
3115@end deffn
3116
3117
3118@node rootnoverify
3119@subsection rootnoverify
3120
3121@deffn Command rootnoverify device [hdbias]
3122Similar to @command{root} (@pxref{root}), but don't attempt to mount the
3123partition. This is useful for when an OS is outside of the area of the
3124disk that GRUB can read, but setting the correct root device is still
3125desired. Note that the items mentioned in @command{root} above which
3126derived from attempting the mount will @emph{not} work correctly.
3127@end deffn
3128
3129
3130@node savedefault
3131@subsection savedefault
3132
3133@deffn Command savedefault num
3134Save the current menu entry or @var{num} if specified as a default
3135entry. Here is an example:
3136
3137@example
3138@group
3139default saved
3140timeout 10
3141
3142title GNU/Linux
3143root (hd0,0)
3144kernel /boot/vmlinuz root=/dev/sda1 vga=ext
3145initrd /boot/initrd
3146savedefault
3147
3148title FreeBSD
3149root (hd0,a)
3150kernel /boot/loader
3151savedefault
3152@end group
3153@end example
3154
3155With this configuration, GRUB will choose the entry booted previously as
3156the default entry.
3157
3158You can specify @samp{fallback} instead of a number. Then, next
3159fallback entry is saved. Next fallback entry is chosen from fallback
3160entries. Normally, this will be the first entry in fallback ones.
3161
3162See also @ref{default} and @ref{Invoking grub-set-default}.
3163@end deffn
3164
3165
3166@node setup
3167@subsection setup
3168
3169@deffn Command setup [@option{--force-lba}] [@option{--stage2=os_stage2_file}] [@option{--prefix=dir}] install_device [image_device]
3170Set up the installation of GRUB automatically. This command uses the
3171more flexible command @command{install} (@pxref{install}) in the backend
3172and installs GRUB into the device @var{install_device}. If
3173@var{image_device} is specified, then find the GRUB images
3174(@pxref{Images}) in the device @var{image_device}, otherwise use the
3175current @dfn{root device}, which can be set by the command
3176@command{root}. If @var{install_device} is a hard disk, then embed a
3177Stage 1.5 in the disk if possible.
3178
3179The option @option{--prefix} specifies the directory under which GRUB
3180images are put. If it is not specified, GRUB automatically searches them
3181in @file{/boot/grub} and @file{/grub}.
3182
3183The options @option{--force-lba} and @option{--stage2} are just passed
3184to @command{install} if specified. @xref{install}, for more
3185information.
3186@end deffn
3187
3188
3189@node testload
3190@subsection testload
3191
3192@deffn Command testload file
3193Read the entire contents of @var{file} in several different ways and
3194compare them, to test the filesystem code. The output is somewhat
3195cryptic, but if no errors are reported and the final @samp{i=@var{X},
3196filepos=@var{Y}} reading has @var{X} and @var{Y} equal, then it is
3197definitely consistent, and very likely works correctly subject to a
3198consistent offset error. If this test succeeds, then a good next step is
3199to try loading a kernel.
3200@end deffn
3201
3202
3203@node testvbe
3204@subsection testvbe
3205
3206@deffn Command testvbe mode
3207Test the VESA BIOS EXTENSION mode @var{mode}. This command will switch
3208your video card to the graphics mode, and show an endless animation. Hit
3209any key to return. See also @ref{vbeprobe}.
3210@end deffn
3211
3212
3213@node uppermem
3214@subsection uppermem
3215
3216@deffn Command uppermem kbytes
3217Force GRUB to assume that only @var{kbytes} kilobytes of upper memory
3218are installed. Any system address range maps are discarded.
3219
3220@strong{Caution:} This should be used with great caution, and should
3221only be necessary on some old machines. GRUB's BIOS probe can pick up
3222all @sc{ram} on all new machines the author has ever heard of. It can
3223also be used for debugging purposes to lie to an OS.
3224@end deffn
3225
3226
3227@node vbeprobe
3228@subsection vbeprobe
3229
3230@deffn Command vbeprobe [mode]
3231Probe VESA BIOS EXTENSION information. If the mode @var{mode} is
3232specified, show only the information about @var{mode}. Otherwise, this
3233command lists up available VBE modes on the screen. See also
3234@ref{testvbe}.
3235@end deffn
3236
3237
3238@node Troubleshooting
3239@chapter Error messages reported by GRUB
3240
3241This chapter describes error messages reported by GRUB when you
3242encounter trouble. @xref{Invoking the grub shell}, if your problem is
3243specific to the grub shell.
3244
3245@menu
3246* Stage1 errors:: Errors reported by the Stage 1
3247* Stage1.5 errors:: Errors reported by the Stage 1.5
3248* Stage2 errors:: Errors reported by the Stage 2
3249@end menu
3250
3251
3252@node Stage1 errors
3253@section Errors reported by the Stage 1
3254
3255The general way that the Stage 1 handles errors is to print an error
3256string and then halt. Pressing @kbd{@key{CTRL}-@key{ALT}-@key{DEL}} will
3257reboot.
3258
3259The following is a comprehensive list of error messages for the Stage 1:
3260
3261@table @asis
3262@item Hard Disk Error
3263The stage2 or stage1.5 is being read from a hard disk, and the attempt
3264to determine the size and geometry of the hard disk failed.
3265
3266@item Floppy Error
3267The stage2 or stage1.5 is being read from a floppy disk, and the attempt
3268to determine the size and geometry of the floppy disk failed. It's listed
3269as a separate error since the probe sequence is different than for hard
3270disks.
3271
3272@item Read Error
3273A disk read error happened while trying to read the stage2 or stage1.5.
3274
3275@item Geom Error
3276The location of the stage2 or stage1.5 is not in the portion of the disk
3277supported directly by the BIOS read calls. This could occur because the
3278BIOS translated geometry has been changed by the user or the disk is
3279moved to another machine or controller after installation, or GRUB was
3280not installed using itself (if it was, the Stage 2 version of this error
3281would have been seen during that process and it would not have completed
3282the install).
3283@end table
3284
3285
3286@node Stage1.5 errors
3287@section Errors reported by the Stage 1.5
3288
3289The general way that the Stage 1.5 handles errors is to print an error
3290number in the form @code{Error @var{num}} and then halt. Pressing
3291@kbd{@key{CTRL}-@key{ALT}-@key{DEL}} will reboot.
3292
3293The error numbers correspond to the errors reported by Stage
32942. @xref{Stage2 errors}.
3295
3296
3297@node Stage2 errors
3298@section Errors reported by the Stage 2
3299
3300The general way that the Stage 2 handles errors is to abort the
3301operation in question, print an error string, then (if possible) either
3302continue based on the fact that an error occurred or wait for the user to
3303deal with the error.
3304
3305The following is a comprehensive list of error messages for the Stage 2
3306(error numbers for the Stage 1.5 are listed before the colon in each
3307description):
3308
3309@table @asis
3310@item 1 : Filename must be either an absolute filename or blocklist
3311This error is returned if a file name is requested which doesn't fit the
3312syntax/rules listed in the @ref{Filesystem}.
3313
3314@item 2 : Bad file or directory type
3315This error is returned if a file requested is not a regular file, but
3316something like a symbolic link, directory, or FIFO.
3317
3318@item 3 : Bad or corrupt data while decompressing file
3319This error is returned if the run-length decompression code gets an
3320internal error. This is usually from a corrupt file.
3321
3322@item 4 : Bad or incompatible header in compressed file
3323This error is returned if the file header for a supposedly compressed
3324file is bad.
3325
3326@item 5 : Partition table invalid or corrupt
3327This error is returned if the sanity checks on the integrity of the
3328partition table fail. This is a bad sign.
3329
3330@item 6 : Mismatched or corrupt version of stage1/stage2
3331This error is returned if the install command points to incompatible
3332or corrupt versions of the stage1 or stage2. It can't detect corruption
3333in general, but this is a sanity check on the version numbers, which
3334should be correct.
3335
3336@item 7 : Loading below 1MB is not supported
3337This error is returned if the lowest address in a kernel is below the
33381MB boundary. The Linux zImage format is a special case and can be
3339handled since it has a fixed loading address and maximum size.
3340
3341@item 8 : Kernel must be loaded before booting
3342This error is returned if GRUB is told to execute the boot sequence
3343without having a kernel to start.
3344
3345@item 9 : Unknown boot failure
3346This error is returned if the boot attempt did not succeed for reasons
3347which are unknown.
3348
3349@item 10 : Unsupported Multiboot features requested
3350This error is returned when the Multiboot features word in the Multiboot
3351header requires a feature that is not recognized. The point of this is
3352that the kernel requires special handling which GRUB is probably
3353unable to provide.
3354
3355@item 11 : Unrecognized device string
3356This error is returned if a device string was expected, and the string
3357encountered didn't fit the syntax/rules listed in the @ref{Filesystem}.
3358
3359@item 12 : Invalid device requested
3360This error is returned if a device string is recognizable but does not
3361fall under the other device errors.
3362
3363@item 13 : Invalid or unsupported executable format
3364This error is returned if the kernel image being loaded is not
3365recognized as Multiboot or one of the supported native formats (Linux
3366zImage or bzImage, FreeBSD, or NetBSD).
3367
3368@item 14 : Filesystem compatibility error, cannot read whole file
3369Some of the filesystem reading code in GRUB has limits on the length of
3370the files it can read. This error is returned when the user runs into
3371such a limit.
3372
3373@item 15 : File not found
3374This error is returned if the specified file name cannot be found, but
3375everything else (like the disk/partition info) is OK.
3376
3377@item 16 : Inconsistent filesystem structure
3378This error is returned by the filesystem code to denote an internal
3379error caused by the sanity checks of the filesystem structure on disk
3380not matching what it expects. This is usually caused by a corrupt
3381filesystem or bugs in the code handling it in GRUB.
3382
3383@item 17 : Cannot mount selected partition
3384This error is returned if the partition requested exists, but the
3385filesystem type cannot be recognized by GRUB.
3386
3387@item 18 : Selected cylinder exceeds maximum supported by BIOS
3388This error is returned when a read is attempted at a linear block
3389address beyond the end of the BIOS translated area. This generally
3390happens if your disk is larger than the BIOS can handle (512MB for
3391(E)IDE disks on older machines or larger than 8GB in general).
3392
3393@item 19 : Linux kernel must be loaded before initrd
3394This error is returned if the initrd command is used before loading a
3395Linux kernel.
3396
3397@item 20 : Multiboot kernel must be loaded before modules
3398This error is returned if the module load command is used before loading
3399a Multiboot kernel. It only makes sense in this case anyway, as GRUB has
3400no idea how to communicate the presence of such modules to a
3401non-Multiboot-aware kernel.
3402
3403@item 21 : Selected disk does not exist
3404This error is returned if the device part of a device- or full file name
3405refers to a disk or BIOS device that is not present or not recognized by
3406the BIOS in the system.
3407
3408@item 22 : No such partition
3409This error is returned if a partition is requested in the device part of
3410a device- or full file name which isn't on the selected disk.
3411
3412@item 23 : Error while parsing number
3413This error is returned if GRUB was expecting to read a number and
3414encountered bad data.
3415
3416@item 24 : Attempt to access block outside partition
3417This error is returned if a linear block address is outside of the disk
3418partition. This generally happens because of a corrupt filesystem on the
3419disk or a bug in the code handling it in GRUB (it's a great debugging
3420tool).
3421
3422@item 25 : Disk read error
3423This error is returned if there is a disk read error when trying to
3424probe or read data from a particular disk.
3425
3426@item 26 : Too many symbolic links
3427This error is returned if the link count is beyond the maximum
3428(currently 5), possibly the symbolic links are looped.
3429
3430@item 27 : Unrecognized command
3431This error is returned if an unrecognized command is entered on the
3432command-line or in a boot sequence section of a configuration file and
3433that entry is selected.
3434
3435@item 28 : Selected item cannot fit into memory
3436This error is returned if a kernel, module, or raw file load command is
3437either trying to load its data such that it won't fit into memory or it
3438is simply too big.
3439
3440@item 29 : Disk write error
3441This error is returned if there is a disk write error when trying to
3442write to a particular disk. This would generally only occur during an
3443install of set active partition command.
3444
3445@item 30 : Invalid argument
3446This error is returned if an argument specified to a command is invalid.
3447
3448@item 31 : File is not sector aligned
3449This error may occur only when you access a ReiserFS partition by
3450block-lists (e.g. the command @command{install}). In this case, you
3451should mount the partition with the @samp{-o notail} option.
3452
3453@item 32 : Must be authenticated
3454This error is returned if you try to run a locked entry. You should
3455enter a correct password before running such an entry.
3456
3457@item 33 : Serial device not configured
3458This error is returned if you try to change your terminal to a serial
3459one before initializing any serial device.
3460
3461@item 34 : No spare sectors on the disk
3462This error is returned if a disk doesn't have enough spare space. This
3463happens when you try to embed Stage 1.5 into the unused sectors after
3464the MBR, but the first partition starts right after the MBR or they are
3465used by EZ-BIOS.
3466@end table
3467
3468
3469@node Invoking the grub shell
3470@chapter Invoking the grub shell
3471
3472This chapter documents the grub shell @command{grub}. Note that the grub
3473shell is an emulator; it doesn't run under the native environment, so it
3474sometimes does something wrong. Therefore, you shouldn't trust it too
3475much. If there is anything wrong with it, don't hesitate to try the
3476native GRUB environment, especially when it guesses a wrong map between
3477BIOS drives and OS devices.
3478
3479@menu
3480* Basic usage:: How to use the grub shell
3481* Installation under UNIX:: How to install GRUB via @command{grub}
3482* Device map:: The map between BIOS drives and OS devices
3483@end menu
3484
3485
3486@node Basic usage
3487@section Introduction into the grub shell
3488
3489You can use the command @command{grub} for installing GRUB under your
3490operating systems and for a testbed when you add a new feature into GRUB
3491or when fixing a bug. @command{grub} is almost the same as the Stage 2,
3492and, in fact, it shares the source code with the Stage 2 and you can use
3493the same commands (@pxref{Commands}) in @command{grub}. It is emulated by
3494replacing BIOS calls with UNIX system calls and libc functions.
3495
3496The command @command{grub} accepts the following options:
3497
3498@table @option
3499@item --help
3500Print a summary of the command-line options and exit.
3501
3502@item --version
3503Print the version number of GRUB and exit.
3504
3505@item --verbose
3506Print some verbose messages for debugging purpose.
3507
3508@item --device-map=@var{file}
3509Use the device map file @var{file}. The format is described in
3510@ref{Device map}.
3511
3512@item --no-floppy
3513Do not probe any floppy drive. This option has no effect if the option
3514@option{--device-map} is specified (@pxref{Device map}).
3515
3516@item --probe-second-floppy
3517Probe the second floppy drive. If this option is not specified, the grub
3518shell does not probe it, as that sometimes takes a long time. If you
3519specify the device map file (@pxref{Device map}), the grub shell just
3520ignores this option.
3521
3522@item --config-file=@var{file}
3523Read the configuration file @var{file} instead of
3524@file{/boot/grub/menu.lst}. The format is the same as the normal GRUB
3525syntax. See @ref{Filesystem}, for more information.
3526
3527@item --boot-drive=@var{drive}
3528Set the stage2 @var{boot_drive} to @var{drive}. This argument should be
3529an integer (decimal, octal or hexadecimal).
3530
3531@item --install-partition=@var{par}
3532Set the stage2 @var{install_partition} to @var{par}. This argument
3533should be an integer (decimal, octal or hexadecimal).
3534
3535@item --no-config-file
3536Do not use the configuration file even if it can be read.
3537
3538@item --no-curses
3539Do not use the screen handling interface by the curses even if it is
3540available.
3541
3542@item --batch
3543This option has the same meaning as @samp{--no-config-file --no-curses}.
3544
3545@item --read-only
3546Disable writing to any disk.
3547
3548@item --hold
3549Wait until a debugger will attach. This option is useful when you want
3550to debug the startup code.
3551@end table
3552
3553
3554@node Installation under UNIX
3555@section How to install GRUB via @command{grub}
3556
3557The installation procedure is the same as under the @dfn{native} Stage
35582. @xref{Installation}, for more information. The command
3559@command{grub}-specific information is described here.
3560
3561What you should be careful about is @dfn{buffer cache}. @command{grub}
3562makes use of raw devices instead of filesystems that your operating
3563systems serve, so there exists a potential problem that some cache
3564inconsistency may corrupt your filesystems. What we recommend is:
3565
3566@itemize @bullet
3567@item
3568If you can unmount drives to which GRUB may write any amount of data,
3569unmount them before running @command{grub}.
3570
3571@item
3572If a drive cannot be unmounted but can be mounted with the read-only
3573flag, mount it in read-only mode. That should be secure.
3574
3575@item
3576If a drive must be mounted with the read-write flag, make sure that no
3577activity is being done on it while the command @command{grub} is
3578running.
3579
3580@item
3581Reboot your operating system as soon as possible. This is probably not
3582required if you follow the rules above, but reboot is the most secure
3583way.
3584@end itemize
3585
3586In addition, enter the command @command{quit} when you finish the
3587installation. That is @emph{very important} because @command{quit} makes
3588the buffer cache consistent. Do not push @key{C-c}.
3589
3590If you want to install GRUB non-interactively, specify @samp{--batch}
3591option in the command-line. This is a simple example:
3592
3593@example
3594@group
3595#!/bin/sh
3596
3597# Use /usr/sbin/grub if you are on an older system.
3598/sbin/grub --batch <<EOT 1>/dev/null 2>/dev/null
3599root (hd0,0)
3600setup (hd0)
3601quit
3602EOT
3603@end group
3604@end example
3605
3606
3607@node Device map
3608@section The map between BIOS drives and OS devices
3609
3610When you specify the option @option{--device-map} (@pxref{Basic usage}),
3611the grub shell creates the @dfn{device map file} automatically unless it
3612already exists. The file name @file{/boot/grub/device.map} is preferred.
3613
3614If the device map file exists, the grub shell reads it to map BIOS
3615drives to OS devices. This file consists of lines like this:
3616
3617@example
3618@var{device} @var{file}
3619@end example
3620
3621@var{device} is a drive specified in the GRUB syntax (@pxref{Device
3622syntax}), and @var{file} is an OS file, which is normally a device
3623file.
3624
3625The reason why the grub shell gives you the device map file is that it
3626cannot guess the map between BIOS drives and OS devices correctly in
3627some environments. For example, if you exchange the boot sequence
3628between IDE and SCSI in your BIOS, it gets the order wrong.
3629
3630Thus, edit the file if the grub shell makes a mistake. You can put any
3631comments in the file if needed, as the grub shell assumes that a line is
3632just a comment if the first character is @samp{#}.
3633
3634
3635@node Invoking grub-install
3636@chapter Invoking grub-install
3637
3638The program @command{grub-install} installs GRUB on your drive using the
3639grub shell (@pxref{Invoking the grub shell}). You must specify the
3640device name on which you want to install GRUB, like this:
3641
3642@example
3643grub-install @var{install_device}
3644@end example
3645
3646The device name @var{install_device} is an OS device name or a GRUB
3647device name.
3648
3649@command{grub-install} accepts the following options:
3650
3651@table @option
3652@item --help
3653Print a summary of the command-line options and exit.
3654
3655@item --version
3656Print the version number of GRUB and exit.
3657
3658@item --force-lba
3659Force GRUB to use LBA mode even for a buggy BIOS. Use this option only
3660if your BIOS doesn't work properly in LBA mode even though it supports
3661LBA mode.
3662
3663@item --root-directory=@var{dir}
3664Install GRUB images under the directory @var{dir} instead of the root
3665directory. This option is useful when you want to install GRUB into a
3666separate partition or a removable disk. Here is an example in which
3667you have a separate @dfn{boot} partition which is mounted on
3668@file{/boot}:
3669
3670@example
3671@kbd{grub-install --root-directory=/boot hd0}
3672@end example
3673
3674@item --grub-shell=@var{file}
3675Use @var{file} as the grub shell. You can append arbitrary options to
3676@var{file} after the file name, like this:
3677
3678@example
3679@kbd{grub-install --grub-shell="grub --read-only" /dev/fd0}
3680@end example
3681
3682@item --recheck
3683Recheck the device map, even if @file{/boot/grub/device.map} already
3684exists. You should use this option whenever you add/remove a disk
3685into/from your computer.
3686@end table
3687
3688
3689@node Invoking grub-md5-crypt
3690@chapter Invoking grub-md5-crypt
3691
3692The program @command{grub-md5-crypt} encrypts a password in MD5 format.
3693This is just a frontend of the grub shell (@pxref{Invoking the grub
3694shell}). Passwords encrypted by this program can be used with the
3695command @command{password} (@pxref{password}).
3696
3697@command{grub-md5-crypt} accepts the following options:
3698
3699@table @option
3700@item --help
3701Print a summary of the command-line options and exit.
3702
3703@item --version
3704Print the version information and exit.
3705
3706@item --grub-shell=@var{file}
3707Use @var{file} as the grub shell.
3708@end table
3709
3710
3711@node Invoking grub-terminfo
3712@chapter Invoking grub-terminfo
3713
3714The program @command{grub-terminfo} generates a terminfo command from
3715a terminfo name (@pxref{terminfo}). The result can be used in the
3716configuration file, to define escape sequences. Because GRUB assumes
3717that your terminal is vt100-compatible by default, this would be
3718useful only if your terminal is uncommon (such as vt52).
3719
3720@command{grub-terminfo} accepts the following options:
3721
3722@table @option
3723@item --help
3724Print a summary of the command-line options and exit.
3725
3726@item --version
3727Print the version information and exit.
3728@end table
3729
3730You must specify one argument to this command. For example:
3731
3732@example
3733@kbd{grub-terminfo vt52}
3734@end example
3735
3736
3737@node Invoking grub-set-default
3738@chapter Invoking grub-set-default
3739
3740The program @command{grub-set-default} sets the default boot entry for
3741GRUB. This automatically creates a file named @file{default} under
3742your GRUB directory (i.e. @file{/boot/grub}), if it is not
3743present. This file is used to determine the default boot entry when
3744GRUB boots up your system when you use @samp{default saved} in your
3745configuration file (@pxref{default}), and to save next default boot
3746entry when you use @samp{savedefault} in a boot entry
3747(@pxref{savedefault}).
3748
3749@command{grub-set-default} accepts the following options:
3750
3751@table @option
3752@item --help
3753Print a summary of the command-line options and exit.
3754
3755@item --version
3756Print the version information and exit.
3757
3758@item --root-directory=@var{dir}
3759Use the directory @var{dir} instead of the root directory
3760(i.e. @file{/}) to define the location of the default file. This
3761is useful when you mount a disk which is used for another system.
3762@end table
3763
3764You must specify a single argument to @command{grub-set-default}. This
3765argument is normally the number of a default boot entry. For example,
3766if you have this configuration file:
3767
3768@example
3769@group
3770default saved
3771timeout 10
3772
3773title GNU/Hurd
3774root (hd0,0)
3775...
3776
3777title GNU/Linux
3778root (hd0,1)
3779...
3780@end group
3781@end example
3782
3783and if you want to set the next default boot entry to GNU/Linux, you
3784may execute this command:
3785
3786@example
3787@kbd{grub-set-default 1}
3788@end example
3789
3790Because the entry for GNU/Linux is @samp{1}. Note that entries are
3791counted from zero. So, if you want to specify GNU/Hurd here, then you
3792should specify @samp{0}.
3793
3794This feature is very useful if you want to test a new kernel or to
3795make your system quite robust. @xref{Making your system robust}, for
3796more hints about how to set up a robust system.
3797
3798
3799@node Invoking mbchk
3800@chapter Invoking mbchk
3801
3802The program @command{mbchk} checks for the format of a Multiboot
3803kernel. We recommend using this program before booting your own kernel
3804by GRUB.
3805
3806@command{mbchk} accepts the following options:
3807
3808@table @option
3809@item --help
3810Print a summary of the command-line options and exit.
3811
3812@item --version
3813Print the version number of GRUB and exit.
3814
3815@item --quiet
3816Suppress all normal output.
3817@end table
3818
3819
3820@node Obtaining and Building GRUB
3821@appendix How to obtain and build GRUB
3822
3823@quotation
3824@strong{Caution:} GRUB requires binutils-2.9.1.0.23 or later because the
3825GNU assembler has been changed so that it can produce real 16bits
3826machine code between 2.9.1 and 2.9.1.0.x. See
3827@uref{http://sources.redhat.com/binutils/}, to obtain information on
3828how to get the latest version.
3829@end quotation
3830
3831GRUB is available from the GNU alpha archive site
3832@uref{ftp://alpha.gnu.org/gnu/grub} or any of its mirrors. The file
3833will be named grub-version.tar.gz. The current version is
3834@value{VERSION}, so the file you should grab is:
3835
3836@uref{ftp://alpha.gnu.org/gnu/grub/grub-@value{VERSION}.tar.gz}
3837
3838To unbundle GRUB use the instruction:
3839
3840@example
3841@kbd{zcat grub-@value{VERSION}.tar.gz | tar xvf -}
3842@end example
3843
3844which will create a directory called @file{grub-@value{VERSION}} with
3845all the sources. You can look at the file @file{INSTALL} for detailed
3846instructions on how to build and install GRUB, but you should be able to
3847just do:
3848
3849@example
3850@group
3851@kbd{cd grub-@value{VERSION}}
3852@kbd{./configure}
3853@kbd{make install}
3854@end group
3855@end example
3856
3857This will install the grub shell @file{grub} (@pxref{Invoking the grub
3858shell}), the Multiboot checker @file{mbchk} (@pxref{Invoking mbchk}),
3859and the GRUB images. This will also install the GRUB manual.
3860
3861Also, the latest version is available from the CVS. See
3862@uref{http://savannah.gnu.org/cvs/?group=grub} for more information.
3863
3864
3865@node Reporting bugs
3866@appendix Reporting bugs
3867
3868These are the guideline for how to report bugs. Take a look at this
3869list below before you submit bugs:
3870
3871@enumerate
3872@item
3873Before getting unsettled, read this manual through and through. Also,
3874see the @uref{http://www.gnu.org/software/grub/grub-faq.html, GNU GRUB FAQ}.
3875
3876@item
3877Always mention the information on your GRUB. The version number and the
3878configuration are quite important. If you build it yourself, write the
3879options specified to the configure script and your operating system,
3880including the versions of gcc and binutils.
3881
3882@item
3883If you have trouble with the installation, inform us of how you
3884installed GRUB. Don't omit error messages, if any. Just @samp{GRUB hangs
3885up when it boots} is not enough.
3886
3887The information on your hardware is also essential. These are especially
3888important: the geometries and the partition tables of your hard disk
3889drives and your BIOS.
3890
3891@item
3892If GRUB cannot boot your operating system, write down
3893@emph{everything} you see on the screen. Don't paraphrase them, like
3894@samp{The foo OS crashes with GRUB, even though it can boot with the
3895bar boot loader just fine}. Mention the commands you executed, the
3896messages printed by them, and information on your operating system
3897including the version number.
3898
3899@item
3900Explain what you wanted to do. It is very useful to know your purpose
3901and your wish, and how GRUB didn't satisfy you.
3902
3903@item
3904If you can investigate the problem yourself, please do. That will give
3905you and us much more information on the problem. Attaching a patch is
3906even better.
3907
3908When you attach a patch, make the patch in unified diff format, and
3909write ChangeLog entries. But, even when you make a patch, don't forget
3910to explain the problem, so that we can understand what your patch is
3911for.
3912
3913@item
3914Write down anything that you think might be related. Please understand
3915that we often need to reproduce the same problem you encounterred in our
3916environment. So your information should be sufficient for us to do the
3917same thing---Don't forget that we cannot see your computer directly. If
3918you are not sure whether to state a fact or leave it out, state it!
3919Reporting too many things is much better than omitting something
3920important.
3921@end enumerate
3922
3923If you follow the guideline above, submit a report to the
3924@uref{http://savannah.gnu.org/bugs/?group=grub, Bug Tracking System}.
3925Alternatively, you can submit a report via electronic mail to
3926@email{bug-grub@@gnu.org}, but we strongly recommend that you use the
3927Bug Tracking System, because e-mail can be passed over easily.
3928
3929Once we get your report, we will try to fix the bugs.
3930
3931
3932@node Future
3933@appendix Where GRUB will go
3934
3935We started the next generation of GRUB, GRUB 2. This will include
3936internationalization, dynamic module loading, real memory management,
3937multiple architecture support, a scripting language, and many other
3938nice feature. If you are interested in the development of GRUB 2, take
3939a look at @uref{http://www.gnu.org/software/grub/grub.html, the
3940homepage}.
3941
3942
3943
3944@node Copying This Manual
3945@appendix Copying This Manual
3946
3947@menu
3948* GNU Free Documentation License:: License for copying this manual.
3949@end menu
3950
3951@include fdl.texi
3952
3953
3954@node Index
3955@unnumbered Index
3956
3957@c Currently, we use only the Concept Index.
3958@printindex cp
3959
3960
3961@bye
3962
3963Some notes:
3964
3965 This is an attempt to make a manual for GRUB 2. The contents are
3966 copied from the GRUB manual in GRUB Legacy, so they are not always
3967 appropriate yet for GRUB 2.