grub.xml 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. <?xml version="1.0" encoding="ISO-8859-1"?>
  2. <!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN" "http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd" [
  3. <!ENTITY % general-entities SYSTEM "../general.ent">
  4. %general-entities;
  5. ]>
  6. <sect1 id="ch-bootable-grub">
  7. <title>Making the LFS System Bootable</title>
  8. <?dbhtml filename="grub.html"?>
  9. <indexterm zone="ch-bootable-grub">
  10. <primary sortas="a-Grub">GRUB</primary>
  11. <secondary>configuring</secondary></indexterm>
  12. <para>Your shiny new LFS system is almost complete. One of the last
  13. things to do is to ensure that the system can be properly booted. The
  14. instructions below apply only to computers of IA-32 architecture,
  15. meaning mainstream PCs. Information on <quote>boot loading</quote> for
  16. other architectures should be available in the usual resource-specific
  17. locations for those architectures.</para>
  18. <para>Boot loading can be a complex area, so a few cautionary
  19. words are in order. Be familiar with the current boot loader and any other
  20. operating systems present on the hard drive(s) that need to be
  21. bootable. Make sure that an emergency boot disk is ready to
  22. <quote>rescue</quote> the computer if the computer becomes
  23. unusable (un-bootable).</para>
  24. <para>Earlier, we compiled and installed the GRUB boot loader software
  25. in preparation for this step. The procedure involves writing some
  26. special GRUB files to specific locations on the hard drive. We highly
  27. recommend creating a GRUB boot floppy diskette as a backup. Insert a
  28. blank floppy diskette and run the following commands:</para>
  29. <screen><userinput>dd if=/boot/grub/stage1 of=/dev/fd0 bs=512 count=1
  30. dd if=/boot/grub/stage2 of=/dev/fd0 bs=512 seek=1</userinput></screen>
  31. <para>Remove the diskette and store it somewhere safe. Now, run the
  32. <command>grub</command> shell:</para>
  33. <screen><userinput>grub</userinput></screen>
  34. <para>GRUB uses its own naming structure for drives and partitions in
  35. the form of <emphasis>(hdn,m)</emphasis>, where <emphasis>n</emphasis>
  36. is the hard drive number and <emphasis>m</emphasis> is the partition
  37. number, both starting from zero. For example, partition <filename
  38. class="partition">hda1</filename> is <emphasis>(hd0,0)</emphasis> to
  39. GRUB and <filename class="partition">hdb3</filename> is
  40. <emphasis>(hd1,2)</emphasis>. In contrast to Linux, GRUB does not
  41. consider CD-ROM drives to be hard drives. For example, if using a CD
  42. on <filename class="partition">hdb</filename> and a second hard drive
  43. on <filename class="partition">hdc</filename>, that second hard drive
  44. would still be <emphasis>(hd1)</emphasis>.</para>
  45. <para>Using the above information, determine the appropriate
  46. designator for the root partition (or boot partition, if a separate
  47. one is used). For the following example, it is assumed that the root
  48. (or separate boot) partition is <filename
  49. class="partition">hda4</filename>.</para>
  50. <para>Tell GRUB where to search for its
  51. <filename>stage{1,2}</filename> files. The Tab key can be used
  52. everywhere to make GRUB show the alternatives:</para>
  53. <screen><userinput>root (hd0,3)</userinput></screen>
  54. <warning><para>The following command will overwrite the current boot
  55. loader. Do not run the command if this is not desired, for example, if
  56. using a third party boot manager to manage the Master Boot Record
  57. (MBR). In this scenario, it would make more sense to install
  58. GRUB into the <quote>boot sector</quote> of the LFS partition. In this
  59. case, this next command would become <userinput>setup
  60. (hd0,3)</userinput>.</para></warning>
  61. <para>Tell GRUB to install itself into the MBR of
  62. <filename class="partition">hda</filename>:</para>
  63. <screen><userinput>setup (hd0)</userinput></screen>
  64. <para>If all went well, GRUB will have reported finding its files in
  65. <filename class="directory">/boot/grub</filename>. That's all there is
  66. to it. Quit the <command>grub</command> shell:</para>
  67. <screen><userinput>quit</userinput></screen>
  68. <para>Create a <quote>menu list</quote> file defining GRUB's boot menu:</para>
  69. <screen><userinput>cat &gt; /boot/grub/menu.lst &lt;&lt; "EOF"
  70. <literal># Begin /boot/grub/menu.lst
  71. # By default boot the first menu entry.
  72. default 0
  73. # Allow 30 seconds before booting the default.
  74. timeout 30
  75. # Use prettier colors.
  76. color green/black light-green/black
  77. # The first entry is for LFS.
  78. title LFS &version;
  79. root (hd0,3)
  80. kernel /boot/lfskernel-&linux-version; root=/dev/hda4</literal>
  81. EOF</userinput></screen>
  82. <para>Add an entry for the host distribution if desired. It might look
  83. like this:</para>
  84. <screen><userinput>cat &gt;&gt; /boot/grub/menu.lst &lt;&lt; "EOF"
  85. <literal>title Red Hat
  86. root (hd0,2)
  87. kernel /boot/kernel-2.6.5 root=/dev/hda3
  88. initrd /boot/initrd-2.6.5</literal>
  89. EOF</userinput></screen>
  90. <para>If dual-booting Windows, the following entry will allow
  91. booting it:</para>
  92. <screen><userinput>cat &gt;&gt; /boot/grub/menu.lst &lt;&lt; "EOF"
  93. <literal>title Windows
  94. rootnoverify (hd0,0)
  95. chainloader +1</literal>
  96. EOF</userinput></screen>
  97. <para>If <command>info grub</command> does not provide all necessary material, additional
  98. information regarding GRUB is located on its website at:
  99. <ulink url="http://www.gnu.org/software/grub/"/>.</para>
  100. <para>The FHS stipulates that GRUB's <filename>menu.lst</filename> file should be symlinked to
  101. <filename class="symlink">/etc/grub/menu.lst</filename>. To satisfy this requirement, issue the
  102. following command:</para>
  103. <screen><userinput>mkdir /etc/grub &amp;&amp;
  104. ln -s /boot/grub/menu.lst /etc/grub</userinput></screen>
  105. </sect1>