grub.texi 53 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596
  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. @footnotestyle separate
  15. @paragraphindent 3
  16. @finalout
  17. @copying
  18. This manual is for GNU GRUB (version @value{VERSION},
  19. @value{UPDATED}).
  20. Copyright @copyright{} 1999,2000,2001,2002,2004,2006,2008,2009 Free Software Foundation, Inc.
  21. @quotation
  22. Permission is granted to copy, distribute and/or modify this document
  23. under the terms of the GNU Free Documentation License, Version 1.2 or
  24. any later version published by the Free Software Foundation; with no
  25. Invariant Sections.
  26. @end quotation
  27. @end copying
  28. @dircategory Kernel
  29. @direntry
  30. * GRUB: (grub). The GRand Unified Bootloader
  31. * grub-install: (grub)Invoking grub-install. Install GRUB on your drive
  32. * grub-terminfo: (grub)Invoking grub-terminfo. Generate a terminfo
  33. command from a
  34. terminfo name
  35. @end direntry
  36. @setchapternewpage odd
  37. @titlepage
  38. @sp 10
  39. @title the GNU GRUB manual
  40. @subtitle The GRand Unified Bootloader, version @value{VERSION}, @value{UPDATED}.
  41. @author Gordon Matzigkeit
  42. @author Yoshinori K. Okuji
  43. @c The following two commands start the copyright page.
  44. @page
  45. @vskip 0pt plus 1filll
  46. @insertcopying
  47. @end titlepage
  48. @c Output the table of contents at the beginning.
  49. @contents
  50. @finalout
  51. @headings double
  52. @ifnottex
  53. @node Top
  54. @top GNU GRUB manual
  55. This is the documentation of GNU GRUB, the GRand Unified Bootloader,
  56. a flexible and powerful boot loader program for a wide range of
  57. architectures.
  58. This edition documents version @value{VERSION}.
  59. @insertcopying
  60. @end ifnottex
  61. @menu
  62. * Introduction:: Capturing the spirit of GRUB
  63. * Naming convention:: Names of your drives in GRUB
  64. * Installation:: Installing GRUB on your drive
  65. * Booting:: How to boot different operating systems
  66. * Configuration:: Writing your own configuration file
  67. * Network:: Downloading OS images from a network
  68. * Serial terminal:: Using GRUB via a serial line
  69. * Preset Menu:: Embedding a configuration file into GRUB
  70. * Images:: GRUB image files
  71. * Filesystem:: Filesystem syntax and semantics
  72. * Interface:: The menu and the command-line
  73. * Commands:: The list of available builtin commands
  74. * Troubleshooting:: Error messages produced by GRUB
  75. * Invoking the grub shell:: How to use the grub shell
  76. * Invoking grub-install:: How to use the GRUB installer
  77. * Invoking grub-terminfo:: How to generate a terminfo command
  78. * Obtaining and Building GRUB:: How to obtain and build GRUB
  79. * Reporting bugs:: Where you should send a bug report
  80. * Future:: Some future plans on GRUB
  81. * Internals:: Hacking GRUB
  82. * Copying This Manual:: Copying This Manual
  83. * Index::
  84. @end menu
  85. @node Introduction
  86. @chapter Introduction to GRUB
  87. @menu
  88. * Overview:: What exactly GRUB is and how to use it
  89. * History:: From maggot to house fly
  90. * Features:: GRUB features
  91. * Role of a boot loader:: The role of a boot loader
  92. @end menu
  93. @node Overview
  94. @section Overview
  95. Briefly, a @dfn{boot loader} is the first software program that runs when
  96. a computer starts. It is responsible for loading and transferring
  97. control to an operating system @dfn{kernel} software (such as Linux or
  98. GNU Mach). The kernel, in turn, initializes the rest of the operating
  99. system (e.g. a GNU system).
  100. GNU GRUB is a very powerful boot loader, which can load a wide variety
  101. of free operating systems, as well as proprietary operating systems with
  102. chain-loading@footnote{@dfn{chain-load} is the mechanism for loading
  103. unsupported operating systems by loading another boot loader. It is
  104. typically used for loading DOS or Windows.}. GRUB is designed to
  105. address the complexity of booting a personal computer; both the
  106. program and this manual are tightly bound to that computer platform,
  107. although porting to other platforms may be addressed in the future.
  108. One of the important features in GRUB is flexibility; GRUB understands
  109. filesystems and kernel executable formats, so you can load an arbitrary
  110. operating system the way you like, without recording the physical
  111. position of your kernel on the disk. Thus you can load the kernel
  112. just by specifying its file name and the drive and partition where the
  113. kernel resides.
  114. When booting with GRUB, you can use either a command-line interface
  115. (@pxref{Command-line interface}), or a menu interface (@pxref{Menu
  116. interface}). Using the command-line interface, you type the drive
  117. specification and file name of the kernel manually. In the menu
  118. interface, you just select an OS using the arrow keys. The menu is
  119. based on a configuration file which you prepare beforehand
  120. (@pxref{Configuration}). While in the menu, you can switch to the
  121. command-line mode, and vice-versa. You can even edit menu entries
  122. before using them.
  123. In the following chapters, you will learn how to specify a drive, a
  124. partition, and a file name (@pxref{Naming convention}) to GRUB, how to
  125. install GRUB on your drive (@pxref{Installation}), and how to boot your
  126. OSes (@pxref{Booting}), step by step.
  127. @node History
  128. @section History of GRUB
  129. GRUB originated in 1995 when Erich Boleyn was trying to boot the GNU
  130. Hurd with the University of Utah's Mach 4 microkernel (now known as GNU
  131. Mach). Erich and Brian Ford designed the Multiboot Specification
  132. (@pxref{Top, Multiboot Specification, Motivation, multiboot, The Multiboot
  133. Specification}), because they were determined not to add to the large
  134. number of mutually-incompatible PC boot methods.
  135. Erich then began modifying the FreeBSD boot loader so that it would
  136. understand Multiboot. He soon realized that it would be a lot easier
  137. to write his own boot loader from scratch than to keep working on the
  138. FreeBSD boot loader, and so GRUB was born.
  139. Erich added many features to GRUB, but other priorities prevented him
  140. from keeping up with the demands of its quickly-expanding user base. In
  141. 1999, Gordon Matzigkeit and Yoshinori K. Okuji adopted GRUB as an
  142. official GNU package, and opened its development by making the latest
  143. sources available via anonymous CVS. @xref{Obtaining and Building
  144. GRUB}, for more information.
  145. @node Features
  146. @section GRUB features
  147. The primary requirement for GRUB is that it be compliant with the
  148. @dfn{Multiboot Specification}, which is described in @ref{Top, Multiboot
  149. Specification, Motivation, multiboot, The Multiboot Specification}.
  150. The other goals, listed in approximate order of importance, are:
  151. @itemize @bullet{}
  152. @item
  153. Basic functions must be straightforward for end-users.
  154. @item
  155. Rich functionality to support kernel experts and designers.
  156. @item
  157. Backward compatibility for booting FreeBSD, NetBSD, OpenBSD, and
  158. Linux. Proprietary kernels (such as DOS, Windows NT, and OS/2) are
  159. supported via a chain-loading function.
  160. @end itemize
  161. Except for specific compatibility modes (chain-loading and the Linux
  162. @dfn{piggyback} format), all kernels will be started in much the same
  163. state as in the Multiboot Specification. Only kernels loaded at 1 megabyte
  164. or above are presently supported. Any attempt to load below that
  165. boundary will simply result in immediate failure and an error message
  166. reporting the problem.
  167. In addition to the requirements above, GRUB has the following features
  168. (note that the Multiboot Specification doesn't require all the features
  169. that GRUB supports):
  170. @table @asis
  171. @item Recognize multiple executable formats
  172. Support many of the @dfn{a.out} variants plus @dfn{ELF}. Symbol
  173. tables are also loaded.
  174. @item Support non-Multiboot kernels
  175. Support many of the various free 32-bit kernels that lack Multiboot
  176. compliance (primarily FreeBSD, NetBSD, OpenBSD, and
  177. Linux). Chain-loading of other boot loaders is also supported.
  178. @item Load multiples modules
  179. Fully support the Multiboot feature of loading multiple modules.
  180. @item Load a configuration file
  181. Support a human-readable text configuration file with preset boot
  182. commands. You can also load another configuration file dynamically and
  183. embed a preset configuration file in a GRUB image file. The list of
  184. commands (@pxref{Commands}) are a superset of those supported on the
  185. command-line. An example configuration file is provided in
  186. @ref{Configuration}.
  187. @item Provide a menu interface
  188. A menu interface listing preset boot commands, with a programmable
  189. timeout, is available. There is no fixed limit on the number of boot
  190. entries, and the current implementation has space for several hundred.
  191. @item Have a flexible command-line interface
  192. A fairly flexible command-line interface, accessible from the menu,
  193. is available to edit any preset commands, or write a new boot command
  194. set from scratch. If no configuration file is present, GRUB drops to
  195. the command-line.
  196. The list of commands (@pxref{Commands}) are a subset of those supported
  197. for configuration files. Editing commands closely resembles the Bash
  198. command-line (@pxref{Command Line Editing, Bash, Command Line Editing,
  199. features, Bash Features}), with @key{TAB}-completion of commands,
  200. devices, partitions, and files in a directory depending on context.
  201. @item Support multiple filesystem types
  202. Support multiple filesystem types transparently, plus a useful explicit
  203. blocklist notation. The currently supported filesystem types are
  204. @dfn{BSD FFS}, @dfn{DOS FAT16 and FAT32}, @dfn{Minix fs}, @dfn{Linux
  205. ext2fs}, @dfn{ReiserFS}, @dfn{JFS}, @dfn{XFS}, and @dfn{VSTa
  206. fs}. @xref{Filesystem}, for more information.
  207. @item Support automatic decompression
  208. Can decompress files which were compressed by @command{gzip}. This
  209. function is both automatic and transparent to the user (i.e. all
  210. functions operate upon the uncompressed contents of the specified
  211. files). This greatly reduces a file size and loading time, a
  212. particularly great benefit for floppies.@footnote{There are a few
  213. pathological cases where loading a very badly organized ELF kernel might
  214. take longer, but in practice this never happen.}
  215. It is conceivable that some kernel modules should be loaded in a
  216. compressed state, so a different module-loading command can be specified
  217. to avoid uncompressing the modules.
  218. @item Access data on any installed device
  219. Support reading data from any or all floppies or hard disk(s) recognized
  220. by the BIOS, independent of the setting of the root device.
  221. @item Be independent of drive geometry translations
  222. Unlike many other boot loaders, GRUB makes the particular drive
  223. translation irrelevant. A drive installed and running with one
  224. translation may be converted to another translation without any adverse
  225. effects or changes in GRUB's configuration.
  226. @item Detect all installed @sc{ram}
  227. GRUB can generally find all the installed @sc{ram} on a PC-compatible
  228. machine. It uses an advanced BIOS query technique for finding all
  229. memory regions. As described on the Multiboot Specification (@pxref{Top,
  230. Multiboot Specification, Motivation, multiboot, The Multiboot
  231. Specification}), not all kernels make use of this information, but GRUB
  232. provides it for those who do.
  233. @item Support Logical Block Address mode
  234. In traditional disk calls (called @dfn{CHS mode}), there is a geometry
  235. translation problem, that is, the BIOS cannot access over 1024
  236. cylinders, so the accessible space is limited to at least 508 MB and to
  237. at most 8GB. GRUB can't universally solve this problem, as there is no
  238. standard interface used in all machines. However, several newer machines
  239. have the new interface, Logical Block Address (@dfn{LBA}) mode. GRUB
  240. automatically detects if LBA mode is available and uses it if
  241. available. In LBA mode, GRUB can access the entire disk.
  242. @item Support network booting
  243. GRUB is basically a disk-based boot loader but also has network
  244. support. You can load OS images from a network by using the @dfn{TFTP}
  245. protocol.
  246. @item Support remote terminals
  247. To support computers with no console, GRUB provides remote terminal
  248. support, so that you can control GRUB from a remote host. Only serial
  249. terminal support is implemented at the moment.
  250. @end table
  251. @node Role of a boot loader
  252. @section The role of a boot loader
  253. The following is a quotation from Gordon Matzigkeit, a GRUB fanatic:
  254. @quotation
  255. Some people like to acknowledge both the operating system and kernel when
  256. they talk about their computers, so they might say they use
  257. ``GNU/Linux'' or ``GNU/Hurd''. Other people seem to think that the
  258. kernel is the most important part of the system, so they like to call
  259. their GNU operating systems ``Linux systems.''
  260. I, personally, believe that this is a grave injustice, because the
  261. @emph{boot loader} is the most important software of all. I used to
  262. refer to the above systems as either ``LILO''@footnote{The LInux LOader,
  263. a boot loader that everybody uses, but nobody likes.} or ``GRUB''
  264. systems.
  265. Unfortunately, nobody ever understood what I was talking about; now I
  266. just use the word ``GNU'' as a pseudonym for GRUB.
  267. So, if you ever hear people talking about their alleged ``GNU'' systems,
  268. remember that they are actually paying homage to the best boot loader
  269. around@dots{} GRUB!
  270. @end quotation
  271. We, the GRUB maintainers, do not (usually) encourage Gordon's level of
  272. fanaticism, but it helps to remember that boot loaders deserve
  273. recognition. We hope that you enjoy using GNU GRUB as much as we did
  274. writing it.
  275. @node Naming convention
  276. @chapter Naming convention
  277. The device syntax used in GRUB is a wee bit different from what you may
  278. have seen before in your operating system(s), and you need to know it so
  279. that you can specify a drive/partition.
  280. Look at the following examples and explanations:
  281. @example
  282. (fd0)
  283. @end example
  284. First of all, GRUB requires that the device name be enclosed with
  285. @samp{(} and @samp{)}. The @samp{fd} part means that it is a floppy
  286. disk. The number @samp{0} is the drive number, which is counted from
  287. @emph{zero}. This expression means that GRUB will use the whole floppy
  288. disk.
  289. @example
  290. (hd0,2)
  291. @end example
  292. Here, @samp{hd} means it is a hard disk drive. The first integer
  293. @samp{0} indicates the drive number, that is, the first hard disk, while
  294. the second integer, @samp{1}, indicates the partition number (or the
  295. @sc{pc} slice number in the BSD terminology). The partition numbers are
  296. counted from @emph{one}, not from zero (as was the case in previous
  297. versions of GRUB). This expression means the second partition of the
  298. first hard disk drive. In this case, GRUB uses one partition of the
  299. disk, instead of the whole disk.
  300. @example
  301. (hd0,5)
  302. @end example
  303. This specifies the first @dfn{extended partition} of the first hard disk
  304. drive. Note that the partition numbers for extended partitions are
  305. counted from @samp{5}, regardless of the actual number of primary
  306. partitions on your hard disk.
  307. @example
  308. (hd1,a)
  309. @end example
  310. This means the BSD @samp{a} partition of the second hard disk. If you
  311. need to specify which @sc{pc} slice number should be used, use something
  312. like this: @samp{(hd1,1,a)}. If the @sc{pc} slice number is omitted,
  313. GRUB searches for the first @sc{pc} slice which has a BSD @samp{a}
  314. partition.
  315. Of course, to actually access the disks or partitions with GRUB, you
  316. need to use the device specification in a command, like @samp{root
  317. (fd0)} or @samp{unhide (hd0,3)}. To help you find out which number
  318. specifies a partition you want, the GRUB command-line
  319. (@pxref{Command-line interface}) options have argument
  320. completion. This means that, for example, you only need to type
  321. @example
  322. root (
  323. @end example
  324. followed by a @key{TAB}, and GRUB will display the list of drives,
  325. partitions, or file names. So it should be quite easy to determine the
  326. name of your target partition, even with minimal knowledge of the
  327. syntax.
  328. Note that GRUB does @emph{not} distinguish IDE from SCSI - it simply
  329. counts the drive numbers from zero, regardless of their type. Normally,
  330. any IDE drive number is less than any SCSI drive number, although that
  331. is not true if you change the boot sequence by swapping IDE and SCSI
  332. drives in your BIOS.
  333. Now the question is, how to specify a file? Again, consider an
  334. example:
  335. @example
  336. (hd0,1)/vmlinuz
  337. @end example
  338. This specifies the file named @samp{vmlinuz}, found on the first
  339. partition of the first hard disk drive. Note that the argument
  340. completion works with file names, too.
  341. That was easy, admit it. Now read the next chapter, to find out how to
  342. actually install GRUB on your drive.
  343. @node Installation
  344. @chapter Installation
  345. In order to install GRUB as your boot loader, you need to first
  346. install the GRUB system and utilities under your UNIX-like operating
  347. system (@pxref{Obtaining and Building GRUB}). You can do this either
  348. from the source tarball, or as a package for your OS.
  349. After you have done that, you need to install the boot loader on a
  350. drive (floppy or hard disk). There are two ways of doing that - either
  351. using the utility @command{grub-install} (@pxref{Invoking
  352. grub-install}) on a UNIX-like OS, or by running GRUB itself from a
  353. floppy. These are quite similar, however the utility might probe a
  354. wrong BIOS drive, so you should be careful.
  355. Also, if you install GRUB on a UNIX-like OS, please make sure that you
  356. have an emergency boot disk ready, so that you can rescue your computer
  357. if, by any chance, your hard drive becomes unusable (unbootable).
  358. GRUB comes with boot images, which are normally put in the directory
  359. @file{/usr/lib/grub/i386-pc}. Hereafter, the directory where GRUB images are
  360. initially placed (normally @file{/usr/lib/grub/i386-pc}) will be
  361. called the @dfn{image directory}, and the directory where the boot
  362. loader needs to find them (usually @file{/boot/grub}) will be called
  363. the @dfn{boot directory}.
  364. @menu
  365. * Installing GRUB using grub-install::
  366. @end menu
  367. @node Installing GRUB using grub-install
  368. @section Installing GRUB using grub-install
  369. @strong{Caution:} This procedure is definitely less safe, because
  370. there are several ways in which your computer can become
  371. unbootable. For example, most operating systems don't tell GRUB how to
  372. map BIOS drives to OS devices correctly---GRUB merely @dfn{guesses}
  373. the mapping. This will succeed in most cases, but not
  374. always. Therefore, GRUB provides you with a map file called the
  375. @dfn{device map}, which you must fix if it is wrong. @xref{Device
  376. map}, for more details.
  377. If you still do want to install GRUB under a UNIX-like OS (such
  378. as @sc{gnu}), invoke the program @command{grub-install} (@pxref{Invoking
  379. grub-install}) as the superuser (@dfn{root}).
  380. The usage is basically very simple. You only need to specify one
  381. argument to the program, namely, where to install the boot loader. The
  382. argument can be either a device file (like @samp{/dev/hda}) or a
  383. partition specified in GRUB's notation. For example, under Linux the
  384. following will install GRUB into the MBR of the first IDE disk:
  385. @example
  386. # @kbd{grub-install /dev/hda}
  387. @end example
  388. Likewise, under GNU/Hurd, this has the same effect:
  389. @example
  390. # @kbd{grub-install /dev/hd0}
  391. @end example
  392. If it is the first BIOS drive, this is the same as well:
  393. @example
  394. # @kbd{grub-install '(hd0)'}
  395. @end example
  396. Or you can omit the parentheses:
  397. @example
  398. # @kbd{grub-install hd0}
  399. @end example
  400. But all the above examples assume that GRUB should use images under
  401. the root directory. If you want GRUB to use images under a directory
  402. other than the root directory, you need to specify the option
  403. @option{--root-directory}. The typical usage is that you create a GRUB
  404. boot floppy with a filesystem. Here is an example:
  405. @example
  406. @group
  407. # @kbd{mke2fs /dev/fd0}
  408. # @kbd{mount -t ext2 /dev/fd0 /mnt}
  409. # @kbd{grub-install --root-directory=/mnt fd0}
  410. # @kbd{umount /mnt}
  411. @end group
  412. @end example
  413. Another example is when you have a separate boot partition
  414. which is mounted at @file{/boot}. Since GRUB is a boot loader, it
  415. doesn't know anything about mountpoints at all. Thus, you need to run
  416. @command{grub-install} like this:
  417. @example
  418. # @kbd{grub-install --root-directory=/boot /dev/hda}
  419. @end example
  420. By the way, as noted above, it is quite difficult to guess BIOS drives
  421. correctly under a UNIX-like OS. Thus, @command{grub-install} will prompt
  422. you to check if it could really guess the correct mappings, after the
  423. installation. The format is defined in @ref{Device map}. Please be
  424. quite careful. If the output is wrong, it is unlikely that your
  425. computer will be able to boot with no problem.
  426. Note that @command{grub-install} is actually just a shell script and the
  427. real task is done by the grub shell @command{grub} (@pxref{Invoking the
  428. grub shell}). Therefore, you may run @command{grub} directly to install
  429. GRUB, without using @command{grub-install}. Don't do that, however,
  430. unless you are very familiar with the internals of GRUB. Installing a
  431. boot loader on a running OS may be extremely dangerous.
  432. @node Making a GRUB bootable CD-ROM
  433. @section Making a GRUB bootable CD-ROM
  434. GRUB supports the @dfn{no emulation mode} in the El Torito
  435. specification@footnote{El Torito is a specification for bootable CD
  436. using BIOS functions.}. This means that you can use the whole CD-ROM
  437. from GRUB and you don't have to make a floppy or hard disk image file,
  438. which can cause compatibility problems.
  439. For booting from a CD-ROM, GRUB uses a special Stage 2 called
  440. @file{stage2_eltorito}. The only GRUB files you need to have in your
  441. bootable CD-ROM are this @file{stage2_eltorito} and optionally a config file
  442. @file{grub.cfg}. You don't need to use @file{stage1} or @file{stage2},
  443. because El Torito is quite different from the standard boot process.
  444. Here is an example of procedures to make a bootable CD-ROM
  445. image. First, make a top directory for the bootable image, say,
  446. @samp{iso}:
  447. @example
  448. $ @kbd{mkdir iso}
  449. @end example
  450. Make a directory for GRUB:
  451. @example
  452. $ @kbd{mkdir -p iso/boot/grub}
  453. @end example
  454. Copy the file @file{stage2_eltorito}:
  455. @example
  456. $ @kbd{cp /usr/lib/grub/i386-pc/stage2_eltorito iso/boot/grub}
  457. @end example
  458. If desired, make the config file @file{grub.cfg} under @file{iso/boot/grub}
  459. (@pxref{Configuration}), and copy any files and directories for the disc to the
  460. directory @file{iso/}.
  461. Finally, make a ISO9660 image file like this:
  462. @example
  463. $ @kbd{mkisofs -R -b boot/grub/stage2_eltorito -no-emul-boot \
  464. -boot-load-size 4 -boot-info-table -o grub.iso iso}
  465. @end example
  466. This produces a file named @file{grub.iso}, which then can be burned
  467. into a CD (or a DVD). @kbd{mkisofs} has already set up the disc to boot
  468. from the @kbd{boot/grub/stage2_eltorito} file, so there is no need to
  469. setup GRUB on the disc. (Note that the @kbd{-boot-load-size 4} bit is
  470. required for compatibility with the BIOS on many older machines.)
  471. You can use the device @samp{(cd)} to access a CD-ROM in your
  472. config file. This is not required; GRUB automatically sets the root device
  473. to @samp{(cd)} when booted from a CD-ROM. It is only necessary to refer to
  474. @samp{(cd)} if you want to access other drives as well.
  475. @node Booting
  476. @chapter Booting
  477. GRUB can load Multiboot-compliant kernels in a consistent way,
  478. but for some free operating systems you need to use some OS-specific
  479. magic.
  480. @menu
  481. * General boot methods:: How to boot OSes with GRUB generally
  482. * OS-specific notes:: Notes on some operating systems
  483. @end menu
  484. @node General boot methods
  485. @section How to boot operating systems
  486. GRUB has two distinct boot methods. One of the two is to load an
  487. operating system directly, and the other is to chain-load another boot
  488. loader which then will load an operating system actually. Generally
  489. speaking, the former is more desirable, because you don't need to
  490. install or maintain other boot loaders and GRUB is flexible enough to
  491. load an operating system from an arbitrary disk/partition. However,
  492. the latter is sometimes required, since GRUB doesn't support all the
  493. existing operating systems natively.
  494. @menu
  495. * Loading an operating system directly::
  496. * Chain-loading::
  497. @end menu
  498. @node Loading an operating system directly
  499. @subsection How to boot an OS directly with GRUB
  500. Multiboot (@pxref{Top, Multiboot Specification, Motivation, multiboot,
  501. The Multiboot Specification}) is the native format supported by GRUB.
  502. For the sake of convenience, there is also support for Linux, FreeBSD,
  503. NetBSD and OpenBSD. If you want to boot other operating systems, you
  504. will have to chain-load them (@pxref{Chain-loading}).
  505. FIXME: this section is incomplete.
  506. @enumerate
  507. @item
  508. Run the command @command{boot} (@pxref{boot}).
  509. @end enumerate
  510. However, DOS and Windows have some deficiencies, so you might have to
  511. use more complicated instructions. @xref{DOS/Windows}, for more
  512. information.
  513. @node OS-specific notes
  514. @section Some caveats on OS-specific issues
  515. Here, we describe some caveats on several operating systems.
  516. @menu
  517. * GNU/Hurd::
  518. * GNU/Linux::
  519. @end menu
  520. @node GNU/Hurd
  521. @subsection GNU/Hurd
  522. Since GNU/Hurd is Multiboot-compliant, it is easy to boot it; there is
  523. nothing special about it. But do not forget that you have to specify a
  524. root partition to the kernel.
  525. FIXME: this section is incomplete.
  526. @enumerate
  527. @item
  528. Run the command @command{boot} (@pxref{boot}).
  529. @end enumerate
  530. @node GNU/Linux
  531. @subsection GNU/Linux
  532. It is relatively easy to boot GNU/Linux from GRUB, because it somewhat
  533. resembles to boot a Multiboot-compliant OS.
  534. FIXME: this section is incomplete.
  535. @enumerate
  536. @item
  537. Set GRUB's root device to the same drive as GNU/Linux's.
  538. @item
  539. Finally, run the command @command{boot} (@pxref{boot}).
  540. @end enumerate
  541. @strong{Caution:} If you use an initrd and specify the @samp{mem=}
  542. option to the kernel to let it use less than actual memory size, you
  543. will also have to specify the same memory size to GRUB. To let GRUB know
  544. the size, run the command @command{uppermem} @emph{before} loading the
  545. kernel. @xref{uppermem}, for more information.
  546. @node Serial terminal
  547. @chapter Using GRUB via a serial line
  548. This chapter describes how to use the serial terminal support in GRUB.
  549. If you have many computers or computers with no display/keyboard, it
  550. could be very useful to control the computers through serial
  551. communications. To connect one computer with another via a serial line,
  552. you need to prepare a null-modem (cross) serial cable, and you may need
  553. to have multiport serial boards, if your computer doesn't have extra
  554. serial ports. In addition, a terminal emulator is also required, such as
  555. minicom. Refer to a manual of your operating system, for more
  556. information.
  557. As for GRUB, the instruction to set up a serial terminal is quite
  558. simple. First of all, make sure that you haven't specified the option
  559. @option{--disable-serial} to the configure script when you built your
  560. GRUB images. If you get them in binary form, probably they have serial
  561. terminal support already.
  562. Then, initialize your serial terminal after GRUB starts up. Here is an
  563. example:
  564. @example
  565. @group
  566. grub> @kbd{serial --unit=0 --speed=9600}
  567. grub> @kbd{terminal serial}
  568. @end group
  569. @end example
  570. The command @command{serial} initializes the serial unit 0 with the
  571. speed 9600bps. The serial unit 0 is usually called @samp{COM1}, so, if
  572. you want to use COM2, you must specify @samp{--unit=1} instead. This
  573. command accepts many other options, so please refer to @ref{serial},
  574. for more details.
  575. The command @command{terminal} (@pxref{terminal}) chooses which type of
  576. terminal you want to use. In the case above, the terminal will be a
  577. serial terminal, but you can also pass @code{console} to the command,
  578. as @samp{terminal serial console}. In this case, a terminal in which
  579. you press any key will be selected as a GRUB terminal.
  580. However, note that GRUB assumes that your terminal emulator is
  581. compatible with VT100 by default. This is true for most terminal
  582. emulators nowadays, but you should pass the option @option{--dumb} to
  583. the command if your terminal emulator is not VT100-compatible or
  584. implements few VT100 escape sequences. If you specify this option then
  585. GRUB provides you with an alternative menu interface, because the normal
  586. menu requires several fancy features of your terminal.
  587. @node Filesystem
  588. @chapter Filesystem syntax and semantics
  589. GRUB uses a special syntax for specifying disk drives which can be
  590. accessed by BIOS. Because of BIOS limitations, GRUB cannot distinguish
  591. between IDE, ESDI, SCSI, or others. You must know yourself which BIOS
  592. device is equivalent to which OS device. Normally, that will be clear if
  593. you see the files in a device or use the command @command{find}
  594. (@pxref{find}).
  595. @menu
  596. * Device syntax:: How to specify devices
  597. * File name syntax:: How to specify files
  598. * Block list syntax:: How to specify block lists
  599. @end menu
  600. @node Device syntax
  601. @section How to specify devices
  602. The device syntax is like this:
  603. @example
  604. @code{(@var{device}[,@var{part-num}][,@var{bsd-subpart-letter}])}
  605. @end example
  606. @samp{[]} means the parameter is optional. @var{device} should be
  607. either @samp{fd} or @samp{hd} followed by a digit, like @samp{fd0}.
  608. But you can also set @var{device} to a hexadecimal or a decimal number
  609. which is a BIOS drive number, so the following are equivalent:
  610. @example
  611. (hd0)
  612. (0x80)
  613. (128)
  614. @end example
  615. @var{part-num} represents the partition number of @var{device}, starting
  616. from one for primary partitions and from five for extended partitions,
  617. and @var{bsd-subpart-letter} represents the BSD disklabel subpartition,
  618. such as @samp{a} or @samp{e}.
  619. A shortcut for specifying BSD subpartitions is
  620. @code{(@var{device},@var{bsd-subpart-letter})}, in this case, GRUB
  621. searches for the first PC partition containing a BSD disklabel, then
  622. finds the subpartition @var{bsd-subpart-letter}. Here is an example:
  623. @example
  624. (hd0,a)
  625. @end example
  626. The syntax @samp{(hd0)} represents using the entire disk (or the
  627. MBR when installing GRUB), while the syntax @samp{(hd0,1)}
  628. represents using the first partition of the disk (or the boot sector
  629. of the partition when installing GRUB).
  630. If you enabled the network support, the special drive, @samp{(nd)}, is
  631. also available. Before using the network drive, you must initialize the
  632. network. @xref{Network}, for more information.
  633. If you boot GRUB from a CD-ROM, @samp{(cd)} is available. @xref{Making
  634. a GRUB bootable CD-ROM}, for details.
  635. @node File name syntax
  636. @section How to specify files
  637. There are two ways to specify files, by @dfn{absolute file name} and by
  638. @dfn{block list}.
  639. An absolute file name resembles a Unix absolute file name, using
  640. @samp{/} for the directory separator (not @samp{\} as in DOS). One
  641. example is @samp{(hd0,1)/boot/grub/grub.cfg}. This means the file
  642. @file{/boot/grub/grub.cfg} in the first partition of the first hard
  643. disk. If you omit the device name in an absolute file name, GRUB uses
  644. GRUB's @dfn{root device} implicitly. So if you set the root device to,
  645. say, @samp{(hd1,1)} by the command @command{root} (@pxref{root}), then
  646. @code{/boot/kernel} is the same as @code{(hd1,1)/boot/kernel}.
  647. @node Block list syntax
  648. @section How to specify block lists
  649. A block list is used for specifying a file that doesn't appear in the
  650. filesystem, like a chainloader. The syntax is
  651. @code{[@var{offset}]+@var{length}[,[@var{offset}]+@var{length}]@dots{}}.
  652. Here is an example:
  653. @example
  654. @code{0+100,200+1,300+300}
  655. @end example
  656. This represents that GRUB should read blocks 0 through 99, block 200,
  657. and blocks 300 through 599. If you omit an offset, then GRUB assumes
  658. the offset is zero.
  659. Like the file name syntax (@pxref{File name syntax}), if a blocklist
  660. does not contain a device name, then GRUB uses GRUB's @dfn{root
  661. device}. So @code{(hd0,2)+1} is the same as @code{+1} when the root
  662. device is @samp{(hd0,2)}.
  663. @node Interface
  664. @chapter GRUB's user interface
  665. GRUB has both a simple menu interface for choosing preset entries from a
  666. configuration file, and a highly flexible command-line for performing
  667. any desired combination of boot commands.
  668. GRUB looks for its configuration file as soon as it is loaded. If one
  669. is found, then the full menu interface is activated using whatever
  670. entries were found in the file. If you choose the @dfn{command-line} menu
  671. option, or if the configuration file was not found, then GRUB drops to
  672. the command-line interface.
  673. @menu
  674. * Command-line interface:: The flexible command-line interface
  675. * Menu interface:: The simple menu interface
  676. @end menu
  677. @node Command-line interface
  678. @section The flexible command-line interface
  679. The command-line interface provides a prompt and after it an editable
  680. text area much like a command-line in Unix or DOS. Each command is
  681. immediately executed after it is entered@footnote{However, this
  682. behavior will be changed in the future version, in a user-invisible
  683. way.}. The commands (@pxref{Command-line and menu entry commands}) are a
  684. subset of those available in the configuration file, used with exactly
  685. the same syntax.
  686. Cursor movement and editing of the text on the line can be done via a
  687. subset of the functions available in the Bash shell:
  688. @table @key
  689. @item C-f
  690. @itemx PC right key
  691. Move forward one character.
  692. @item C-b
  693. @itemx PC left key
  694. Move back one character.
  695. @item C-a
  696. @itemx HOME
  697. Move to the start of the line.
  698. @item C-e
  699. @itemx END
  700. Move the the end of the line.
  701. @item C-d
  702. @itemx DEL
  703. Delete the character underneath the cursor.
  704. @item C-h
  705. @itemx BS
  706. Delete the character to the left of the cursor.
  707. @item C-k
  708. Kill the text from the current cursor position to the end of the line.
  709. @item C-u
  710. Kill backward from the cursor to the beginning of the line.
  711. @item C-y
  712. Yank the killed text back into the buffer at the cursor.
  713. @item C-p
  714. @itemx PC up key
  715. Move up through the history list.
  716. @item C-n
  717. @itemx PC down key
  718. Move down through the history list.
  719. @end table
  720. When typing commands interactively, if the cursor is within or before
  721. the first word in the command-line, pressing the @key{TAB} key (or
  722. @key{C-i}) will display a listing of the available commands, and if the
  723. cursor is after the first word, the @kbd{@key{TAB}} will provide a
  724. completion listing of disks, partitions, and file names depending on the
  725. context. Note that to obtain a list of drives, one must open a
  726. parenthesis, as @command{root (}.
  727. Note that you cannot use the completion functionality in the TFTP
  728. filesystem. This is because TFTP doesn't support file name listing for
  729. the security.
  730. @node Menu interface
  731. @section The simple menu interface
  732. The menu interface is quite easy to use. Its commands are both
  733. reasonably intuitive and described on screen.
  734. Basically, the menu interface provides a list of @dfn{boot entries} to
  735. the user to choose from. Use the arrow keys to select the entry of
  736. choice, then press @key{RET} to run it. An optional timeout is
  737. available to boot the default entry (the first one if not set), which is
  738. aborted by pressing any key.
  739. Commands are available to enter a bare command-line by pressing @key{c}
  740. (which operates exactly like the non-config-file version of GRUB, but
  741. allows one to return to the menu if desired by pressing @key{ESC}) or to
  742. edit any of the @dfn{boot entries} by pressing @key{e}.
  743. If you protect the menu interface with a password (@pxref{Security}),
  744. all you can do is choose an entry by pressing @key{RET}, or press
  745. @key{p} to enter the password.
  746. @node Menu entry editor
  747. @section Editing a menu entry
  748. The menu entry editor looks much like the main menu interface, but the
  749. lines in the menu are individual commands in the selected entry instead
  750. of entry names.
  751. If an @key{ESC} is pressed in the editor, it aborts all the changes made
  752. to the configuration entry and returns to the main menu interface.
  753. When a particular line is selected, the editor places the user in a
  754. special version of the GRUB command-line to edit that line. When the
  755. user hits @key{RET}, GRUB replaces the line in question in the boot
  756. entry with the changes (unless it was aborted via @key{ESC},
  757. in which case the changes are thrown away).
  758. If you want to add a new line to the menu entry, press @key{o} if adding
  759. a line after the current line or press @key{O} if before the current
  760. line.
  761. To delete a line, hit the key @key{d}. Although GRUB unfortunately
  762. does not support @dfn{undo}, you can do almost the same thing by just
  763. returning to the main menu.
  764. @node Commands
  765. @chapter The list of available commands
  766. In this chapter, we list all commands that are available in GRUB.
  767. Commands belong to different groups. A few can only be used in
  768. the global section of the configuration file (or ``menu''); most
  769. of them can be entered on the command-line and can be used either
  770. anywhere in the menu or specifically in the menu entries.
  771. @menu
  772. * Menu-specific commands::
  773. * General commands::
  774. * Command-line and menu entry commands::
  775. @end menu
  776. @node Menu-specific commands
  777. @section The list of commands for the menu only
  778. The semantics used in parsing the configuration file are the following:
  779. @itemize @bullet
  780. @item
  781. The menu-specific commands have to be used before any others.
  782. @item
  783. The files @emph{must} be in plain-text format.
  784. @item
  785. @samp{#} at the beginning of a line in a configuration file means it is
  786. only a comment.
  787. @item
  788. Options are separated by spaces.
  789. @item
  790. All numbers can be either decimal or hexadecimal. A hexadecimal number
  791. must be preceded by @samp{0x}, and is case-insensitive.
  792. @item
  793. Extra options or text at the end of the line are ignored unless otherwise
  794. specified.
  795. @item
  796. Unrecognized commands are added to the current entry, except before entries
  797. start, where they are ignored.
  798. @end itemize
  799. These commands can only be used in the menu:
  800. @menu
  801. * menuentry:: Start a menu entry
  802. @end menu
  803. @node menuentry
  804. @subsection menuentry
  805. @deffn Command title name @dots{}
  806. Start a new boot entry, and set its name to the contents of the rest of
  807. the line, starting with the first non-space character.
  808. @end deffn
  809. @node General commands
  810. @section The list of general commands
  811. Commands usable anywhere in the menu and in the command-line.
  812. @menu
  813. * serial:: Set up a serial device
  814. * terminfo:: Define escape sequences for a terminal
  815. @end menu
  816. @node serial
  817. @subsection serial
  818. @deffn Command serial [@option{--unit=unit}] [@option{--port=port}] [@option{--speed=speed}] [@option{--word=word}] [@option{--parity=parity}] [@option{--stop=stop}] [@option{--device=dev}]
  819. Initialize a serial device. @var{unit} is a number in the range 0-3
  820. specifying which serial port to use; default is 0, which corresponds to
  821. the port often called COM1. @var{port} is the I/O port where the UART
  822. is to be found; if specified it takes precedence over @var{unit}.
  823. @var{speed} is the transmission speed; default is 9600. @var{word} and
  824. @var{stop} are the number of data bits and stop bits. Data bits must
  825. be in the range 5-8 and stop bits must be 1 or 2. Default is 8 data
  826. bits and one stop bit. @var{parity} is one of @samp{no}, @samp{odd},
  827. @samp{even} and defaults to @samp{no}. The option @option{--device}
  828. can only be used in the grub shell and is used to specify the
  829. tty device to be used in the host operating system (@pxref{Invoking the
  830. grub shell}).
  831. The serial port is not used as a communication channel unless the
  832. @command{terminal} command is used (@pxref{terminal}).
  833. This command is only available if GRUB is compiled with serial
  834. support. See also @ref{Serial terminal}.
  835. @end deffn
  836. @node terminfo
  837. @subsection terminfo
  838. @deffn Command terminfo @option{--name=name} @option{--cursor-address=seq} [@option{--clear-screen=seq}] [@option{--enter-standout-mode=seq}] [@option{--exit-standout-mode=seq}]
  839. Define the capabilities of your terminal. Use this command to define
  840. escape sequences, if it is not vt100-compatible. You may use @samp{\e}
  841. for @key{ESC} and @samp{^X} for a control character.
  842. You can use the utility @command{grub-terminfo} to generate
  843. appropriate arguments to this command. @xref{Invoking grub-terminfo}.
  844. If no option is specified, the current settings are printed.
  845. @end deffn
  846. @node Command-line and menu entry commands
  847. @section The list of command-line and menu entry commands
  848. These commands are usable in the command-line and in menu entries. If
  849. you forget a command, you can run the command @command{help}
  850. (@pxref{help}).
  851. @menu
  852. * acpi:: Load ACPI tables
  853. * blocklist:: Print a block list
  854. * boot:: Start up your operating system
  855. * cat:: Show the contents of a file
  856. * chainloader:: Chain-load another boot loader
  857. * cmp:: Compare two files
  858. * configfile:: Load a configuration file
  859. * crc:: Calculate CRC32 checksums
  860. * date:: Display or set current date and time
  861. * echo:: Display a line of text
  862. * export:: Export an environment variable
  863. * halt:: Shut down your computer
  864. * help:: Show help messages
  865. * insmod:: Insert a module
  866. * keystatus:: Check key modifier status
  867. * ls:: List devices or files
  868. * play:: Play a tune
  869. * reboot:: Reboot your computer
  870. * set:: Set an environment variable
  871. * unset:: Unset an environment variable
  872. @end menu
  873. @node acpi
  874. @subsection acpi
  875. @deffn Command acpi [@option{-1}|@option{-2}] @
  876. [@option{--exclude=table1,@dots{}}|@option{--load-only=table1,@dots{}}] @
  877. [@option{--oemid=id}] [@option{--oemtable=table}] @
  878. [@option{--oemtablerev=rev}] [@option{--oemtablecreator=creator}] @
  879. [@option{--oemtablecreatorrev=rev}] [@option{--no-ebda}] @
  880. filename @dots{}
  881. Modern BIOS systems normally implement the Advanced Configuration and Power
  882. Interface (ACPI), and define various tables that describe the interface
  883. between an ACPI-compliant operating system and the firmware. In some cases,
  884. the tables provided by default only work well with certain operating
  885. systems, and it may be necessary to replace some of them.
  886. Normally, this command will replace the Root System Description Pointer
  887. (RSDP) in the Extended BIOS Data Area to point to the new tables. If the
  888. @option{--no-ebda} option is used, the new tables will be known only to
  889. GRUB, but may be used by GRUB's EFI emulation.
  890. @end deffn
  891. @node blocklist
  892. @subsection blocklist
  893. @deffn Command blocklist file
  894. Print a block list (@pxref{Block list syntax}) for @var{file}.
  895. @end deffn
  896. @node boot
  897. @subsection boot
  898. @deffn Command boot
  899. Boot the OS or chain-loader which has been loaded. Only necessary if
  900. running the fully interactive command-line (it is implicit at the end of
  901. a menu entry).
  902. @end deffn
  903. @node cat
  904. @subsection cat
  905. @deffn Command cat file
  906. Display the contents of the file @var{file}. This command may be useful
  907. to remind you of your OS's root partition:
  908. @example
  909. grub> @kbd{cat /etc/fstab}
  910. @end example
  911. @end deffn
  912. @node chainloader
  913. @subsection chainloader
  914. @deffn Command chainloader [@option{--force}] file
  915. Load @var{file} as a chain-loader. Like any other file loaded by the
  916. filesystem code, it can use the blocklist notation to grab the first
  917. sector of the current partition with @samp{+1}. If you specify the
  918. option @option{--force}, then load @var{file} forcibly, whether it has a
  919. correct signature or not. This is required when you want to load a
  920. defective boot loader, such as SCO UnixWare 7.1 (@pxref{SCO UnixWare}).
  921. @end deffn
  922. @node cmp
  923. @subsection cmp
  924. @deffn Command cmp file1 file2
  925. Compare the file @var{file1} with the file @var{file2}. If they differ
  926. in size, print the sizes like this:
  927. @example
  928. Differ in size: 0x1234 [foo], 0x4321 [bar]
  929. @end example
  930. If the sizes are equal but the bytes at an offset differ, then print the
  931. bytes like this:
  932. @example
  933. Differ at the offset 777: 0xbe [foo], 0xef [bar]
  934. @end example
  935. If they are completely identical, nothing will be printed.
  936. @end deffn
  937. @node configfile
  938. @subsection configfile
  939. @deffn Command configfile file
  940. Load @var{file} as a configuration file.
  941. @end deffn
  942. @node crc
  943. @subsection crc
  944. @deffn Command crc file
  945. Display the CRC32 checksum of @var{file}.
  946. @end deffn
  947. @node date
  948. @subsection date
  949. @deffn Command date [[year-]month-day] [hour:minute[:second]]
  950. With no arguments, print the current date and time.
  951. Otherwise, take the current date and time, change any elements specified as
  952. arguments, and set the result as the new date and time. For example, `date
  953. 01-01' will set the current month and day to January 1, but leave the year,
  954. hour, minute, and second unchanged.
  955. @end deffn
  956. @node echo
  957. @subsection echo
  958. @deffn Command echo [@option{-n}] [@option{-e}] string @dots{}
  959. Display the requested text and, unless the @option{-n} option is used, a
  960. trailing new line. If there is more than one string, they are separated by
  961. spaces in the output. As usual in GRUB commands, variables may be
  962. substituted using @samp{$@{var@}}.
  963. The @option{-e} option enables interpretation of backslash escapes. The
  964. following sequences are recognised:
  965. @table @code
  966. @item \\
  967. backslash
  968. @item \a
  969. alert (BEL)
  970. @item \c
  971. suppress trailing new line
  972. @item \f
  973. form feed
  974. @item \n
  975. new line
  976. @item \r
  977. carriage return
  978. @item \t
  979. horizontal tab
  980. @item \v
  981. vertical tab
  982. @end table
  983. When interpreting backslash escapes, backslash followed by any other
  984. character will print that character.
  985. @end deffn
  986. @node export
  987. @subsection export
  988. @deffn Command export envvar
  989. Export the environment variable @var{envvar}. Exported variables are visible
  990. to subsidiary configuration files loaded using @command{configfile}.
  991. @end deffn
  992. @node halt
  993. @subsection halt
  994. @deffn Command halt @option{--no-apm}
  995. The command halts the computer. If the @option{--no-apm} option
  996. is specified, no APM BIOS call is performed. Otherwise, the computer
  997. is shut down using APM.
  998. @end deffn
  999. @node help
  1000. @subsection help
  1001. @deffn Command help @option{--all} [pattern @dots{}]
  1002. Display helpful information about builtin commands. If you do not
  1003. specify @var{pattern}, this command shows short descriptions of most of
  1004. available commands. If you specify the option @option{--all} to this
  1005. command, short descriptions of rarely used commands (such as
  1006. @ref{testload}) are displayed as well.
  1007. If you specify any @var{patterns}, it displays longer information
  1008. about each of the commands which match those @var{patterns}.
  1009. @end deffn
  1010. @node insmod
  1011. @subsection insmod
  1012. @deffn Command insmod module
  1013. Insert the dynamic GRUB module called @var{module}.
  1014. @end deffn
  1015. @node keystatus
  1016. @subsection keystatus
  1017. @deffn Command keystatus [@option{--shift}] [@option{--ctrl}] [@option{--alt}]
  1018. Return true if the Shift, Control, or Alt modifier keys are held down, as
  1019. requested by options. This is useful in scripting, to allow some user
  1020. control over behaviour without having to wait for a keypress.
  1021. Checking key modifier status is only supported on some platforms. If invoked
  1022. without any options, the @command{keystatus} command returns true if and
  1023. only if checking key modifier status is supported.
  1024. @end deffn
  1025. @node ls
  1026. @subsection ls
  1027. @deffn Command ls [arg]
  1028. List devices or files.
  1029. With no arguments, print all devices known to GRUB.
  1030. If the argument is a device name enclosed in parentheses (@pxref{Device
  1031. syntax}), then list all files at the root directory of that device.
  1032. If the argument is a directory given as an absolute file name (@pxref{File
  1033. name syntax}), then list the contents of that directory.
  1034. @end deffn
  1035. @node play
  1036. @subsection play
  1037. @deffn Command play file | tempo [pitch1 duration1] [pitch2 duration2] ...
  1038. Plays a tune
  1039. If the argument is a file name (@pxref{File name syntax}), play the tune
  1040. recorded in it. The file format is first the tempo as an unsigned 32bit
  1041. little-endian number, then pairs of unsigned 16bit little-endian numbers for
  1042. pitch and duration pairs.
  1043. If the arguments are a series of numbers, play the inline tune.
  1044. The tempo is the base for all note durations. 60 gives a 1-second base, 120
  1045. gives a half-second base, etc. Pitches are Hz. Set pitch to 0 to produce
  1046. a rest.
  1047. @end deffn
  1048. @node reboot
  1049. @subsection reboot
  1050. @deffn Command reboot
  1051. Reboot the computer.
  1052. @end deffn
  1053. @node set
  1054. @subsection set
  1055. @deffn Command set [envvar=value]
  1056. Set the environment variable @var{envvar} to @var{value}. If invoked with no
  1057. arguments, print all environment variables with their values.
  1058. @end deffn
  1059. @node unset
  1060. @subsection unset
  1061. @deffn Command unset envvar
  1062. Unset the environment variable @var{envvar}.
  1063. @end deffn
  1064. @node Invoking grub-install
  1065. @chapter Invoking grub-install
  1066. The program @command{grub-install} installs GRUB on your drive using the
  1067. grub shell (@pxref{Invoking the grub shell}). You must specify the
  1068. device name on which you want to install GRUB, like this:
  1069. @example
  1070. grub-install @var{install_device}
  1071. @end example
  1072. The device name @var{install_device} is an OS device name or a GRUB
  1073. device name.
  1074. @command{grub-install} accepts the following options:
  1075. @table @option
  1076. @item --help
  1077. Print a summary of the command-line options and exit.
  1078. @item --version
  1079. Print the version number of GRUB and exit.
  1080. @item --root-directory=@var{dir}
  1081. Install GRUB images under the directory @var{dir} instead of the root
  1082. directory. This option is useful when you want to install GRUB into a
  1083. separate partition or a removable disk. Here is an example in which
  1084. you have a separate @dfn{boot} partition which is mounted on
  1085. @file{/boot}:
  1086. @example
  1087. @kbd{grub-install --root-directory=/boot hd0}
  1088. @end example
  1089. @item --recheck
  1090. Recheck the device map, even if @file{/boot/grub/device.map} already
  1091. exists. You should use this option whenever you add/remove a disk
  1092. into/from your computer.
  1093. @end table
  1094. @node Obtaining and Building GRUB
  1095. @appendix How to obtain and build GRUB
  1096. @quotation
  1097. @strong{Caution:} GRUB requires binutils-2.9.1.0.23 or later because the
  1098. GNU assembler has been changed so that it can produce real 16bits
  1099. machine code between 2.9.1 and 2.9.1.0.x. See
  1100. @uref{http://sources.redhat.com/binutils/}, to obtain information on
  1101. how to get the latest version.
  1102. @end quotation
  1103. GRUB is available from the GNU alpha archive site
  1104. @uref{ftp://alpha.gnu.org/gnu/grub} or any of its mirrors. The file
  1105. will be named grub-version.tar.gz. The current version is
  1106. @value{VERSION}, so the file you should grab is:
  1107. @uref{ftp://alpha.gnu.org/gnu/grub/grub-@value{VERSION}.tar.gz}
  1108. To unbundle GRUB use the instruction:
  1109. @example
  1110. @kbd{zcat grub-@value{VERSION}.tar.gz | tar xvf -}
  1111. @end example
  1112. which will create a directory called @file{grub-@value{VERSION}} with
  1113. all the sources. You can look at the file @file{INSTALL} for detailed
  1114. instructions on how to build and install GRUB, but you should be able to
  1115. just do:
  1116. @example
  1117. @group
  1118. @kbd{cd grub-@value{VERSION}}
  1119. @kbd{./configure}
  1120. @kbd{make install}
  1121. @end group
  1122. @end example
  1123. Also, the latest version is available from the SVN. See
  1124. @uref{http://savannah.gnu.org/svn/?group=grub} for more information.
  1125. @node Reporting bugs
  1126. @appendix Reporting bugs
  1127. These are the guideline for how to report bugs. Take a look at this
  1128. list below before you submit bugs:
  1129. @enumerate
  1130. @item
  1131. Before getting unsettled, read this manual through and through. Also,
  1132. see the @uref{http://www.gnu.org/software/grub/grub-faq.html, GNU GRUB FAQ}.
  1133. @item
  1134. Always mention the information on your GRUB. The version number and the
  1135. configuration are quite important. If you build it yourself, write the
  1136. options specified to the configure script and your operating system,
  1137. including the versions of gcc and binutils.
  1138. @item
  1139. If you have trouble with the installation, inform us of how you
  1140. installed GRUB. Don't omit error messages, if any. Just @samp{GRUB hangs
  1141. up when it boots} is not enough.
  1142. The information on your hardware is also essential. These are especially
  1143. important: the geometries and the partition tables of your hard disk
  1144. drives and your BIOS.
  1145. @item
  1146. If GRUB cannot boot your operating system, write down
  1147. @emph{everything} you see on the screen. Don't paraphrase them, like
  1148. @samp{The foo OS crashes with GRUB, even though it can boot with the
  1149. bar boot loader just fine}. Mention the commands you executed, the
  1150. messages printed by them, and information on your operating system
  1151. including the version number.
  1152. @item
  1153. Explain what you wanted to do. It is very useful to know your purpose
  1154. and your wish, and how GRUB didn't satisfy you.
  1155. @item
  1156. If you can investigate the problem yourself, please do. That will give
  1157. you and us much more information on the problem. Attaching a patch is
  1158. even better.
  1159. When you attach a patch, make the patch in unified diff format, and
  1160. write ChangeLog entries. But, even when you make a patch, don't forget
  1161. to explain the problem, so that we can understand what your patch is
  1162. for.
  1163. @item
  1164. Write down anything that you think might be related. Please understand
  1165. that we often need to reproduce the same problem you encounterred in our
  1166. environment. So your information should be sufficient for us to do the
  1167. same thing---Don't forget that we cannot see your computer directly. If
  1168. you are not sure whether to state a fact or leave it out, state it!
  1169. Reporting too many things is much better than omitting something
  1170. important.
  1171. @end enumerate
  1172. If you follow the guideline above, submit a report to the
  1173. @uref{http://savannah.gnu.org/bugs/?group=grub, Bug Tracking System}.
  1174. Alternatively, you can submit a report via electronic mail to
  1175. @email{bug-grub@@gnu.org}, but we strongly recommend that you use the
  1176. Bug Tracking System, because e-mail can be passed over easily.
  1177. Once we get your report, we will try to fix the bugs.
  1178. @node Future
  1179. @appendix Where GRUB will go
  1180. We started the next generation of GRUB, GRUB 2. GRUB 2 includes
  1181. internationalization, dynamic module loading, real memory management,
  1182. multiple architecture support, a scripting language, and many other
  1183. nice feature. If you are interested in the development of GRUB 2, take
  1184. a look at @uref{http://www.gnu.org/software/grub/grub.html, the
  1185. homepage}.
  1186. @node Copying This Manual
  1187. @appendix Copying This Manual
  1188. @menu
  1189. * GNU Free Documentation License:: License for copying this manual.
  1190. @end menu
  1191. @include fdl.texi
  1192. @node Index
  1193. @unnumbered Index
  1194. @c Currently, we use only the Concept Index.
  1195. @printindex cp
  1196. @bye
  1197. Some notes:
  1198. This is an attempt to make a manual for GRUB 2. The contents are
  1199. copied from the GRUB manual in GRUB Legacy, so they are not always
  1200. appropriate yet for GRUB 2.