source: chapter08/grub.xml@ 6be8f06

Last change on this file since 6be8f06 was 6be8f06, checked in by Matthew Burgess <matthew@…>, 20 years ago
  • (chapter08/*.xml) RELAX NG validation fixes

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

  • Property mode set to 100644
File size: 5.3 KB
RevLine 
[673b0d8]1<?xml version="1.0" encoding="ISO-8859-1"?>
[6be8f06]2<!DOCTYPE section [
[673b0d8]3 <!ENTITY % general-entities SYSTEM "../general.ent">
4 %general-entities;
5]>
[6be8f06]6<section xmlns="http://docbook.org/docbook-ng"
7 xmlns:xlink="http://www.w3.org/1999/xlink"
8 xml:id="ch-bootable-grub">
9<info><title>Making the LFS system bootable</title></info>
[673b0d8]10<?dbhtml filename="grub.html"?>
11
12<indexterm zone="ch-bootable-grub">
13<primary sortas="a-Grub">Grub</primary>
14<secondary>configuring</secondary></indexterm>
[955533b]15
[e3a72b1]16<para>Your shiny new LFS system is almost complete. One of the last things to
[5cd6caa]17do is ensure you can boot it. The instructions below apply only to computers of
[673b0d8]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>
[e3a72b1]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
[673b0d8]27(un-bootable).</para>
[e3a72b1]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
[0719866]39<command>grub</command> shell:</para>
[1561534]40
[21ba4e3]41<screen><userinput>grub</userinput></screen>
[1561534]42
[54ff0b9]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
[0719866]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
[54ff0b9]48doesn't consider CD-ROM drives to be hard drives, so if you have a CD on
[0719866]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>
[1561534]51
[54ff0b9]52<para>Using the above information, determine the appropriate designator for
[5cd6caa]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
[0719866]55<filename class="partition">hda4</filename>.</para>
[1561534]56
[54ff0b9]57<para>First, tell Grub where to search for its <filename>stage{1,2}</filename>
[673b0d8]58files -- you can use the Tab key everywhere to make Grub show the alternatives:</para>
[1561534]59
[21ba4e3]60<screen><userinput>root (hd0,3)</userinput></screen>
[1561534]61
[e3a72b1]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
[673b0d8]67<quote>boot sector</quote> of the LFS partition, in which case this next command
68would become: <userinput>setup (hd0,3)</userinput>.</para></warning>
[e3a72b1]69
70
[673b0d8]71<para>Tell Grub to install itself into the MBR (Master Boot Record) of
[0719866]72<filename class="partition">hda</filename>:</para>
[1561534]73
[21ba4e3]74<screen><userinput>setup (hd0)</userinput></screen>
[54ff0b9]75
76<para>If all is well, Grub will have reported finding its files in
[0719866]77<filename class="directory">/boot/grub</filename>. That's all there is to it:</para>
[54ff0b9]78
[21ba4e3]79<screen><userinput>quit</userinput></screen>
[54ff0b9]80
[673b0d8]81<para>Now we need to create a <quote>menu list</quote> file, defining Grub's
82boot menu:</para>
[54ff0b9]83
[0719866]84<screen><userinput>cat &gt; /boot/grub/menu.lst &lt;&lt; "EOF"
[1561534]85# Begin /boot/grub/menu.lst
86
[54ff0b9]87# By default boot the first menu entry.
[1561534]88default 0
89
[54ff0b9]90# Allow 30 seconds before booting the default.
[1561534]91timeout 30
92
[54ff0b9]93# Use prettier colors.
[1561534]94color green/black light-green/black
95
[54ff0b9]96# The first entry is for LFS.
[52216a8]97title LFS &version;
[bc362d4]98root (hd0,3)
[eb443a3]99kernel /boot/lfskernel-&linux-version; root=/dev/hda4
[0719866]100EOF</userinput></screen>
[1561534]101
[17476c5]102<para>You may want to add an entry for your host distribution. It might look
[54ff0b9]103like this:</para>
[1561534]104
[0719866]105<screen><userinput>cat &gt;&gt; /boot/grub/menu.lst &lt;&lt; "EOF"
[54ff0b9]106title Red Hat
[bc362d4]107root (hd0,2)
[1969cea]108kernel /boot/kernel-2.4.20 root=/dev/hda3
[bc362d4]109initrd /boot/initrd-2.4.20
[0719866]110EOF</userinput></screen>
[1561534]111
112<para>Also, if you happen to dual-boot Windows, the following entry should
113allow booting it:</para>
114
[0719866]115<screen><userinput>cat &gt;&gt; /boot/grub/menu.lst &lt;&lt; "EOF"
[bc362d4]116title Windows
117rootnoverify (hd0,0)
118chainloader +1
[0719866]119EOF</userinput></screen>
[1561534]120
[90e3cb3]121<para>If <command>info grub</command> doesn't tell you all you want to
[54ff0b9]122know, you can find more information regarding Grub on its website, located at:
[6be8f06]123<uri xlink:href="http://www.gnu.org/software/grub/"/>.</para>
[955533b]124
[205af12]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
[6be8f06]132</section>
Note: See TracBrowser for help on using the repository browser.