grub.xml 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306
  1. <?xml version="1.0" encoding="ISO-8859-1"?>
  2. <!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
  3. "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
  4. <!ENTITY % general-entities SYSTEM "../general.ent">
  5. %general-entities;
  6. ]>
  7. <sect1 id="ch-bootable-grub" role="wrap">
  8. <?dbhtml filename="grub.html"?>
  9. <sect1info condition="script">
  10. <productname>grub</productname>
  11. <productnumber>&grub-version;</productnumber>
  12. <address>&grub-url;</address>
  13. </sect1info>
  14. <title>GRUB-&grub-version;</title>
  15. <indexterm zone="ch-bootable-grub">
  16. <primary sortas="a-Grub">GRUB</primary>
  17. </indexterm>
  18. <sect2 role="package">
  19. <title/>
  20. <para>The GRUB package contains the GRand Unified Bootloader.</para>
  21. <segmentedlist>
  22. <segtitle>&buildtime;</segtitle>
  23. <segtitle>&diskspace;</segtitle>
  24. <seglistitem>
  25. <seg>&grub-ch6-sbu;</seg>
  26. <seg>&grub-ch6-du;</seg>
  27. </seglistitem>
  28. </segmentedlist>
  29. </sect2>
  30. <sect2 role="installation">
  31. <title>Installation of GRUB</title>
  32. <para>Your shiny new LFS system is almost complete. One of the last
  33. things to do is to ensure that the system can be properly booted.</para>
  34. <caution>
  35. <para>This package will only build for x86 and x86_64 architectures
  36. containing 32-bit libs. If you chose to build on x86_64 without 32-bit
  37. libraries (no multilib), then you must use LILO instead. Information on
  38. <quote>boot loading</quote> for other architectures should be available in
  39. the usual resource-specific locations for those architectures.</para>
  40. </caution>
  41. <para>This package is known to have issues when its default
  42. optimization flags (including the <parameter>-march</parameter> and
  43. <parameter>-mcpu</parameter> options) are changed. If any environment
  44. variables that override default optimizations have been defined, such
  45. as <envar>CFLAGS</envar> and <envar>CXXFLAGS</envar>,
  46. unset them when building GRUB.</para>
  47. <para>Start by applying the following patch to allow for better drive
  48. detection, fix some GCC 4.x issues, and provide better SATA support
  49. for some disk controllers:</para>
  50. <screen><userinput remap="pre">patch -Np1 -i ../&grub-geometry-patch;</userinput></screen>
  51. <para>By default, GRUB doesn't support ext2 filesystems with 256-byte inodes.
  52. Fix this by applying the following patch:</para>
  53. <screen><userinput remap="pre">patch -Np1 -i ../&grub-inode-patch;</userinput></screen>
  54. <para>Prepare GRUB for compilation:</para>
  55. <screen><userinput remap="configure">./configure --prefix=/usr</userinput></screen>
  56. <para>Compile the package, but use custom optimization flags to
  57. prevent an error flagged in the test routines:</para>
  58. <screen><userinput remap="make">make CFLAGS="-march=i486 -mtune=native -Os"</userinput></screen>
  59. <para>To test the results, issue:</para>
  60. <screen><userinput remap="test">make check</userinput></screen>
  61. <para>Install the package:</para>
  62. <screen><userinput remap="install">make install
  63. mkdir -v /boot/grub
  64. cp -v /usr/lib/grub/i386-pc/stage{1,2} /boot/grub</userinput></screen>
  65. <para>Replace <filename class="directory">i386-pc</filename> with whatever
  66. directory is appropriate for the hardware in use.</para>
  67. <para>The <filename class="directory">i386-pc</filename> directory
  68. contains a number of <filename>*stage1_5</filename> files, different
  69. ones for different file systems. Review the files available and copy
  70. the appropriate ones to the <filename
  71. class="directory">/boot/grub</filename> directory. Most users will
  72. copy the <filename>e2fs_stage1_5</filename> and/or
  73. <filename>reiserfs_stage1_5</filename> files.</para>
  74. </sect2>
  75. <sect2 role="configuration">
  76. <title>Configuring GRUB</title>
  77. <para>Boot loading can be a complex area, so a few cautionary
  78. words are in order. Be familiar with the current boot loader and any other
  79. operating systems present on the hard drive(s) that need to be
  80. bootable. Make sure that an emergency boot disk is ready to
  81. <quote>rescue</quote> the computer if the computer becomes
  82. unusable (un-bootable).</para>
  83. <para>The procedure involves writing some special GRUB files to specific
  84. locations on the hard drive. We highly recommend creating a GRUB boot floppy
  85. diskette as a backup. Insert a blank floppy diskette and run the following
  86. commands:</para>
  87. <screen><userinput>dd if=/boot/grub/stage1 of=/dev/fd0 bs=512 count=1
  88. dd if=/boot/grub/stage2 of=/dev/fd0 bs=512 seek=1</userinput></screen>
  89. <para>Remove the diskette and store it somewhere safe. Now, run the
  90. <command>grub</command> shell:</para>
  91. <screen><userinput>grub</userinput></screen>
  92. <para>GRUB uses its own naming structure for drives and partitions in
  93. the form of <emphasis>(hdn,m)</emphasis>, where <emphasis>n</emphasis>
  94. is the hard drive number and <emphasis>m</emphasis> is the partition
  95. number, both starting from zero. For example, partition <filename
  96. class="partition">hda1</filename> is <emphasis>(hd0,0)</emphasis> to
  97. GRUB and <filename class="partition">hdb3</filename> is
  98. <emphasis>(hd1,2)</emphasis>. In contrast to Linux, GRUB does not
  99. consider CD-ROM drives to be hard drives. For example, if using a CD
  100. on <filename class="partition">hdb</filename> and a second hard drive
  101. on <filename class="partition">hdc</filename>, that second hard drive
  102. would still be <emphasis>(hd1)</emphasis>.</para>
  103. <para>Using the above information, determine the appropriate
  104. designator for the root partition (or boot partition, if a separate
  105. one is used). For the following example, it is assumed that the root
  106. (or separate boot) partition is <filename
  107. class="partition">hda4</filename>.</para>
  108. <para>Tell GRUB where to search for its
  109. <filename>stage{1,2}</filename> files. The Tab key can be used
  110. everywhere to make GRUB show the alternatives:</para>
  111. <screen><userinput>root (hd0,3)</userinput></screen>
  112. <warning>
  113. <para>The following command will overwrite the current boot loader. Do not
  114. run the command if this is not desired, for example, if using a third party
  115. boot manager to manage the Master Boot Record (MBR). In this scenario, it
  116. would make more sense to install GRUB into the <quote>boot sector</quote>
  117. of the LFS partition. In this case, this next command would become
  118. <userinput>setup (hd0,3)</userinput>.</para>
  119. </warning>
  120. <para>Tell GRUB to install itself into the MBR of
  121. <filename class="partition">hda</filename>:</para>
  122. <screen><userinput>setup (hd0)</userinput></screen>
  123. <para>If all went well, GRUB will have reported finding its files in
  124. <filename class="directory">/boot/grub</filename>. That's all there is
  125. to it. Quit the <command>grub</command> shell:</para>
  126. <screen><userinput>quit</userinput></screen>
  127. <para>Create a <quote>menu list</quote> file defining GRUB's boot menu:</para>
  128. <screen><userinput>cat &gt; /boot/grub/menu.lst &lt;&lt; "EOF"
  129. <literal># Begin /boot/grub/menu.lst
  130. # By default boot the first menu entry.
  131. default 0
  132. # Allow 30 seconds before booting the default.
  133. timeout 30
  134. # Use prettier colors.
  135. color green/black light-green/black
  136. # The first entry is for LFS.
  137. title LFS &version;
  138. root (hd0,3)
  139. kernel /boot/lfskernel-&linux-version; root=/dev/hda4</literal>
  140. EOF</userinput></screen>
  141. <para>Add an entry for the host distribution if desired. It might look
  142. like this:</para>
  143. <screen><userinput>cat &gt;&gt; /boot/grub/menu.lst &lt;&lt; "EOF"
  144. <literal>title Red Hat
  145. root (hd0,2)
  146. kernel /boot/kernel-2.6.5 root=/dev/hda3
  147. initrd /boot/initrd-2.6.5</literal>
  148. EOF</userinput></screen>
  149. <para>If dual-booting Windows, the following entry will allow
  150. booting it:</para>
  151. <screen><userinput>cat &gt;&gt; /boot/grub/menu.lst &lt;&lt; "EOF"
  152. <literal>title Windows
  153. rootnoverify (hd0,0)
  154. chainloader +1</literal>
  155. EOF</userinput></screen>
  156. <para>If <command>info grub</command> does not provide all necessary material,
  157. additional information regarding GRUB is located on its website at:
  158. <ulink url="http://www.gnu.org/software/grub/"/>.</para>
  159. <para>The FHS stipulates that GRUB's <filename>menu.lst</filename> file should
  160. be symlinked to <filename class="symlink">/etc/grub/menu.lst</filename>. To
  161. satisfy this requirement, issue the following command:</para>
  162. <screen><userinput>mkdir -v /etc/grub
  163. ln -sv /boot/grub/menu.lst /etc/grub</userinput></screen>
  164. </sect2>
  165. <sect2 id="contents-gRUB" role="content">
  166. <title>Contents of GRUB</title>
  167. <segmentedlist>
  168. <segtitle>Installed programs</segtitle>
  169. <seglistitem>
  170. <seg>grub, grub-install, grub-md5-crypt, grub-set-default,
  171. grub-terminfo, and mbchk</seg>
  172. </seglistitem>
  173. </segmentedlist>
  174. <variablelist>
  175. <bridgehead renderas="sect3">Short Descriptions</bridgehead>
  176. <?dbfo list-presentation="list"?>
  177. <?dbhtml list-presentation="table"?>
  178. <varlistentry id="grub">
  179. <term><command>grub</command></term>
  180. <listitem>
  181. <para>The Grand Unified Bootloader's command shell</para>
  182. <indexterm zone="ch-bootable-grub grub">
  183. <primary sortas="b-grub">grub</primary>
  184. </indexterm>
  185. </listitem>
  186. </varlistentry>
  187. <varlistentry id="grub-install">
  188. <term><command>grub-install</command></term>
  189. <listitem>
  190. <para>Installs GRUB on the given device</para>
  191. <indexterm zone="ch-bootable-grub grub-install">
  192. <primary sortas="b-grub-install">grub-install</primary>
  193. </indexterm>
  194. </listitem>
  195. </varlistentry>
  196. <varlistentry id="grub-md5-crypt">
  197. <term><command>grub-md5-crypt</command></term>
  198. <listitem>
  199. <para>Encrypts a password in MD5 format</para>
  200. <indexterm zone="ch-bootable-grub grub-md5-crypt">
  201. <primary sortas="b-grub-md5-crypt">grub-md5-crypt</primary>
  202. </indexterm>
  203. </listitem>
  204. </varlistentry>
  205. <varlistentry id="grub-set-default">
  206. <term><command>grub-set-default</command></term>
  207. <listitem>
  208. <para>Sets the default boot entry for GRUB</para>
  209. <indexterm zone="ch-bootable-grub grub-set-default">
  210. <primary sortas="b-grub-set-default">grub-set-default</primary>
  211. </indexterm>
  212. </listitem>
  213. </varlistentry>
  214. <varlistentry id="grub-terminfo">
  215. <term><command>grub-terminfo</command></term>
  216. <listitem>
  217. <para>Generates a terminfo command from a terminfo name; it can be
  218. employed if an unknown terminal is being used</para>
  219. <indexterm zone="ch-bootable-grub grub-terminfo">
  220. <primary sortas="b-grub-terminfo">grub-terminfo</primary>
  221. </indexterm>
  222. </listitem>
  223. </varlistentry>
  224. <varlistentry id="mbchk">
  225. <term><command>mbchk</command></term>
  226. <listitem>
  227. <para>Checks the format of a multi-boot kernel</para>
  228. <indexterm zone="ch-bootable-grub mbchk">
  229. <primary sortas="b-mbchk">mbchk</primary>
  230. </indexterm>
  231. </listitem>
  232. </varlistentry>
  233. </variablelist>
  234. </sect2>
  235. </sect1>