source: chapter08/grub.xml@ 6a0e6f3

Last change on this file since 6a0e6f3 was 6a0e6f3, checked in by Matthew Burgess <matthew@…>, 19 years ago
  • Remove the spurious <info> tags that I thought were necessary but evidently aren't

git-svn-id: http://svn.linuxfromscratch.org/LFS/branches/LFS-RNG/BOOK@4387 4aa44e1e-78dd-0310-a6d2-fbcd4c07a689

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