grub.xml 11 KB

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