~hamo/ubuntu/precise/grub2/grub2.hi_res

« back to all changes in this revision

Viewing changes to docs/grub.texi

Tags: upstream-1.98+20100705
ImportĀ upstreamĀ versionĀ 1.98+20100705

Show diffs side-by-side

added added

removed removed

Lines of Context:
80
80
* Network::                     Downloading OS images from a network
81
81
* Serial terminal::             Using GRUB via a serial line
82
82
* Vendor power-on keys::        Changing GRUB behaviour on vendor power-on keys
83
 
* Preset Menu::                 Embedding a configuration file into GRUB
84
83
* Images::                      GRUB image files
85
84
* Filesystem::                  Filesystem syntax and semantics
86
85
* Interface::                   The menu and the command-line
107
106
* Overview::                    What exactly GRUB is and how to use it
108
107
* History::                     From maggot to house fly
109
108
* Features::                    GRUB features
 
109
* Changes from GRUB Legacy::    Differences from previous versions
110
110
* Role of a boot loader::       The role of a boot loader
111
111
@end menu
112
112
 
191
191
it by default.
192
192
 
193
193
 
 
194
@node Changes from GRUB Legacy
 
195
@section Differences from previous versions
 
196
 
 
197
GRUB 2 is a rewrite of GRUB (@pxref{History}), although it shares many
 
198
characteristics with the previous version, now known as GRUB Legacy.  Users
 
199
of GRUB Legacy may need some guidance to find their way around this new
 
200
version.
 
201
 
 
202
@itemize @bullet
 
203
@item
 
204
The configuration file has a new name (@file{grub.cfg} rather than
 
205
@file{menu.lst} or @file{grub.conf}), new syntax (@pxref{Configuration}) and
 
206
many new commands (@pxref{Commands}).  Configuration cannot be copied over
 
207
directly, although most GRUB Legacy users should not find the syntax too
 
208
surprising.
 
209
 
 
210
@item
 
211
@file{grub.cfg} is typically automatically generated by
 
212
@command{grub-mkconfig} (@pxref{Simple configuration}).  This makes it
 
213
easier to handle versioned kernel upgrades.
 
214
 
 
215
@item
 
216
Partition numbers in GRUB device names now start at 1, not 0 (@pxref{Naming
 
217
convention}).
 
218
 
 
219
@item
 
220
The configuration file is now written in something closer to a full
 
221
scripting language: variables, conditionals, and loops are available.
 
222
 
 
223
@item
 
224
A small amount of persistent storage is available across reboots, using the
 
225
@command{save_env} and @command{load_env} commands in GRUB and the
 
226
@command{grub-editenv} utility.
 
227
 
 
228
@item
 
229
GRUB 2 has more reliable ways to find its own files and those of target
 
230
kernels on multiple-disk systems, and has commands (@pxref{search}) to find
 
231
devices using file system labels or Universally Unique Identifiers (UUIDs).
 
232
 
 
233
@item
 
234
GRUB 2 is available for several other types of system in addition to the PC
 
235
BIOS systems supported by GRUB Legacy: PC EFI, PC coreboot, PowerPC, SPARC,
 
236
and MIPS Lemote Yeeloong are all supported.
 
237
 
 
238
@item
 
239
Many more file systems are supported, including but not limited to ext4,
 
240
HFS+, and NTFS.
 
241
 
 
242
@item
 
243
GRUB 2 can read files directly from LVM and RAID devices.
 
244
 
 
245
@item
 
246
A graphical terminal and a graphical menu system are available.
 
247
 
 
248
@item
 
249
GRUB 2's interface can be translated, including menu entry names.
 
250
 
 
251
@item
 
252
The image files (@pxref{Images}) that make up GRUB have been reorganised;
 
253
Stage 1, Stage 1.5, and Stage 2 are no more.
 
254
 
 
255
@item
 
256
GRUB 2 puts many facilities in dynamically loaded modules, allowing the core
 
257
image to be smaller, and allowing the core image to be built in more
 
258
flexible ways.
 
259
@end itemize
 
260
 
 
261
 
194
262
@node Features
195
263
@section GRUB features
196
264
 
