grub.xml 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305
  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:</para>
  57. <screen><userinput remap="make">make</userinput></screen>
  58. <para>To test the results, issue:</para>
  59. <screen><userinput remap="test">make check</userinput></screen>
  60. <para>Install the package:</para>
  61. <screen><userinput remap="install">make install
  62. mkdir -v /boot/grub
  63. cp -v /usr/lib/grub/i386-pc/stage{1,2} /boot/grub</userinput></screen>
  64. <para>Replace <filename class="directory">i386-pc</filename> with whatever
  65. directory is appropriate for the hardware in use.</para>
  66. <para>The <filename class="directory">i386-pc</filename> directory
  67. contains a number of <filename>*stage1_5</filename> files, different
  68. ones for different file systems. Review the files available and copy
  69. the appropriate ones to the <filename
  70. class="directory">/boot/grub</filename> directory. Most users will
  71. copy the <filename>e2fs_stage1_5</filename> and/or
  72. <filename>reiserfs_stage1_5</filename> files.</para>
  73. </sect2>
  74. <sect2 role="configuration">
  75. <title>Configuring GRUB</title>
  76. <para>Boot loading can be a complex area, so a few cautionary
  77. words are in order. Be familiar with the current boot loader and any other
  78. operating systems present on the hard drive(s) that need to be
  79. bootable. Make sure that an emergency boot disk is ready to
  80. <quote>rescue</quote> the computer if the computer becomes
  81. unusable (un-bootable).</para>
  82. <para>The procedure involves writing some special GRUB files to specific
  83. locations on the hard drive. We highly recommend creating a GRUB boot floppy
  84. diskette as a backup. Insert a blank floppy diskette and run the following
  85. commands:</para>
  86. <screen><userinput>dd if=/boot/grub/stage1 of=/dev/fd0 bs=512 count=1
  87. dd if=/boot/grub/stage2 of=/dev/fd0 bs=512 seek=1</userinput></screen>
  88. <para>Remove the diskette and store it somewhere safe. Now, run the
  89. <command>grub</command> shell:</para>
  90. <screen><userinput>grub</userinput></screen>
  91. <para>GRUB uses its own naming structure for drives and partitions in
  92. the form of <emphasis>(hdn,m)</emphasis>, where <emphasis>n</emphasis>
  93. is the hard drive number and <emphasis>m</emphasis> is the partition
  94. number, both starting from zero. For example, partition <filename
  95. class="partition">hda1</filename> is <emphasis>(hd0,0)</emphasis> to
  96. GRUB and <filename class="partition">hdb3</filename> is
  97. <emphasis>(hd1,2)</emphasis>. In contrast to Linux, GRUB does not
  98. consider CD-ROM drives to be hard drives. For example, if using a CD
  99. on <filename class="partition">hdb</filename> and a second hard drive
  100. on <filename class="partition">hdc</filename>, that second hard drive
  101. would still be <emphasis>(hd1)</emphasis>.</para>
  102. <para>Using the above information, determine the appropriate
  103. designator for the root partition (or boot partition, if a separate
  104. one is used). For the following example, it is assumed that the root
  105. (or separate boot) partition is <filename
  106. class="partition">hda4</filename>.</para>
  107. <para>Tell GRUB where to search for its
  108. <filename>stage{1,2}</filename> files. The Tab key can be used
  109. everywhere to make GRUB show the alternatives:</para>
  110. <screen><userinput>root (hd0,3)</userinput></screen>
  111. <warning>
  112. <para>The following command will overwrite the current boot loader. Do not
  113. run the command if this is not desired, for example, if using a third party
  114. boot manager to manage the Master Boot Record (MBR). In this scenario, it
  115. would make more sense to install GRUB into the <quote>boot sector</quote>
  116. of the LFS partition. In this case, this next command would become
  117. <userinput>setup (hd0,3)</userinput>.</para>
  118. </warning>
  119. <para>Tell GRUB to install itself into the MBR of
  120. <filename class="partition">hda</filename>:</para>
  121. <screen><userinput>setup (hd0)</userinput></screen>
  122. <para>If all went well, GRUB will have reported finding its files in
  123. <filename class="directory">/boot/grub</filename>. That's all there is
  124. to it. Quit the <command>grub</command> shell:</para>
  125. <screen><userinput>quit</userinput></screen>
  126. <para>Create a <quote>menu list</quote> file defining GRUB's boot menu:</para>
  127. <screen><userinput>cat &gt; /boot/grub/menu.lst &lt;&lt; "EOF"
  128. <literal># Begin /boot/grub/menu.lst
  129. # By default boot the first menu entry.
  130. default 0
  131. # Allow 30 seconds before booting the default.
  132. timeout 30
  133. # Use prettier colors.
  134. color green/black light-green/black
  135. # The first entry is for LFS.
  136. title LFS &version;
  137. root (hd0,3)
  138. kernel /boot/lfskernel-&linux-version; root=/dev/hda4</literal>
  139. EOF</userinput></screen>
  140. <para>Add an entry for the host distribution if desired. It might look
  141. like this:</para>
  142. <screen><userinput>cat &gt;&gt; /boot/grub/menu.lst &lt;&lt; "EOF"
  143. <literal>title Red Hat
  144. root (hd0,2)
  145. kernel /boot/kernel-2.6.5 root=/dev/hda3
  146. initrd /boot/initrd-2.6.5</literal>
  147. EOF</userinput></screen>
  148. <para>If dual-booting Windows, the following entry will allow
  149. booting it:</para>
  150. <screen><userinput>cat &gt;&gt; /boot/grub/menu.lst &lt;&lt; "EOF"
  151. <literal>title Windows
  152. rootnoverify (hd0,0)
  153. chainloader +1</literal>
  154. EOF</userinput></screen>
  155. <para>If <command>info grub</command> does not provide all necessary material,
  156. additional information regarding GRUB is located on its website at:
  157. <ulink url="http://www.gnu.org/software/grub/"/>.</para>
  158. <para>The FHS stipulates that GRUB's <filename>menu.lst</filename> file should
  159. be symlinked to <filename class="symlink">/etc/grub/menu.lst</filename>. To
  160. satisfy this requirement, issue the following command:</para>
  161. <screen><userinput>mkdir -v /etc/grub
  162. ln -sv /boot/grub/menu.lst /etc/grub</userinput></screen>
  163. </sect2>
  164. <sect2 id="contents-gRUB" role="content">
  165. <title>Contents of GRUB</title>
  166. <segmentedlist>
  167. <segtitle>Installed programs</segtitle>
  168. <seglistitem>
  169. <seg>grub, grub-install, grub-md5-crypt, grub-set-default,
  170. grub-terminfo, and mbchk</seg>
  171. </seglistitem>
  172. </segmentedlist>
  173. <variablelist>
  174. <bridgehead renderas="sect3">Short Descriptions</bridgehead>
  175. <?dbfo list-presentation="list"?>
  176. <?dbhtml list-presentation="table"?>
  177. <varlistentry id="grub">
  178. <term><command>grub</command></term>
  179. <listitem>
  180. <para>The Grand Unified Bootloader's command shell</para>
  181. <indexterm zone="ch-bootable-grub grub">
  182. <primary sortas="b-grub">grub</primary>
  183. </indexterm>
  184. </listitem>
  185. </varlistentry>
  186. <varlistentry id="grub-install">
  187. <term><command>grub-install</command></term>
  188. <listitem>
  189. <para>Installs GRUB on the given device</para>
  190. <indexterm zone="ch-bootable-grub grub-install">
  191. <primary sortas="b-grub-install">grub-install</primary>
  192. </indexterm>
  193. </listitem>
  194. </varlistentry>
  195. <varlistentry id="grub-md5-crypt">
  196. <term><command>grub-md5-crypt</command></term>
  197. <listitem>
  198. <para>Encrypts a password in MD5 format</para>
  199. <indexterm zone="ch-bootable-grub grub-md5-crypt">
  200. <primary sortas="b-grub-md5-crypt">grub-md5-crypt</primary>
  201. </indexterm>
  202. </listitem>
  203. </varlistentry>
  204. <varlistentry id="grub-set-default">
  205. <term><command>grub-set-default</command></term>
  206. <listitem>
  207. <para>Sets the default boot entry for GRUB</para>
  208. <indexterm zone="ch-bootable-grub grub-set-default">
  209. <primary sortas="b-grub-set-default">grub-set-default</primary>
  210. </indexterm>
  211. </listitem>
  212. </varlistentry>
  213. <varlistentry id="grub-terminfo">
  214. <term><command>grub-terminfo</command></term>
  215. <listitem>
  216. <para>Generates a terminfo command from a terminfo name; it can be
  217. employed if an unknown terminal is being used</para>
  218. <indexterm zone="ch-bootable-grub grub-terminfo">
  219. <primary sortas="b-grub-terminfo">grub-terminfo</primary>
  220. </indexterm>
  221. </listitem>
  222. </varlistentry>
  223. <varlistentry id="mbchk">
  224. <term><command>mbchk</command></term>
  225. <listitem>
  226. <para>Checks the format of a multi-boot kernel</para>
  227. <indexterm zone="ch-bootable-grub mbchk">
  228. <primary sortas="b-mbchk">mbchk</primary>
  229. </indexterm>
  230. </listitem>
  231. </varlistentry>
  232. </variablelist>
  233. </sect2>
  234. </sect1>