grub.xml 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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, in the form of (hdn,m),
  9. where n is the hard drive number, and m is the partition number, both of which
  10. start from zero. So, partition hda1 would be (hd0,0) to Grub, and hdb2 would
  11. be (hd1,1). Also, Grub doesn't pay attention to CD-ROM drives at all, so if,
  12. for example, you have a CD on hdb, and a second hard drive on hdc, partitions
  13. on that second hard drive would still be (hd1,m).</para>
  14. <para>So, using the information above, select the appropriate designator for
  15. your root partition. For the purposes of this, we will assume (hd0,3) for
  16. your root partition. First, we tell grub where to find its files:</para>
  17. <para><screen><userinput>root (hd0,3)
  18. setup (hd0)
  19. quit</userinput></screen></para>
  20. <para>This tells Grub to look for its files on hda4 (hd0,3), and install itself
  21. into the MBR (Master Boot Record) of hda.</para>
  22. <para>Also, we need to create the <filename>menu.lst</filename> file, which
  23. Grub uses to designate its boot menu:</para>
  24. <para><screen><userinput>cat &gt; /boot/grub/menu.lst &lt;&lt; "EOF"
  25. # Begin /boot/grub/menu.lst
  26. # Default to first menu entry
  27. default 0
  28. # Allow 30 seconds before booting default
  29. timeout 30
  30. # Use prettier colors
  31. color green/black light-green/black
  32. # Default Entry for LFS
  33. title LFS 5.0
  34. root (hd0,3)
  35. kernel /boot/lfskernel root=/dev/hda4 ro
  36. EOF</userinput></screen></para>
  37. <para>You might also want to add in an entry for your host distribution. It
  38. might look similar to this:</para>
  39. <para><screen><userinput>cat &gt;&gt; /boot/grub/menu.lst &lt;&lt; "EOF"
  40. # Redhat Linux
  41. title Redhat
  42. root (hd0,2)
  43. kernel /boot/kernel-2.4.20 root=/dev/hda3 ro
  44. initrd /boot/initrd-2.4.20
  45. EOF</userinput></screen></para>
  46. <para>Also, if you happen to dual-boot Windows, the following entry should
  47. allow booting it:</para>
  48. <para><screen><userinput>cat &gt;&gt; /boot/grub/menu.lst &lt;&lt; "EOF"
  49. # Windows
  50. title Windows
  51. rootnoverify (hd0,0)
  52. chainloader +1
  53. EOF</userinput></screen></para>
  54. <para>You can find more info regarding Grub on its web site, located at:
  55. <ulink url="http://www.gnu.org/software/grub"/>, as well as in the LFS Grub
  56. HOWTO located at:
  57. <ulink url="http://www.linuxfromscratch.org/hints/downloads/files/grub-howto.txt"/>.</para>
  58. </sect1>