471
539
@menu
472
540
* Installing GRUB using grub-install::
473
541
* Making a GRUB bootable CD-ROM::
 
542
* Device map::
474
543
@end menu
475
544
 
476
545
 
615
684
@samp{(cd)} if you want to access other drives as well.
616
685
 
617
686
 
 
687
@node Device map
 
688
@section The map between BIOS drives and OS devices
 
689
 
 
690
The @command{grub-mkdevicemap} program can be used to create the @dfn{device
 
691
map file}.  It is often run automatically by tools such as
 
692
@command{grub-install} if the device map file does not already exist.  The
 
693
file name @file{/boot/grub/device.map} is preferred.
 
694
 
 
695
If the device map file exists, the GRUB utilities (@command{grub-probe},
 
696
@command{grub-setup}, etc.) read it to map BIOS drives to OS devices.  This
 
697
file consists of lines like this:
 
698
 
 
699
@example
 
700
@var{device} @var{file}
 
701
@end example
 
702
 
 
703
@var{device} is a drive specified in the GRUB syntax (@pxref{Device
 
704
syntax}), and @var{file} is an OS file, which is normally a device file.
 
705
 
 
706
Historically, the device map file was used because GRUB device names had to
 
707
be used in the configuration file, and they were derived from BIOS drive
 
708
numbers.  The map between BIOS drives and OS devices cannot always be
 
709
guessed correctly: for example, GRUB will get the order wrong if you
 
710
exchange the boot sequence between IDE and SCSI in your BIOS.
 
711
 
 
712
Unfortunately, even OS device names are not always stable.  Modern versions
 
713
of the Linux kernel may probe drives in a different order from boot to boot,
 
714
and the prefix (@file{/dev/hd*} versus @file{/dev/sd*}) may change depending
 
715
on the driver subsystem in use.  As a result, the device map file required
 
716
frequent editing on some systems.
 
717
 
 
718
GRUB avoids this problem nowadays by using UUIDs or file system labels when
 
719
generating @file{grub.cfg}, and we advise that you do the same for any
 
720
custom menu entries you write.  If the device map file does not exist, then
 
721
the GRUB utilities will assume a temporary device map on the fly.  This is
 
722
often good enough, particularly in the common case of single-disk systems.
 
723
 
 
724
However, the device map file is not entirely obsolete yet, and there are
 
725
still some situations that require it to exist.  If necessary, you may edit
 
726
the file if @command{grub-mkdevicemap} makes a mistake.  You can put any
 
727
comments in the file if needed, as the GRUB utilities assume that a line is
 
