grub.xml 5.5 KB

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