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">
6 <sect1 id="ch-bootable-grub">
7 <title>Making the LFS system bootable</title>
8 <?dbhtml filename="grub.html"?>
10 <indexterm zone="ch-bootable-grub">
11 <primary sortas="a-Grub">Grub</primary>
12 <secondary>configuring</secondary></indexterm>
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>
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
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>
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>
36 <para>Remove the diskette and store it somewhere safe. Now we'll run the
37 <userinput>grub</userinput> shell:</para>
39 <screen><userinput>grub</userinput></screen>
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>hda1</filename> is (hd0,0) to
45 Grub, and <filename>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>hdb</filename>, for example, and a second hard drive on
48 <filename>hdc</filename>, that second hard drive would still be (hd1).</para>
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>hda4</filename>.</para>
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>
58 <screen><userinput>root (hd0,3)</userinput></screen>
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>
69 <para>Tell Grub to install itself into the MBR (Master Boot Record) of
70 <filename>hda</filename>:</para>
72 <screen><userinput>setup (hd0)</userinput></screen>
74 <para>If all is well, Grub will have reported finding its files in
75 <filename>/boot/grub</filename>. That's all there is to it:</para>
77 <screen><userinput>quit</userinput></screen>
79 <para>Now we need to create a <quote>menu list</quote> file, defining Grub's
82 <screen><userinput>cat > /boot/grub/menu.lst << "EOF"</userinput>
83 # Begin /boot/grub/menu.lst
85 # By default boot the first menu entry.
88 # Allow 30 seconds before booting the default.
91 # Use prettier colors.
92 color green/black light-green/black
94 # The first entry is for LFS.
97 kernel --no-mem-option /boot/lfskernel root=/dev/hda4
98 <userinput>EOF</userinput></screen>
100 <note><para>By default, Grub will automatically pass a <quote>mem=xxx</quote>
101 command line argument to the kernel. However, Grub occasionally gets the amount
102 of memory wrong which can lead to problems in some circumstances. It's best to
103 disable this functionality and let the kernel determine the amount of memory
104 itself, hence the use of the <emphasis>--no-mem-option</emphasis> above.</para>
107 <para>You may want to add an entry for your host distribution. It might look
110 <screen><userinput>cat >> /boot/grub/menu.lst << "EOF"</userinput>
113 kernel /boot/kernel-2.4.20 root=/dev/hda3
114 initrd /boot/initrd-2.4.20
115 <userinput>EOF</userinput></screen>
117 <para>Also, if you happen to dual-boot Windows, the following entry should
118 allow booting it:</para>
120 <screen><userinput>cat >> /boot/grub/menu.lst << "EOF"</userinput>
124 <userinput>EOF</userinput></screen>
126 <para>If <command>info grub</command> doesn't tell you all you want to
127 know, you can find more information regarding Grub on its website, located at:
128 <ulink url="http://www.gnu.org/software/grub/"/>.</para>