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