[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">
|
---|
[6a0e6f3] | 9 | <title>Making the LFS system bootable</title>
|
---|
[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] | 17 | do is ensure you can boot it. The instructions below apply only to computers of
|
---|
[673b0d8] | 18 | IA-32 architecture, meaning mainstream PCs. Information on <quote>boot
|
---|
| 19 | loading</quote> for other architectures should be available in the usual
|
---|
| 20 | resource-specific locations for those architectures.</para>
|
---|
[e3a72b1] | 21 |
|
---|
| 22 | <para>Boot loading can be a complex area. First, a few cautionary words. You
|
---|
| 23 | really should be familiar with your current boot loader and any other
|
---|
| 24 | operating systems present on your hard drive(s) that you might wish to keep
|
---|
| 25 | bootable. Please make sure that you have an emergency boot disk ready, so that
|
---|
| 26 | you 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
|
---|
| 30 | preparation for this step. The procedure involves writing some special Grub
|
---|
| 31 | files to specific locations on the hard drive. Before we get to that, we
|
---|
| 32 | highly recommend that you create a Grub boot floppy diskette just in case.
|
---|
| 33 | Insert 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
|
---|
| 36 | dd 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
|
---|
| 44 | of (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] | 46 | means, for instance, that partition <filename class="partition">hda1</filename> is (hd0,0) to
|
---|
| 47 | Grub, and <filename class="partition">hdb2</filename> is (hd1,1). In contrast to Linux, Grub
|
---|
[54ff0b9] | 48 | doesn'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] | 53 | your root partition (or boot partition, if you use a separate one). For the
|
---|
| 54 | following 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] | 58 | files -- 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.
|
---|
| 64 | Don't run the command if this is not what you want. For example, you may be
|
---|
| 65 | using a third party boot manager to manage your MBR (Master Boot Record). In
|
---|
| 66 | this 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
|
---|
| 68 | would 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
|
---|
| 82 | boot menu:</para>
|
---|
[54ff0b9] | 83 |
|
---|
[0719866] | 84 | <screen><userinput>cat > /boot/grub/menu.lst << "EOF"
|
---|
[1561534] | 85 | # Begin /boot/grub/menu.lst
|
---|
| 86 |
|
---|
[54ff0b9] | 87 | # By default boot the first menu entry.
|
---|
[1561534] | 88 | default 0
|
---|
| 89 |
|
---|
[54ff0b9] | 90 | # Allow 30 seconds before booting the default.
|
---|
[1561534] | 91 | timeout 30
|
---|
| 92 |
|
---|
[54ff0b9] | 93 | # Use prettier colors.
|
---|
[1561534] | 94 | color green/black light-green/black
|
---|
| 95 |
|
---|
[54ff0b9] | 96 | # The first entry is for LFS.
|
---|
[52216a8] | 97 | title LFS &version;
|
---|
[bc362d4] | 98 | root (hd0,3)
|
---|
[eb443a3] | 99 | kernel /boot/lfskernel-&linux-version; root=/dev/hda4
|
---|
[0719866] | 100 | EOF</userinput></screen>
|
---|
[1561534] | 101 |
|
---|
[17476c5] | 102 | <para>You may want to add an entry for your host distribution. It might look
|
---|
[54ff0b9] | 103 | like this:</para>
|
---|
[1561534] | 104 |
|
---|
[0719866] | 105 | <screen><userinput>cat >> /boot/grub/menu.lst << "EOF"
|
---|
[54ff0b9] | 106 | title Red Hat
|
---|
[bc362d4] | 107 | root (hd0,2)
|
---|
[1969cea] | 108 | kernel /boot/kernel-2.4.20 root=/dev/hda3
|
---|
[bc362d4] | 109 | initrd /boot/initrd-2.4.20
|
---|
[0719866] | 110 | EOF</userinput></screen>
|
---|
[1561534] | 111 |
|
---|
| 112 | <para>Also, if you happen to dual-boot Windows, the following entry should
|
---|
| 113 | allow booting it:</para>
|
---|
| 114 |
|
---|
[0719866] | 115 | <screen><userinput>cat >> /boot/grub/menu.lst << "EOF"
|
---|
[bc362d4] | 116 | title Windows
|
---|
| 117 | rootnoverify (hd0,0)
|
---|
| 118 | chainloader +1
|
---|
[0719866] | 119 | EOF</userinput></screen>
|
---|
[1561534] | 120 |
|
---|
[90e3cb3] | 121 | <para>If <command>info grub</command> doesn't tell you all you want to
|
---|
[54ff0b9] | 122 | know, you can find more information regarding Grub on its website, located at:
|
---|
[dc6acb5] | 123 | <link 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
|
---|
| 127 | command:</para>
|
---|
| 128 |
|
---|
| 129 | <screen><userinput>mkdir /etc/grub &&
|
---|
| 130 | ln -s /boot/grub/menu.lst /etc/grub</userinput></screen>
|
---|
| 131 |
|
---|
[6be8f06] | 132 | </section>
|
---|