source: chapter08/grub.xml@ 2bb9942

Last change on this file since 2bb9942 was 1609da8, checked in by Matthew Burgess <matthew@…>, 19 years ago

Upgraded to DocBook 4.4 DTD

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

  • Property mode set to 100644
File size: 5.4 KB
RevLine 
[673b0d8]1<?xml version="1.0" encoding="ISO-8859-1"?>
[1609da8]2<!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN" "http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd" [
[673b0d8]3 <!ENTITY % general-entities SYSTEM "../general.ent">
4 %general-entities;
5]>
[3be4d97]6<sect1 id="ch-bootable-grub">
[69993f4]7<title>Making the LFS System Bootable</title>
[673b0d8]8<?dbhtml filename="grub.html"?>
9
10<indexterm zone="ch-bootable-grub">
11<primary sortas="a-Grub">Grub</primary>
12<secondary>configuring</secondary></indexterm>
[955533b]13
[1dc34de7]14<para>Your shiny new LFS system is almost complete. One of the last
[69993f4]15things to do is to ensure that the system can be properly booted. The
[1dc34de7]16instructions below apply only to computers of IA-32 architecture,
17meaning mainstream PCs. Information on <quote>boot loading</quote> for
18other architectures should be available in the usual resource-specific
19locations for those architectures.</para>
20
[69993f4]21<para>Boot loading can be a complex area, so a few cautionary
[fb34768]22words are in order. Be familiar with the current boot loader and any other
[1dc34de7]23operating systems present on the hard drive(s) that need to be
[69993f4]24bootable. Make sure that an emergency boot disk is ready to
25<quote>rescue</quote> the computer if the computer becomes
[1dc34de7]26unusable (un-bootable).</para>
27
[fb34768]28<para>Earlier, we compiled and installed the Grub boot loader software
[1dc34de7]29in preparation for this step. The procedure involves writing some
30special Grub files to specific locations on the hard drive. We highly
[69993f4]31recommend creating a Grub boot floppy diskette as a backup. Insert a
[1dc34de7]32blank floppy diskette and run the following commands:</para>
[e3a72b1]33
34<screen><userinput>dd if=/boot/grub/stage1 of=/dev/fd0 bs=512 count=1
35dd if=/boot/grub/stage2 of=/dev/fd0 bs=512 seek=1</userinput></screen>
36
[1dc34de7]37<para>Remove the diskette and store it somewhere safe. Now, run the
[0719866]38<command>grub</command> shell:</para>
[1561534]39
[21ba4e3]40<screen><userinput>grub</userinput></screen>
[1561534]41
[69993f4]42<para>Grub uses its own naming structure for drives and partitions in
[1dc34de7]43the form of <emphasis>(hdn,m)</emphasis>, where <emphasis>n</emphasis>
44is the hard drive number and <emphasis>m</emphasis> is the partition
45number, both starting from zero. For example, partition <filename
46class="partition">hda1</filename> is <emphasis>(hd0,0)</emphasis> to
[69993f4]47Grub and <filename class="partition">hdb3</filename> is
[1dc34de7]48<emphasis>(hd1,2)</emphasis>. In contrast to Linux, Grub does not
49consider CD-ROM drives to be hard drives. For example, if using a CD
50on <filename class="partition">hdb</filename> and a second hard drive
51on <filename class="partition">hdc</filename>, that second hard drive
52would still be <emphasis>(hd1)</emphasis>.</para>
53
54<para>Using the above information, determine the appropriate
55designator for the root partition (or boot partition, if a separate
56one is used). For the following example, it is assumed that the root
57(or separate boot) partition is <filename
58class="partition">hda4</filename>.</para>
59
[69993f4]60<para>Tell Grub where to search for its
[1dc34de7]61<filename>stage{1,2}</filename> files. The Tab key can be used
62everywhere to make Grub show the alternatives:</para>
[1561534]63
[21ba4e3]64<screen><userinput>root (hd0,3)</userinput></screen>
[1561534]65
[38bb44a]66<beginpage/>
[1dc34de7]67<warning><para>The following command will overwrite the current boot
68loader. Do not run the command if this is not desired, for example, if
69using a third party boot manager to manage the Master Boot Record
[69993f4]70(MBR). In this scenario, it would make more sense to install
[1dc34de7]71Grub into the <quote>boot sector</quote> of the LFS partition. In this
[2256873]72case, this next command would become <userinput>setup
[1dc34de7]73(hd0,3)</userinput>.</para></warning>
[e3a72b1]74
[69993f4]75<para>Tell Grub to install itself into the MBR of
[0719866]76<filename class="partition">hda</filename>:</para>
[1561534]77
[21ba4e3]78<screen><userinput>setup (hd0)</userinput></screen>
[54ff0b9]79
[1dc34de7]80<para>If all went well, Grub will have reported finding its files in
81<filename class="directory">/boot/grub</filename>. That's all there is
82to it. Quit the <command>grub</command> shell:</para>
[54ff0b9]83
[21ba4e3]84<screen><userinput>quit</userinput></screen>
[54ff0b9]85
[1dc34de7]86<para>Create a <quote>menu list</quote> file defining Grub's boot menu:</para>
[54ff0b9]87
[0719866]88<screen><userinput>cat &gt; /boot/grub/menu.lst &lt;&lt; "EOF"
[3890f5a]89<literal># Begin /boot/grub/menu.lst
[1561534]90
[54ff0b9]91# By default boot the first menu entry.
[1561534]92default 0
93
[54ff0b9]94# Allow 30 seconds before booting the default.
[1561534]95timeout 30
96
[54ff0b9]97# Use prettier colors.
[1561534]98color green/black light-green/black
99
[54ff0b9]100# The first entry is for LFS.
[52216a8]101title LFS &version;
[bc362d4]102root (hd0,3)
[3890f5a]103kernel /boot/lfskernel-&linux-version; root=/dev/hda4</literal>
[0719866]104EOF</userinput></screen>
[1561534]105
[38bb44a]106<beginpage/>
[1dc34de7]107<para>Add an entry for the host distribution if desired. It might look
[54ff0b9]108like this:</para>
[1561534]109
[0719866]110<screen><userinput>cat &gt;&gt; /boot/grub/menu.lst &lt;&lt; "EOF"
[3890f5a]111<literal>title Red Hat
[bc362d4]112root (hd0,2)
[1969cea]113kernel /boot/kernel-2.4.20 root=/dev/hda3
[3890f5a]114initrd /boot/initrd-2.4.20</literal>
[0719866]115EOF</userinput></screen>
[1561534]116
[69993f4]117<para>If dual-booting Windows, the following entry will allow
[1dc34de7]118booting it:</para>
[1561534]119
[0719866]120<screen><userinput>cat &gt;&gt; /boot/grub/menu.lst &lt;&lt; "EOF"
[3890f5a]121<literal>title Windows
[bc362d4]122rootnoverify (hd0,0)
[3890f5a]123chainloader +1</literal>
[0719866]124EOF</userinput></screen>
[1561534]125
[1dc34de7]126<para>If <command>info grub</command> does not provide all necessary material, additional
127information regarding Grub is located on its website at:
[5cd6caa]128<ulink url="http://www.gnu.org/software/grub/"/>.</para>
[955533b]129
[d773252]130<para>The FHS stipulates that Grub's <filename>menu.lst</filename> file should be symlinked to
131<filename class="symlink">/etc/grub/menu.lst</filename>. To satisfy this requirement, issue the
132following command:</para>
[5fcfcd2]133
134<screen><userinput>mkdir /etc/grub &amp;&amp;
135ln -s /boot/grub/menu.lst /etc/grub</userinput></screen>
136
[955533b]137</sect1>
[1dc34de7]138
Note: See TracBrowser for help on using the repository browser.