1 | <sect1 id="ch08-grub">
|
---|
2 | <title>Making the LFS system bootable</title>
|
---|
3 | <?dbhtml filename="grub.html" dir="chapter08"?>
|
---|
4 |
|
---|
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>
|
---|
8 |
|
---|
9 | <screen><userinput>grub</userinput></screen>
|
---|
10 |
|
---|
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>
|
---|
19 |
|
---|
20 | <para>Using the above information, determine the appropriate designator for
|
---|
21 | your root partition. For the following example, we'll assume your root
|
---|
22 | partition is <filename>hda4</filename>.</para>
|
---|
23 |
|
---|
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>
|
---|
26 |
|
---|
27 | <screen><userinput>root (hd0,3)</userinput></screen>
|
---|
28 |
|
---|
29 | <para>Then tell it to install itself into the MBR (Master Boot Record) of
|
---|
30 | <filename>hda</filename>:</para>
|
---|
31 |
|
---|
32 | <screen><userinput>setup (hd0)</userinput></screen>
|
---|
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 |
|
---|
37 | <screen><userinput>quit</userinput></screen>
|
---|
38 |
|
---|
39 | <para>Now we need to create the <filename>menu.lst</filename> file, which
|
---|
40 | defines Grub's boot menu:</para>
|
---|
41 |
|
---|
42 | <screen><userinput>cat > /boot/grub/menu.lst << "EOF"</userinput>
|
---|
43 | # Begin /boot/grub/menu.lst
|
---|
44 |
|
---|
45 | # By default boot the first menu entry.
|
---|
46 | default 0
|
---|
47 |
|
---|
48 | # Allow 30 seconds before booting the default.
|
---|
49 | timeout 30
|
---|
50 |
|
---|
51 | # Use prettier colors.
|
---|
52 | color green/black light-green/black
|
---|
53 |
|
---|
54 | # The first entry is for LFS.
|
---|
55 | title LFS 5.0
|
---|
56 | root (hd0,3)
|
---|
57 | kernel /boot/lfskernel root=/dev/hda4 ro
|
---|
58 | <userinput>EOF</userinput></screen>
|
---|
59 |
|
---|
60 | <para>You may want to add an entry for your host distribution. It might look
|
---|
61 | like this:</para>
|
---|
62 |
|
---|
63 | <screen><userinput>cat >> /boot/grub/menu.lst << "EOF"</userinput>
|
---|
64 | title Red Hat
|
---|
65 | root (hd0,2)
|
---|
66 | kernel /boot/kernel-2.4.20 root=/dev/hda3 ro
|
---|
67 | initrd /boot/initrd-2.4.20
|
---|
68 | <userinput>EOF</userinput></screen>
|
---|
69 |
|
---|
70 | <para>Also, if you happen to dual-boot Windows, the following entry should
|
---|
71 | allow booting it:</para>
|
---|
72 |
|
---|
73 | <screen><userinput>cat >> /boot/grub/menu.lst << "EOF"</userinput>
|
---|
74 | title Windows
|
---|
75 | rootnoverify (hd0,0)
|
---|
76 | chainloader +1
|
---|
77 | <userinput>EOF</userinput></screen>
|
---|
78 |
|
---|
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:
|
---|
81 | <ulink url="http://www.gnu.org/software/grub"/>.</para>
|
---|
82 |
|
---|
83 | </sect1>
|
---|
84 |
|
---|