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 |
|
---|
10 | <indexterm zone="ch-bootable-grub">
|
---|
11 | <primary sortas="a-Grub">Grub</primary>
|
---|
12 | <secondary>configuring</secondary></indexterm>
|
---|
13 |
|
---|
14 | <para>Your shiny new LFS system is almost complete. One of the last things to
|
---|
15 | do is ensure you can boot it. The instructions below apply only to computers of
|
---|
16 | IA-32 architecture, meaning mainstream PCs. Information on <quote>boot
|
---|
17 | loading</quote> for other architectures should be available in the usual
|
---|
18 | resource-specific locations for those architectures.</para>
|
---|
19 |
|
---|
20 | <para>Boot loading can be a complex area. First, a few cautionary words. You
|
---|
21 | really should be familiar with your current boot loader and any other
|
---|
22 | operating systems present on your hard drive(s) that you might wish to keep
|
---|
23 | bootable. Please make sure that you have an emergency boot disk ready, so that
|
---|
24 | you can rescue your computer if, by any chance, your computer becomes unusable
|
---|
25 | (un-bootable).</para>
|
---|
26 |
|
---|
27 | <para>Earlier, we compiled and installed the Grub boot loader software in
|
---|
28 | preparation for this step. The procedure involves writing some special Grub
|
---|
29 | files to specific locations on the hard drive. Before we get to that, we
|
---|
30 | highly recommend that you create a Grub boot floppy diskette just in case.
|
---|
31 | Insert a blank floppy diskette and run the following commands:</para>
|
---|
32 |
|
---|
33 | <screen><userinput>dd if=/boot/grub/stage1 of=/dev/fd0 bs=512 count=1
|
---|
34 | dd if=/boot/grub/stage2 of=/dev/fd0 bs=512 seek=1</userinput></screen>
|
---|
35 |
|
---|
36 | <para>Remove the diskette and store it somewhere safe. Now we'll run the
|
---|
37 | <command>grub</command> shell:</para>
|
---|
38 |
|
---|
39 | <screen><userinput>grub</userinput></screen>
|
---|
40 |
|
---|
41 | <para>Grub uses its own naming structure for drives and partitions, in the form
|
---|
42 | of (hdn,m), where <emphasis>n</emphasis> is the hard drive number, and
|
---|
43 | <emphasis>m</emphasis> the partition number, both starting from zero. This
|
---|
44 | means, for instance, that partition <filename class="partition">hda1</filename> is (hd0,0) to
|
---|
45 | Grub, and <filename class="partition">hdb2</filename> is (hd1,1). In contrast to Linux, Grub
|
---|
46 | doesn't consider CD-ROM drives to be hard drives, so if you have a CD on
|
---|
47 | <filename class="partition">hdb</filename>, for example, and a second hard drive on
|
---|
48 | <filename class="partition">hdc</filename>, that second hard drive would still be (hd1).</para>
|
---|
49 |
|
---|
50 | <para>Using the above information, determine the appropriate designator for
|
---|
51 | your root partition (or boot partition, if you use a separate one). For the
|
---|
52 | following example, we'll assume your root (or separate boot) partition is
|
---|
53 | <filename class="partition">hda4</filename>.</para>
|
---|
54 |
|
---|
55 | <para>First, tell Grub where to search for its <filename>stage{1,2}</filename>
|
---|
56 | files -- you can use the Tab key everywhere to make Grub show the alternatives:</para>
|
---|
57 |
|
---|
58 | <screen><userinput>root (hd0,3)</userinput></screen>
|
---|
59 |
|
---|
60 |
|
---|
61 | <warning><para>The following command will overwrite your current boot loader.
|
---|
62 | Don't run the command if this is not what you want. For example, you may be
|
---|
63 | using a third party boot manager to manage your MBR (Master Boot Record). In
|
---|
64 | this scenario, it would probably make more sense to install Grub into the
|
---|
65 | <quote>boot sector</quote> of the LFS partition, in which case this next command
|
---|
66 | would become: <userinput>setup (hd0,3)</userinput>.</para></warning>
|
---|
67 |
|
---|
68 |
|
---|
69 | <para>Tell Grub to install itself into the MBR (Master Boot Record) of
|
---|
70 | <filename class="partition">hda</filename>:</para>
|
---|
71 |
|
---|
72 | <screen><userinput>setup (hd0)</userinput></screen>
|
---|
73 |
|
---|
74 | <para>If all is well, Grub will have reported finding its files in
|
---|
75 | <filename class="directory">/boot/grub</filename>. That's all there is to it:</para>
|
---|
76 |
|
---|
77 | <screen><userinput>quit</userinput></screen>
|
---|
78 |
|
---|
79 | <para>Now we need to create a <quote>menu list</quote> file, defining Grub's
|
---|
80 | boot menu:</para>
|
---|
81 |
|
---|
82 | <screen><userinput>cat > /boot/grub/menu.lst << "EOF"
|
---|
83 | # Begin /boot/grub/menu.lst
|
---|
84 |
|
---|
85 | # By default boot the first menu entry.
|
---|
86 | default 0
|
---|
87 |
|
---|
88 | # Allow 30 seconds before booting the default.
|
---|
89 | timeout 30
|
---|
90 |
|
---|
91 | # Use prettier colors.
|
---|
92 | color green/black light-green/black
|
---|
93 |
|
---|
94 | # The first entry is for LFS.
|
---|
95 | title LFS &version;
|
---|
96 | root (hd0,3)
|
---|
97 | kernel /boot/lfskernel-&linux-version; root=/dev/hda4
|
---|
98 | EOF</userinput></screen>
|
---|
99 |
|
---|
100 | <para>You may want to add an entry for your host distribution. It might look
|
---|
101 | like this:</para>
|
---|
102 |
|
---|
103 | <screen><userinput>cat >> /boot/grub/menu.lst << "EOF"
|
---|
104 | title Red Hat
|
---|
105 | root (hd0,2)
|
---|
106 | kernel /boot/kernel-2.4.20 root=/dev/hda3
|
---|
107 | initrd /boot/initrd-2.4.20
|
---|
108 | EOF</userinput></screen>
|
---|
109 |
|
---|
110 | <para>Also, if you happen to dual-boot Windows, the following entry should
|
---|
111 | allow booting it:</para>
|
---|
112 |
|
---|
113 | <screen><userinput>cat >> /boot/grub/menu.lst << "EOF"
|
---|
114 | title Windows
|
---|
115 | rootnoverify (hd0,0)
|
---|
116 | chainloader +1
|
---|
117 | EOF</userinput></screen>
|
---|
118 |
|
---|
119 | <para>If <command>info grub</command> doesn't tell you all you want to
|
---|
120 | know, you can find more information regarding Grub on its website, located at:
|
---|
121 | <ulink url="http://www.gnu.org/software/grub/"/>.</para>
|
---|
122 |
|
---|
123 | <para>The FHS stipulates that Grub's menu.lst file should be symlinked to
|
---|
124 | /etc/grub/menu.lst. To satisfy this requirement, issue the following
|
---|
125 | command:</para>
|
---|
126 |
|
---|
127 | <screen><userinput>mkdir /etc/grub &&
|
---|
128 | ln -s /boot/grub/menu.lst /etc/grub</userinput></screen>
|
---|
129 |
|
---|
130 | </sect1>
|
---|