grub.xml 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. <?xml version="1.0" encoding="ISO-8859-1"?>
  2. <!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN" "http://www.oasis-open.org/docbook/xml/4.3/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 things to
  13. do is ensure you can boot it. The instructions below apply only to computers of
  14. IA-32 architecture, meaning mainstream PCs. Information on <quote>boot
  15. loading</quote> for other architectures should be available in the usual
  16. resource-specific locations for those architectures.</para>
  17. <para>Boot loading can be a complex area. First, a few cautionary words. You
  18. really should be familiar with your current boot loader and any other
  19. operating systems present on your hard drive(s) that you might wish to keep
  20. bootable. Please make sure that you have an emergency boot disk ready, so that
  21. you can rescue your computer if, by any chance, your computer becomes unusable
  22. (un-bootable).</para>
  23. <para>Earlier, we compiled and installed the Grub boot loader software in
  24. preparation for this step. The procedure involves writing some special Grub
  25. files to specific locations on the hard drive. Before we get to that, we
  26. highly recommend that you create a Grub boot floppy diskette just in case.
  27. Insert a blank floppy diskette and run the following commands:</para>
  28. <screen><userinput>dd if=/boot/grub/stage1 of=/dev/fd0 bs=512 count=1
  29. dd if=/boot/grub/stage2 of=/dev/fd0 bs=512 seek=1</userinput></screen>
  30. <para>Remove the diskette and store it somewhere safe. Now we'll run the
  31. <userinput>grub</userinput> shell:</para>
  32. <screen><userinput>grub</userinput></screen>
  33. <para>Grub uses its own naming structure for drives and partitions, in the form
  34. of (hdn,m), where <emphasis>n</emphasis> is the hard drive number, and
  35. <emphasis>m</emphasis> the partition number, both starting from zero. This
  36. means, for instance, that partition <filename>hda1</filename> is (hd0,0) to
  37. Grub, and <filename>hdb2</filename> is (hd1,1). In contrast to Linux, Grub
  38. doesn't consider CD-ROM drives to be hard drives, so if you have a CD on
  39. <filename>hdb</filename>, for example, and a second hard drive on
  40. <filename>hdc</filename>, that second hard drive would still be (hd1).</para>
  41. <para>Using the above information, determine the appropriate designator for
  42. your root partition (or boot partition, if you use a separate one). For the
  43. following example, we'll assume your root (or separate boot) partition is
  44. <filename>hda4</filename>.</para>
  45. <para>First, tell Grub where to search for its <filename>stage{1,2}</filename>
  46. files -- you can use the Tab key everywhere to make Grub show the alternatives:</para>
  47. <screen><userinput>root (hd0,3)</userinput></screen>
  48. <warning><para>The following command will overwrite your current boot loader.
  49. Don't run the command if this is not what you want. For example, you may be
  50. using a third party boot manager to manage your MBR (Master Boot Record). In
  51. this scenario, it would probably make more sense to install Grub into the
  52. <quote>boot sector</quote> of the LFS partition, in which case this next command
  53. would become: <userinput>setup (hd0,3)</userinput>.</para></warning>
  54. <para>Tell Grub to install itself into the MBR (Master Boot Record) of
  55. <filename>hda</filename>:</para>
  56. <screen><userinput>setup (hd0)</userinput></screen>
  57. <para>If all is well, Grub will have reported finding its files in
  58. <filename>/boot/grub</filename>. That's all there is to it:</para>
  59. <screen><userinput>quit</userinput></screen>
  60. <para>Now we need to create a <quote>menu list</quote> file, defining Grub's
  61. boot menu:</para>
  62. <screen><userinput>cat &gt; /boot/grub/menu.lst &lt;&lt; "EOF"</userinput>
  63. # Begin /boot/grub/menu.lst
  64. # By default boot the first menu entry.
  65. default 0
  66. # Allow 30 seconds before booting the default.
  67. timeout 30
  68. # Use prettier colors.
  69. color green/black light-green/black
  70. # The first entry is for LFS.
  71. title LFS &milestone; (Linux &linux-version;)
  72. root (hd0,3)
  73. kernel --no-mem-option /boot/lfskernel-&linux-version; root=/dev/hda4
  74. <userinput>EOF</userinput></screen>
  75. <note><para>By default, Grub will automatically pass a <quote>mem=xxx</quote>
  76. command line argument to the kernel. However, Grub occasionally gets the amount
  77. of memory wrong which can lead to problems in some circumstances. It's best to
  78. disable this functionality and let the kernel determine the amount of memory
  79. itself, hence the use of the <emphasis>--no-mem-option</emphasis> above.</para>
  80. </note>
  81. <para>You may want to add an entry for your host distribution. It might look
  82. like this:</para>
  83. <screen><userinput>cat &gt;&gt; /boot/grub/menu.lst &lt;&lt; "EOF"</userinput>
  84. title Red Hat
  85. root (hd0,2)
  86. kernel /boot/kernel-2.4.20 root=/dev/hda3
  87. initrd /boot/initrd-2.4.20
  88. <userinput>EOF</userinput></screen>
  89. <para>Also, if you happen to dual-boot Windows, the following entry should
  90. allow booting it:</para>
  91. <screen><userinput>cat &gt;&gt; /boot/grub/menu.lst &lt;&lt; "EOF"</userinput>
  92. title Windows
  93. rootnoverify (hd0,0)
  94. chainloader +1
  95. <userinput>EOF</userinput></screen>
  96. <para>If <command>info grub</command> doesn't tell you all you want to
  97. know, you can find more information regarding Grub on its website, located at:
  98. <ulink url="http://www.gnu.org/software/grub/"/>.</para>
  99. </sect1>