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