1 | <?xml version="1.0" encoding="ISO-8859-1"?>
|
---|
2 | <!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
|
---|
3 | "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
|
---|
4 | <!ENTITY % general-entities SYSTEM "../general.ent">
|
---|
5 | %general-entities;
|
---|
6 | ]>
|
---|
7 |
|
---|
8 | <sect1 id="ch-bootable-grub" role="wrap">
|
---|
9 | <?dbhtml filename="grub.html"?>
|
---|
10 |
|
---|
11 | <sect1info condition="script">
|
---|
12 | <productname>grub</productname>
|
---|
13 | <productnumber>&grub-version;</productnumber>
|
---|
14 | <address>&grub-url;</address>
|
---|
15 | </sect1info>
|
---|
16 |
|
---|
17 | <title>GRUB-&grub-version;</title>
|
---|
18 |
|
---|
19 | <indexterm zone="ch-bootable-grub">
|
---|
20 | <primary sortas="a-Grub">GRUB</primary>
|
---|
21 | </indexterm>
|
---|
22 |
|
---|
23 | <sect2 role="package">
|
---|
24 | <title/>
|
---|
25 |
|
---|
26 | <para>The GRUB package contains the GRand Unified Bootloader.</para>
|
---|
27 |
|
---|
28 | <segmentedlist>
|
---|
29 | <segtitle>&buildtime;</segtitle>
|
---|
30 | <segtitle>&diskspace;</segtitle>
|
---|
31 |
|
---|
32 | <seglistitem>
|
---|
33 | <seg>&grub-ch6-sbu;</seg>
|
---|
34 | <seg>&grub-ch6-du;</seg>
|
---|
35 | </seglistitem>
|
---|
36 | </segmentedlist>
|
---|
37 |
|
---|
38 | </sect2>
|
---|
39 |
|
---|
40 | <sect2 role="installation">
|
---|
41 | <title>Installation of GRUB</title>
|
---|
42 |
|
---|
43 | <para>Your shiny new LFS system is almost complete. One of the last
|
---|
44 | things to do is to ensure that the system can be properly booted.</para>
|
---|
45 |
|
---|
46 | <caution>
|
---|
47 | <para>This package will only build for x86 and x86_64 architectures
|
---|
48 | containing 32-bit libs. If you chose to build on x86_64 without 32-bit
|
---|
49 | libraries (no multilib), then you must use LILO instead. Information on
|
---|
50 | <quote>boot loading</quote> for other architectures should be available in
|
---|
51 | the usual resource-specific locations for those architectures.</para>
|
---|
52 | </caution>
|
---|
53 |
|
---|
54 | <para>This package is known to have issues when its default
|
---|
55 | optimization flags (including the <parameter>-march</parameter> and
|
---|
56 | <parameter>-mcpu</parameter> options) are changed. If any environment
|
---|
57 | variables that override default optimizations have been defined, such
|
---|
58 | as <envar>CFLAGS</envar> and <envar>CXXFLAGS</envar>,
|
---|
59 | unset them when building GRUB.</para>
|
---|
60 |
|
---|
61 | <para>Start by applying the following patch to allow for better drive
|
---|
62 | detection, fix some GCC 4.x issues, and provide better SATA support
|
---|
63 | for some disk controllers:</para>
|
---|
64 |
|
---|
65 | <screen><userinput remap="pre">patch -Np1 -i ../&grub-geometry-patch;</userinput></screen>
|
---|
66 |
|
---|
67 | <para>By default, GRUB doesn't support ext2 filesystems with 256-byte inodes.
|
---|
68 | Fix this by applying the following patch:</para>
|
---|
69 |
|
---|
70 | <screen><userinput remap="pre">patch -Np1 -i ../&grub-inode-patch;</userinput></screen>
|
---|
71 |
|
---|
72 | <para>Prepare GRUB for compilation:</para>
|
---|
73 |
|
---|
74 | <screen><userinput remap="configure">./configure --prefix=/usr</userinput></screen>
|
---|
75 |
|
---|
76 | <para>Compile the package:</para>
|
---|
77 |
|
---|
78 | <screen><userinput remap="make">make</userinput></screen>
|
---|
79 |
|
---|
80 | <para>To test the results, issue:</para>
|
---|
81 |
|
---|
82 | <screen><userinput remap="test">make check</userinput></screen>
|
---|
83 |
|
---|
84 | <para>Install the package:</para>
|
---|
85 |
|
---|
86 | <screen><userinput remap="install">make install
|
---|
87 | mkdir -v /boot/grub
|
---|
88 | cp -v /usr/lib/grub/i386-pc/stage{1,2} /boot/grub</userinput></screen>
|
---|
89 |
|
---|
90 | <para>Replace <filename class="directory">i386-pc</filename> with whatever
|
---|
91 | directory is appropriate for the hardware in use.</para>
|
---|
92 |
|
---|
93 | <para>The <filename class="directory">i386-pc</filename> directory
|
---|
94 | contains a number of <filename>*stage1_5</filename> files, different
|
---|
95 | ones for different file systems. Review the files available and copy
|
---|
96 | the appropriate ones to the <filename
|
---|
97 | class="directory">/boot/grub</filename> directory. Most users will
|
---|
98 | copy the <filename>e2fs_stage1_5</filename> and/or
|
---|
99 | <filename>reiserfs_stage1_5</filename> files.</para>
|
---|
100 |
|
---|
101 | </sect2>
|
---|
102 |
|
---|
103 | <sect2 role="configuration">
|
---|
104 | <title>Configuring GRUB</title>
|
---|
105 |
|
---|
106 |
|
---|
107 | <para>Boot loading can be a complex area, so a few cautionary
|
---|
108 | words are in order. Be familiar with the current boot loader and any other
|
---|
109 | operating systems present on the hard drive(s) that need to be
|
---|
110 | bootable. Make sure that an emergency boot disk is ready to
|
---|
111 | <quote>rescue</quote> the computer if the computer becomes
|
---|
112 | unusable (un-bootable).</para>
|
---|
113 |
|
---|
114 | <para>The procedure involves writing some special GRUB files to specific
|
---|
115 | locations on the hard drive. We highly recommend creating a GRUB boot floppy
|
---|
116 | diskette as a backup. Insert a blank floppy diskette and run the following
|
---|
117 | commands:</para>
|
---|
118 |
|
---|
119 | <screen><userinput>dd if=/boot/grub/stage1 of=/dev/fd0 bs=512 count=1
|
---|
120 | dd if=/boot/grub/stage2 of=/dev/fd0 bs=512 seek=1</userinput></screen>
|
---|
121 |
|
---|
122 | <para>Remove the diskette and store it somewhere safe. Now, run the
|
---|
123 | <command>grub</command> shell:</para>
|
---|
124 |
|
---|
125 | <screen><userinput>grub</userinput></screen>
|
---|
126 |
|
---|
127 | <para>GRUB uses its own naming structure for drives and partitions in
|
---|
128 | the form of <emphasis>(hdn,m)</emphasis>, where <emphasis>n</emphasis>
|
---|
129 | is the hard drive number and <emphasis>m</emphasis> is the partition
|
---|
130 | number, both starting from zero. For example, partition <filename
|
---|
131 | class="partition">hda1</filename> is <emphasis>(hd0,0)</emphasis> to
|
---|
132 | GRUB and <filename class="partition">hdb3</filename> is
|
---|
133 | <emphasis>(hd1,2)</emphasis>. In contrast to Linux, GRUB does not
|
---|
134 | consider CD-ROM drives to be hard drives. For example, if using a CD
|
---|
135 | on <filename class="partition">hdb</filename> and a second hard drive
|
---|
136 | on <filename class="partition">hdc</filename>, that second hard drive
|
---|
137 | would still be <emphasis>(hd1)</emphasis>.</para>
|
---|
138 |
|
---|
139 | <para>Using the above information, determine the appropriate
|
---|
140 | designator for the root partition (or boot partition, if a separate
|
---|
141 | one is used). For the following example, it is assumed that the root
|
---|
142 | (or separate boot) partition is <filename
|
---|
143 | class="partition">hda4</filename>.</para>
|
---|
144 |
|
---|
145 | <para>Tell GRUB where to search for its
|
---|
146 | <filename>stage{1,2}</filename> files. The Tab key can be used
|
---|
147 | everywhere to make GRUB show the alternatives:</para>
|
---|
148 |
|
---|
149 | <screen><userinput>root (hd0,3)</userinput></screen>
|
---|
150 |
|
---|
151 | <warning>
|
---|
152 | <para>The following command will overwrite the current boot loader. Do not
|
---|
153 | run the command if this is not desired, for example, if using a third party
|
---|
154 | boot manager to manage the Master Boot Record (MBR). In this scenario, it
|
---|
155 | would make more sense to install GRUB into the <quote>boot sector</quote>
|
---|
156 | of the LFS partition. In this case, this next command would become
|
---|
157 | <userinput>setup (hd0,3)</userinput>.</para>
|
---|
158 | </warning>
|
---|
159 |
|
---|
160 | <para>Tell GRUB to install itself into the MBR of
|
---|
161 | <filename class="partition">hda</filename>:</para>
|
---|
162 |
|
---|
163 | <screen><userinput>setup (hd0)</userinput></screen>
|
---|
164 |
|
---|
165 | <para>If all went well, GRUB will have reported finding its files in
|
---|
166 | <filename class="directory">/boot/grub</filename>. That's all there is
|
---|
167 | to it. Quit the <command>grub</command> shell:</para>
|
---|
168 |
|
---|
169 | <screen><userinput>quit</userinput></screen>
|
---|
170 |
|
---|
171 | <para>Create a <quote>menu list</quote> file defining GRUB's boot menu:</para>
|
---|
172 |
|
---|
173 | <screen><userinput>cat > /boot/grub/menu.lst << "EOF"
|
---|
174 | <literal># Begin /boot/grub/menu.lst
|
---|
175 |
|
---|
176 | # By default boot the first menu entry.
|
---|
177 | default 0
|
---|
178 |
|
---|
179 | # Allow 30 seconds before booting the default.
|
---|
180 | timeout 30
|
---|
181 |
|
---|
182 | # Use prettier colors.
|
---|
183 | color green/black light-green/black
|
---|
184 |
|
---|
185 | # The first entry is for LFS.
|
---|
186 | title LFS &version;
|
---|
187 | root (hd0,3)
|
---|
188 | kernel /boot/lfskernel-&linux-version; root=/dev/hda4</literal>
|
---|
189 | EOF</userinput></screen>
|
---|
190 |
|
---|
191 | <para>Add an entry for the host distribution if desired. It might look
|
---|
192 | like this:</para>
|
---|
193 |
|
---|
194 | <screen><userinput>cat >> /boot/grub/menu.lst << "EOF"
|
---|
195 | <literal>title Red Hat
|
---|
196 | root (hd0,2)
|
---|
197 | kernel /boot/kernel-2.6.5 root=/dev/hda3
|
---|
198 | initrd /boot/initrd-2.6.5</literal>
|
---|
199 | EOF</userinput></screen>
|
---|
200 |
|
---|
201 | <para>If dual-booting Windows, the following entry will allow
|
---|
202 | booting it:</para>
|
---|
203 |
|
---|
204 | <screen><userinput>cat >> /boot/grub/menu.lst << "EOF"
|
---|
205 | <literal>title Windows
|
---|
206 | rootnoverify (hd0,0)
|
---|
207 | chainloader +1</literal>
|
---|
208 | EOF</userinput></screen>
|
---|
209 |
|
---|
210 | <para>If <command>info grub</command> does not provide all necessary material,
|
---|
211 | additional information regarding GRUB is located on its website at:
|
---|
212 | <ulink url="http://www.gnu.org/software/grub/"/>.</para>
|
---|
213 |
|
---|
214 | <para>The FHS stipulates that GRUB's <filename>menu.lst</filename> file should
|
---|
215 | be symlinked to <filename class="symlink">/etc/grub/menu.lst</filename>. To
|
---|
216 | satisfy this requirement, issue the following command:</para>
|
---|
217 |
|
---|
218 | <screen><userinput>mkdir -v /etc/grub
|
---|
219 | ln -sv /boot/grub/menu.lst /etc/grub</userinput></screen>
|
---|
220 |
|
---|
221 | </sect2>
|
---|
222 |
|
---|
223 | <sect2 id="contents-gRUB" role="content">
|
---|
224 | <title>Contents of GRUB</title>
|
---|
225 |
|
---|
226 | <segmentedlist>
|
---|
227 | <segtitle>Installed programs</segtitle>
|
---|
228 |
|
---|
229 | <seglistitem>
|
---|
230 | <seg>grub, grub-install, grub-md5-crypt, grub-set-default,
|
---|
231 | grub-terminfo, and mbchk</seg>
|
---|
232 | </seglistitem>
|
---|
233 | </segmentedlist>
|
---|
234 |
|
---|
235 | <variablelist>
|
---|
236 | <bridgehead renderas="sect3">Short Descriptions</bridgehead>
|
---|
237 | <?dbfo list-presentation="list"?>
|
---|
238 | <?dbhtml list-presentation="table"?>
|
---|
239 |
|
---|
240 | <varlistentry id="grub">
|
---|
241 | <term><command>grub</command></term>
|
---|
242 | <listitem>
|
---|
243 | <para>The Grand Unified Bootloader's command shell</para>
|
---|
244 | <indexterm zone="ch-bootable-grub grub">
|
---|
245 | <primary sortas="b-grub">grub</primary>
|
---|
246 | </indexterm>
|
---|
247 | </listitem>
|
---|
248 | </varlistentry>
|
---|
249 |
|
---|
250 | <varlistentry id="grub-install">
|
---|
251 | <term><command>grub-install</command></term>
|
---|
252 | <listitem>
|
---|
253 | <para>Installs GRUB on the given device</para>
|
---|
254 | <indexterm zone="ch-bootable-grub grub-install">
|
---|
255 | <primary sortas="b-grub-install">grub-install</primary>
|
---|
256 | </indexterm>
|
---|
257 | </listitem>
|
---|
258 | </varlistentry>
|
---|
259 |
|
---|
260 | <varlistentry id="grub-md5-crypt">
|
---|
261 | <term><command>grub-md5-crypt</command></term>
|
---|
262 | <listitem>
|
---|
263 | <para>Encrypts a password in MD5 format</para>
|
---|
264 | <indexterm zone="ch-bootable-grub grub-md5-crypt">
|
---|
265 | <primary sortas="b-grub-md5-crypt">grub-md5-crypt</primary>
|
---|
266 | </indexterm>
|
---|
267 | </listitem>
|
---|
268 | </varlistentry>
|
---|
269 |
|
---|
270 | <varlistentry id="grub-set-default">
|
---|
271 | <term><command>grub-set-default</command></term>
|
---|
272 | <listitem>
|
---|
273 | <para>Sets the default boot entry for GRUB</para>
|
---|
274 | <indexterm zone="ch-bootable-grub grub-set-default">
|
---|
275 | <primary sortas="b-grub-set-default">grub-set-default</primary>
|
---|
276 | </indexterm>
|
---|
277 | </listitem>
|
---|
278 | </varlistentry>
|
---|
279 |
|
---|
280 | <varlistentry id="grub-terminfo">
|
---|
281 | <term><command>grub-terminfo</command></term>
|
---|
282 | <listitem>
|
---|
283 | <para>Generates a terminfo command from a terminfo name; it can be
|
---|
284 | employed if an unknown terminal is being used</para>
|
---|
285 | <indexterm zone="ch-bootable-grub grub-terminfo">
|
---|
286 | <primary sortas="b-grub-terminfo">grub-terminfo</primary>
|
---|
287 | </indexterm>
|
---|
288 | </listitem>
|
---|
289 | </varlistentry>
|
---|
290 |
|
---|
291 | <varlistentry id="mbchk">
|
---|
292 | <term><command>mbchk</command></term>
|
---|
293 | <listitem>
|
---|
294 | <para>Checks the format of a multi-boot kernel</para>
|
---|
295 | <indexterm zone="ch-bootable-grub mbchk">
|
---|
296 | <primary sortas="b-mbchk">mbchk</primary>
|
---|
297 | </indexterm>
|
---|
298 | </listitem>
|
---|
299 | </varlistentry>
|
---|
300 |
|
---|
301 | </variablelist>
|
---|
302 |
|
---|
303 | </sect2>
|
---|
304 |
|
---|
305 | </sect1>
|
---|