grub.xml 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <sect1 id="ch08-grub">
  2. <title>Making the LFS system bootable</title>
  3. <?dbhtml filename="grub.html" dir="chapter08"?>
  4. <para>Now that we have our shiny new Linux-From-Scratch system completed,
  5. we need to ensure we can boot it. To do this, we will run the
  6. <userinput>grub</userinput> program.</para>
  7. <para><screen><userinput>grub</userinput></screen></para>
  8. <para>Grub uses its own naming structure for drives and partitions, in the form
  9. of (hdn,m), where <emphasis>n</emphasis> is the hard drive number, and
  10. <emphasis>m</emphasis> the partition number, both starting from zero. This
  11. means, for instance, that partition <filename>hda1</filename> is (hd0,0) to
  12. Grub, and <filename>hdb2</filename> is (hd1,1). In contrast to Linux, Grub
  13. doesn't consider CD-ROM drives to be hard drives, so if you have a CD on
  14. <filename>hdb</filename>, for example, and a second hard drive on
  15. <filename>hdc</filename>, that second hard drive would still be (hd1).</para>
  16. <para>Using the above information, determine the appropriate designator for
  17. your root partition. For the following example, we'll assume your root
  18. partition is <filename>hda4</filename>.</para>
  19. <para>First, tell Grub where to search for its <filename>stage{1,2}</filename>
  20. files -- you can use Tab everywhere to make Grub show the alternatives:</para>
  21. <para><screen><userinput>root (hd0,3)</userinput></screen></para>
  22. <para>Then tell it to install itself into the MBR (Master Boot Record) of
  23. <filename>hda</filename>:</para>
  24. <para><screen><userinput>setup (hd0)</userinput></screen></para>
  25. <para>If all is well, Grub will have reported finding its files in
  26. <filename>/boot/grub</filename>. That's all there was to it:</para>
  27. <para><screen><userinput>quit</userinput></screen></para>
  28. <para>Now we need to create the <filename>menu.lst</filename> file, which
  29. defines Grub's boot menu:</para>
  30. <para><screen><userinput>cat &gt; /boot/grub/menu.lst &lt;&lt; "EOF"</userinput>
  31. # Begin /boot/grub/menu.lst
  32. # By default boot the first menu entry.
  33. default 0
  34. # Allow 30 seconds before booting the default.
  35. timeout 30
  36. # Use prettier colors.
  37. color green/black light-green/black
  38. # The first entry is for LFS.
  39. title LFS 5.0
  40. root (hd0,3)
  41. kernel /boot/lfskernel root=/dev/hda4 ro
  42. <userinput>EOF</userinput></screen></para>
  43. <para>You may want to add an entry for your host distribution. It might look
  44. like this:</para>
  45. <para><screen><userinput>cat &gt;&gt; /boot/grub/menu.lst &lt;&lt; "EOF"</userinput>
  46. title Red Hat
  47. root (hd0,2)
  48. kernel /boot/kernel-2.4.20 root=/dev/hda3 ro
  49. initrd /boot/initrd-2.4.20
  50. <userinput>EOF</userinput></screen></para>
  51. <para>Also, if you happen to dual-boot Windows, the following entry should
  52. allow booting it:</para>
  53. <para><screen><userinput>cat &gt;&gt; /boot/grub/menu.lst &lt;&lt; "EOF"</userinput>
  54. title Windows
  55. rootnoverify (hd0,0)
  56. chainloader +1
  57. <userinput>EOF</userinput></screen></para>
  58. <para>If <userinput>info grub</userinput> doesn't tell you all you want to
  59. know, you can find more information regarding Grub on its website, located at:
  60. <ulink url="http://www.gnu.org/software/grub"/>.</para>
  61. </sect1>