2003-09-11 22:35:35 +01:00
|
|
|
<sect1 id="ch08-grub">
|
|
|
|
<title>Making the LFS system bootable</title>
|
|
|
|
<?dbhtml filename="grub.html" dir="chapter08"?>
|
|
|
|
|
2003-09-15 22:47:44 +01:00
|
|
|
<para>Now that we have our shiny new Linux-From-Scratch system completed,
|
|
|
|
we need to ensure we can boot it. To do this, we will run the
|
|
|
|
<userinput>grub</userinput> program.</para>
|
2003-09-12 01:47:51 +01:00
|
|
|
|
2003-10-10 00:22:07 +01:00
|
|
|
<screen><userinput>grub</userinput></screen>
|
2003-09-12 01:47:51 +01:00
|
|
|
|
2003-10-08 23:31:01 +01:00
|
|
|
<para>Grub uses its own naming structure for drives and partitions, in the form
|
|
|
|
of (hdn,m), where <emphasis>n</emphasis> is the hard drive number, and
|
|
|
|
<emphasis>m</emphasis> the partition number, both starting from zero. This
|
|
|
|
means, for instance, that partition <filename>hda1</filename> is (hd0,0) to
|
|
|
|
Grub, and <filename>hdb2</filename> is (hd1,1). In contrast to Linux, Grub
|
|
|
|
doesn't consider CD-ROM drives to be hard drives, so if you have a CD on
|
|
|
|
<filename>hdb</filename>, for example, and a second hard drive on
|
|
|
|
<filename>hdc</filename>, that second hard drive would still be (hd1).</para>
|
2003-09-12 01:47:51 +01:00
|
|
|
|
2003-10-08 23:31:01 +01:00
|
|
|
<para>Using the above information, determine the appropriate designator for
|
2003-10-09 23:35:55 +01:00
|
|
|
your root partition. For the following example, we'll assume your root
|
|
|
|
partition is <filename>hda4</filename>.</para>
|
2003-09-12 01:47:51 +01:00
|
|
|
|
2003-10-08 23:31:01 +01:00
|
|
|
<para>First, tell Grub where to search for its <filename>stage{1,2}</filename>
|
|
|
|
files -- you can use Tab everywhere to make Grub show the alternatives:</para>
|
2003-09-12 01:47:51 +01:00
|
|
|
|
2003-10-10 00:22:07 +01:00
|
|
|
<screen><userinput>root (hd0,3)</userinput></screen>
|
2003-09-12 01:47:51 +01:00
|
|
|
|
2003-10-08 23:31:01 +01:00
|
|
|
<para>Then tell it to install itself into the MBR (Master Boot Record) of
|
|
|
|
<filename>hda</filename>:</para>
|
2003-09-12 01:47:51 +01:00
|
|
|
|
2003-10-10 00:22:07 +01:00
|
|
|
<screen><userinput>setup (hd0)</userinput></screen>
|
2003-10-08 23:31:01 +01:00
|
|
|
|
|
|
|
<para>If all is well, Grub will have reported finding its files in
|
|
|
|
<filename>/boot/grub</filename>. That's all there was to it:</para>
|
|
|
|
|
2003-10-10 00:22:07 +01:00
|
|
|
<screen><userinput>quit</userinput></screen>
|
2003-10-08 23:31:01 +01:00
|
|
|
|
|
|
|
<para>Now we need to create the <filename>menu.lst</filename> file, which
|
|
|
|
defines Grub's boot menu:</para>
|
|
|
|
|
2003-10-10 00:22:07 +01:00
|
|
|
<screen><userinput>cat > /boot/grub/menu.lst << "EOF"</userinput>
|
2003-09-12 01:47:51 +01:00
|
|
|
# Begin /boot/grub/menu.lst
|
|
|
|
|
2003-10-08 23:31:01 +01:00
|
|
|
# By default boot the first menu entry.
|
2003-09-12 01:47:51 +01:00
|
|
|
default 0
|
|
|
|
|
2003-10-08 23:31:01 +01:00
|
|
|
# Allow 30 seconds before booting the default.
|
2003-09-12 01:47:51 +01:00
|
|
|
timeout 30
|
|
|
|
|
2003-10-08 23:31:01 +01:00
|
|
|
# Use prettier colors.
|
2003-09-12 01:47:51 +01:00
|
|
|
color green/black light-green/black
|
|
|
|
|
2003-10-08 23:31:01 +01:00
|
|
|
# The first entry is for LFS.
|
2003-09-12 01:47:51 +01:00
|
|
|
title LFS 5.0
|
2003-09-12 07:50:02 +01:00
|
|
|
root (hd0,3)
|
|
|
|
kernel /boot/lfskernel root=/dev/hda4 ro
|
2003-10-10 00:22:07 +01:00
|
|
|
<userinput>EOF</userinput></screen>
|
2003-09-12 01:47:51 +01:00
|
|
|
|
2003-10-08 23:31:01 +01:00
|
|
|
<para>You may want to add an entry for your host distribution. It might look
|
|
|
|
like this:</para>
|
2003-09-12 01:47:51 +01:00
|
|
|
|
2003-10-10 00:22:07 +01:00
|
|
|
<screen><userinput>cat >> /boot/grub/menu.lst << "EOF"</userinput>
|
2003-10-08 23:31:01 +01:00
|
|
|
title Red Hat
|
2003-09-12 07:50:02 +01:00
|
|
|
root (hd0,2)
|
|
|
|
kernel /boot/kernel-2.4.20 root=/dev/hda3 ro
|
|
|
|
initrd /boot/initrd-2.4.20
|
2003-10-10 00:22:07 +01:00
|
|
|
<userinput>EOF</userinput></screen>
|
2003-09-12 01:47:51 +01:00
|
|
|
|
|
|
|
<para>Also, if you happen to dual-boot Windows, the following entry should
|
|
|
|
allow booting it:</para>
|
|
|
|
|
2003-10-10 00:22:07 +01:00
|
|
|
<screen><userinput>cat >> /boot/grub/menu.lst << "EOF"</userinput>
|
2003-09-12 07:50:02 +01:00
|
|
|
title Windows
|
|
|
|
rootnoverify (hd0,0)
|
|
|
|
chainloader +1
|
2003-10-10 00:22:07 +01:00
|
|
|
<userinput>EOF</userinput></screen>
|
2003-09-12 01:47:51 +01:00
|
|
|
|
2003-10-08 23:31:01 +01:00
|
|
|
<para>If <userinput>info grub</userinput> doesn't tell you all you want to
|
|
|
|
know, you can find more information regarding Grub on its website, located at:
|
2003-09-29 03:27:27 +01:00
|
|
|
<ulink url="http://www.gnu.org/software/grub"/>.</para>
|
2003-09-11 22:35:35 +01:00
|
|
|
|
|
|
|
</sect1>
|
|
|
|
|