728
just a comment if the first character is @samp{#}.
 
729
 
 
730
 
618
731
@node Booting
619
732
@chapter Booting
620
733
 
805
918
@menu
806
919
* Simple configuration::        Recommended for most users
807
920
* Shell-like scripting::        For power users and developers
 
921
* Embedded configuration::      Embedding a configuration file into GRUB
 
922
* Themes::                      Graphical menu themes
808
923
@end menu
809
924
 
810
925
 
911
1026
Command-line arguments to add to menu entries for the Linux kernel.
912
1027
 
913
1028
@item GRUB_CMDLINE_LINUX_DEFAULT
914
 
Unless @samp{GRUB_DISABLE_LINUX_RECOVERY} is set, two menu entries will be
915
 
generated for each Linux kernel: one default entry and one entry for
916
 
recovery mode.  This option lists command-line arguments to add only to the
917
 
default menu entry, after those listed in @samp{GRUB_CMDLINE_LINUX}.
 
1029
Unless @samp{GRUB_DISABLE_LINUX_RECOVERY} is set to @samp{true}, two menu
 
1030
entries will be generated for each Linux kernel: one default entry and one
 
1031
entry for recovery mode.  This option lists command-line arguments to add
 
1032
only to the default menu entry, after those listed in
 
1033
@samp{GRUB_CMDLINE_LINUX}.
918
1034
 
919
1035
@item GRUB_CMDLINE_NETBSD
920
1036
@itemx GRUB_CMDLINE_NETBSD_DEFAULT
929
1045
disable the use of UUIDs, set this option to @samp{true}.
930
1046
 
931
1047
@item GRUB_DISABLE_LINUX_RECOVERY
932
 
Disable the generation of recovery mode menu entries for Linux.
 
1048
If this option is set to @samp{true}, disable the generation of recovery
 
1049
mode menu entries for Linux.
933
1050
 
934
1051
@item GRUB_DISABLE_NETBSD_RECOVERY
935
 
Disable the generation of recovery mode menu entries for NetBSD.
 
1052
If this option is set to @samp{true}, disable the generation of recovery
 
1053
mode menu entries for NetBSD.
 
1054
 
 
1055
@item GRUB_VIDEO_BACKEND
 
1056
If graphical video support is required, either because the @samp{gfxterm}
 
1057
graphical terminal is in use or because @samp{GRUB_GFXPAYLOAD_LINUX} is set,
 
1058
then @command{grub-mkconfig} will normally load all available GRUB video
 
1059
drivers and use the one most appropriate for your hardware.  If you need to
 
1060
override this for some reason, then you can set this option.
 
1061
 
 
1062
After @command{grub-install} has been run, the available video drivers are
 
1063
listed in @file{/boot/grub/video.lst}.
936
1064
 
937
1065
@item GRUB_GFXMODE
938
1066
Set the resolution used on the @samp{gfxterm} graphical terminal.  Note that
973
1101
Play a tune on the speaker when GRUB starts.  This is particularly useful
974
1102
for users unable to see the screen.  The value of this option is passed
975
1103
directly to @ref{play}.
 
1104
 
 
1105
@item GRUB_BADRAM
 
1106
If this option is set, GRUB will issue a @ref{badram} command to filter
 
1107
out specified regions of RAM.
 
1108
 
976
1109
@end table
977
1110
 
978
1111
For more detailed customisation of @command{grub-mkconfig}'s output, you may
986
1119
@section Writing full configuration files directly
987
1120
 
988
1121
 
 
1122
@node Embedded configuration
 
1123
@section Embedding a configuration file into GRUB
 
1124
 
 
1125
GRUB supports embedding a configuration file directly into the core image,
 
1126
so that it is loaded before entering normal mode.  This is useful, for
 
1127
example, when it is not straightforward to find the real configuration file,
 
1128
or when you need to debug problems with loading that file.
 
1129
@command{grub-install} uses this feature when it is not using BIOS disk
 
1130
functions or when installing to a different disk from the one containing
 
1131
@file{/boot/grub}, in which case it needs to use the @command{search}
 
1132
command (@pxref{search}) to find @file{/boot/grub}.
 
1133
 
 
1134
To embed a configuration file, use the @option{-c} option to
 
1135
@command{grub-mkimage}.  The file is copied into the core image, so it may
 
1136
reside anywhere on the file system, and may be removed after running
 
1137
@command{grub-mkimage}.
 
1138
 
 
1139
After the embedded configuration file (if any) is executed, GRUB will load
 
1140
the @samp{normal} module, which will then read the real configuration file
 
1141
from @file{$prefix/grub.cfg}.  By this point, the @code{root} variable will
 
1142
also have been set to the root device name.  For example, @code{prefix}
 
1143
might be set to @samp{(hd0,1)/boot/grub}, and @code{root} might be set to
 
1144
@samp{hd0,1}.  Thus, in most cases, the embedded configuration file only
 
1145
needs to set the @code{prefix} and @code{root} variables, and then drop
 
1146
through to GRUB's normal processing.  A typical example of this might look
 
1147
like this:
 
1148
 
 
1149
@example
 
1150
@group
 
1151
search.fs_uuid 01234567-89ab-cdef-0123-456789abcdef root
 
1152
set prefix=($root)/boot/grub
 
1153
@end group
 
1154
@end example
 
1155
 
 
1156
(The @samp{search_fs_uuid} module must be included in the core image for this
 
1157
example to work.)
 
1158
 
 
1159
In more complex cases, it may be useful to read other configuration files
 
1160
directly from the embedded configuration file.  This allows such things as
 
1161
reading files not called @file{grub.cfg}, or reading files from a directory
 
1162
other than that where GRUB's loadable modules are installed.  To do this,
 
1163
include the @samp{configfile} and @samp{normal} modules in the core image,
 
1164
and embed a configuration file that uses the @command{configfile} command to
 
1165
load another file.  The following example of this also requires the
 
1166
@command{echo}, @command{search_label}, and @command{test} modules to be
 
1167
included in the core image:
 
1168
 
 
1169
@example
 
1170
@group
 
1171
search.fs_label grub root
 
1172
if [ -e /boot/grub/example/test1.cfg ]; then
 
1173
    set prefix=($root)/boot/grub
 
1174
    configfile /boot/grub/example/test1.cfg
 
1175
else
 
1176
    if [ -e /boot/grub/example/test2.cfg ]; then
 
1177
        set prefix=($root)/boot/grub
 
1178
        configfile /boot/grub/example/test2.cfg
 
1179
    else
 
1180
        echo "Could not find an example configuration file!"
 
1181
    fi
 
1182
fi
 
1183
@end group
 
1184
@end example
 
1185
 
 
1186
The embedded configuration file may not contain menu entries directly, but
 
1187
may only read them from elsewhere using @command{configfile}.
 
1188
 
 
1189
 
 
1190
@node Themes
 
1191
@section Graphical menu themes
 
1192
 
 
1193
 
989
1194
@node Network
990
1195
@chapter Booting GRUB from the network
991
1196
 
1109
1314
GRUB provides you with an alternative menu interface, because the normal
1110
1315
menu requires several fancy features of your terminal.
1111
1316
 
 
1317
 
1112
1318
@node Vendor power-on keys
1113
1319
@chapter Using GRUB with vendor power-on keys
1114
1320
Some laptop vendor provide an additional power-on button which boots another OS.
1129
1335
 
1130
1336
To take full advantage of this function install GRUB into MBR.
1131
1337
 
 
1338
 
 
1339
@node Images
 
1340
@chapter GRUB image files
 
1341
 
 
1342
@c FIXME: parts of this section are specific to PC BIOS right now.
 
1343
 
 
1344
GRUB consists of several images: a variety of bootstrap images for starting
 
1345
GRUB in various ways, a kernel image, and a set of modules which are
 
1346
combined with the kernel image to form a core image.  Here is a short
 
1347
overview of them.
 
1348
 
 
1349
@table @file
 
1350
@item boot.img
 
1351
On PC BIOS systems, this image is the first part of GRUB to start.  It is
 
1352
written to a master boot record (MBR) or to the boot sector of a partition.
 
1353
Because a PC boot sector is 512 bytes, the size of this image is exactly 512
 
1354
bytes.
 
1355
 
 
1356
The sole function of @file{boot.img} is to read the first sector of the core
 
1357
image from a local disk and jump to it.  Because of the size restriction,
 
1358
@file{boot.img} cannot understand any file system structure, so
 
1359
@command{grub-setup} hardcodes the location of the first sector of the core
 
1360
image into @file{boot.img} when installing GRUB.
 
1361
 
 
1362
@item diskboot.img
 
1363
This image is used as the first sector of the core image when booting from a
 
1364
hard disk.  It reads the rest of the core image into memory and starts the
 
1365
kernel.  Since file system handling is not yet available, it encodes the
 
1366
location of the core image using a block list format.
 
1367
 
 
1368
@item cdboot.img
 
1369
This image is used as the first sector of the core image when booting from a
 
1370
CD-ROM drive.  It performs a similar function to @file{diskboot.img}.
 
1371
 
 
1372
@item pxeboot.img
 
1373
This image is used as the start of the core image when booting from the
 
1374
network using PXE.  @xref{Network}.
 
1375
 
 
1376
@item lnxboot.img
 
1377
This image may be placed at the start of the core image in order to make
 
1378
GRUB look enough like a Linux kernel that it can be booted by LILO using an
 
1379
@samp{image=} section.
 
1380
 
 
1381
@item kernel.img
 
1382
This image contains GRUB's basic run-time facilities: frameworks for device
 
1383
and file handling, environment variables, the rescue mode command-line
 
1384
parser, and so on.  It is rarely used directly, but is built into all core
 
1385
images.
 
1386
 
 
1387
@item core.img
 
1388
This is the core image of GRUB.  It is built dynamically from the kernel
 
1389
image and an arbitrary list of modules by the @command{grub-mkimage}
 
1390
program.  Usually, it contains enough modules to access @file{/boot/grub},
 
1391
and loads everything else (including menu handling, the ability to load
 
1392
target operating systems, and so on) from the file system at run-time.  The
 
1393
modular design allows the core image to be kept small, since the areas of
 
1394
disk where it must be installed are often as small as 32KB.
 
1395
 
 
1396
On PC systems using the traditional MBR partition table format, the core
 
1397
image is usually installed in the "MBR gap" between the master boot record
 
1398
and the first partition, or sometimes it is installed in a file system and
 
1399
read directly from that.  The latter is not recommended because GRUB needs
 
1400
to encode the location of all the core image sectors in @file{diskboot.img},
 
1401
and if the file system ever moves the core image around (as it is entitled
 
1402
to do) then GRUB must be reinstalled; it also means that GRUB will not be
 
1403
able to reliably find the core image if it resides on a different disk than
 
1404
the one to which @file{boot.img} was installed.
 
1405
 
 
1406
On PC systems using the more recent GUID Partition Table (GPT) format, the
 
1407
core image should be installed to a BIOS Boot Partition.  This may be
 
1408
created by GNU Parted using a command such as the following:
 
1409
 
 
1410
@example
 
1411
# @kbd{parted /dev/@var{disk} set @var{partition-number} bios_grub on}
 
1412
@end example
 
1413
 
 
1414
@strong{Caution:} Be very careful which partition you select!  When GRUB
 
1415
finds a BIOS Boot Partition during installation, it will automatically
 
1416
overwrite part of it.  Make sure that the partition does not contain any
 
1417
other data.
 
1418
 
 
1419
@item *.mod
 
1420
Everything else in GRUB resides in dynamically loadable modules.  These are
 
1421
often loaded automatically, or built into the core image if they are
 
1422
essential, but may also be loaded manually using the @command{insmod}
 
1423
command (@pxref{insmod}).
 
1424
@end table
 
1425
 
 
1426
@heading For GRUB Legacy users
 
1427
 
 
1428
GRUB 2 has a different design from GRUB Legacy, and so correspondences with
 
1429
the images it used cannot be exact.  Nevertheless, GRUB Legacy users often
 
1430
ask questions in the terms they are familiar with, and so here is a brief
 
1431
guide to how GRUB 2's images relate to that.
 
1432
 
 
1433
@table @file
 
1434
@item stage1
 
1435
Stage 1 from GRUB Legacy was very similar to @file{boot.img} in GRUB 2, and
 
1436
they serve the same function.
 
1437
 
 
1438
@item *_stage1_5
 
1439
In GRUB Legacy, Stage 1.5's function was to include enough filesystem code
 
1440
to allow the much larger Stage 2 to be read from an ordinary filesystem.  In
 
1441
this respect, its function was similar to @file{core.img} in GRUB 2.
 
1442
However, @file{core.img} is much more capable than Stage 1.5 was; since it
 
1443
offers a rescue shell, it is sometimes possible to recover manually in the
 
1444
event that it is unable to load any other modules, for example if partition
 
1445
numbers have changed.  @file{core.img} is built in a more flexible way,
 
1446
allowing GRUB 2 to support reading modules from advanced disk types such as
 
1447
LVM and RAID.
 
1448
 
 
1449
GRUB Legacy could run with only Stage 1 and Stage 2 in some limited
 
1450
configurations, while GRUB 2 requires @file{core.img} and cannot work
 
1451
without it.
 
1452
 
 
1453
@item stage2
 
1454
GRUB 2 has no single Stage 2 image.  Instead, it loads modules from
 
1455
@file{/boot/grub} at run-time.
 
1456
 
 
1457
@item stage2_eltorito
 
1458
In GRUB 2, images for booting from CD-ROM drives are now constructed using
 
1459
@file{cdboot.img} and @file{core.img}, making sure that the core image
 
1460
contains the @samp{iso9660} module.  It is usually best to use the
 
1461
@command{grub-mkrescue} program for this.
 
1462
 
 
1463
@item nbgrub
 
1464
There is as yet no equivalent for @file{nbgrub} in GRUB 2; it was used by
 
1465
Etherboot and some other network boot loaders.
 
1466
 
 
1467
@item pxegrub
 
1468
In GRUB 2, images for PXE network booting are now constructed using
 
1469
@file{pxeboot.img} and @file{core.img}, making sure that the core image
 
1470
contains the @samp{pxe} and @samp{pxecmd} modules.  @xref{Network}.
 
1471
@end table
 
1472
 
 
1473
 
1132
1474
@node Filesystem
1133
1475
@chapter Filesystem syntax and semantics
1134
1476
 
1536
1878
 
1537
1879
@menu
1538
1880
* acpi::                        Load ACPI tables
 
1881
* badram::                      Filter out bad regions of RAM
1539
1882
* blocklist::                   Print a block list
1540
1883
* boot::                        Start up your operating system
1541
1884
* cat::                         Show the contents of a file
1589
1932
GRUB, but may be used by GRUB's EFI emulation.
1590
1933
@end deffn
1591
1934
 
 
1935
@node badram
 
1936
@subsection badram
 
1937
 
 
1938
@deffn Command badram addr,mask[,addr,mask...]
 
1939
Filter out bad RAM.
 
1940
@end deffn
 
1941
 
 
1942
This command notifies the memory manager that specified regions of
 
1943
RAM ought to be filtered out (usually, because they're damaged).  This
 
1944
remains in effect after a payload kernel has been loaded by GRUB, as
 
1945
long as the loaded kernel obtains its memory map from GRUB.  Kernels that
 
1946
support this include Linux, GNU Mach, the kernel of FreeBSD and Multiboot
 
1947
kernels in general.
 
1948
 
 
1949
Syntax is the same as provided by the @uref{http://www.memtest.org/,
 
1950
Memtest86+ utility}: a list of address/mask pairs.  Given a page-aligned
 
1951
address and a base address / mask pair, if all the bits of the page-aligned
 
1952
address that are enabled by the mask match with the base address, it means
 
1953
this page is to be filtered.  This syntax makes it easy to represent patterns
 
1954
that are often result of memory damage, due to physical distribution of memory
 
1955
cells.
1592
1956
 
1593
1957
@node blocklist
1594
1958
@subsection blocklist
1611
1975
@node cat
1612
1976
@subsection cat
1613
1977
 
1614
 
@deffn Command cat file
 
1978
@deffn Command cat [@option{--dos}] file
1615
1979
Display the contents of the file @var{file}. This command may be useful
1616
1980
to remind you of your OS's root partition:
1617
1981
 
1618
1982
@example
1619
1983
grub> @kbd{cat /etc/fstab}
1620
1984
@end example
 
1985
 
 
1986
If the @option{--dos} option is used, then carriage return / new line pairs
 
1987
will be displayed as a simple new line.  Otherwise, the carriage return will
 
1988
be displayed as a control character (@samp{<d>}) to make it easier to see
 
1989
when boot problems are caused by a file formatted using DOS-style line
 
1990
endings.
1621
1991
@end deffn
1622
1992
 
1623
1993
 
1660
2030
@subsection configfile
1661
2031
 
1662
2032
@deffn Command configfile file
1663
 
Load @var{file} as a configuration file.
 
2033
Load @var{file} as a configuration file.  If @var{file} defines any menu
 
2034
entries, then show a menu containing them immediately.
1664
2035
@end deffn
1665
2036
 
1666
2037
 
2353
2724
We started the next generation of GRUB, GRUB 2. GRUB 2 includes
2354
2725
internationalization, dynamic module loading, real memory management,
2355
2726
multiple architecture support, a scripting language, and many other
2356
 
nice feature. If you are interested in the development of GRUB 2, take
 
2727
nice features. If you are interested in the development of GRUB 2, take
2357
2728
a look at @uref{http://www.gnu.org/software/grub/grub.html, the
2358
2729
homepage}.
2359
2730