[673b0d8] | 1 | <?xml version="1.0" encoding="ISO-8859-1"?>
|
---|
| 2 | <!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN" "http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd" [
|
---|
| 3 | <!ENTITY % general-entities SYSTEM "../general.ent">
|
---|
| 4 | %general-entities;
|
---|
| 5 | ]>
|
---|
[3be4d97] | 6 | <sect1 id="ch-bootable-grub">
|
---|
[955533b] | 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 |
|
---|
[e3a72b1] | 14 | <para>Your shiny new LFS system is almost complete. One of the last things to
|
---|
[5cd6caa] | 15 | do is ensure you can boot it. The instructions below apply only to computers of
|
---|
[673b0d8] | 16 | IA-32 architecture, meaning mainstream PCs. Information on <quote>boot
|
---|
| 17 | loading</quote> for other architectures should be available in the usual
|
---|
| 18 | resource-specific locations for those architectures.</para>
|
---|
[e3a72b1] | 19 |
|
---|
| 20 | <para>Boot loading can be a complex area. First, a few cautionary words. You
|
---|
| 21 | really should be familiar with your current boot loader and any other
|
---|
| 22 | operating systems present on your hard drive(s) that you might wish to keep
|
---|
| 23 | bootable. Please make sure that you have an emergency boot disk ready, so that
|
---|
| 24 | you can rescue your computer if, by any chance, your computer becomes unusable
|
---|
[673b0d8] | 25 | (un-bootable).</para>
|
---|
[e3a72b1] | 26 |
|
---|
| 27 | <para>Earlier, we compiled and installed the Grub boot loader software in
|
---|
| 28 | preparation for this step. The procedure involves writing some special Grub
|
---|
| 29 | files to specific locations on the hard drive. Before we get to that, we
|
---|
| 30 | highly recommend that you create a Grub boot floppy diskette just in case.
|
---|
| 31 | Insert a blank floppy diskette and run the following commands:</para>
|
---|
| 32 |
|
---|
| 33 | <screen><userinput>dd if=/boot/grub/stage1 of=/dev/fd0 bs=512 count=1
|
---|
| 34 | dd if=/boot/grub/stage2 of=/dev/fd0 bs=512 seek=1</userinput></screen>
|
---|
| 35 |
|
---|
| 36 | <para>Remove the diskette and store it somewhere safe. Now we'll run the
|
---|
[0719866] | 37 | <command>grub</command> shell:</para>
|
---|
[1561534] | 38 |
|
---|
[21ba4e3] | 39 | <screen><userinput>grub</userinput></screen>
|
---|
[1561534] | 40 |
|
---|
[54ff0b9] | 41 | <para>Grub uses its own naming structure for drives and partitions, in the form
|
---|
| 42 | of (hdn,m), where <emphasis>n</emphasis> is the hard drive number, and
|
---|
| 43 | <emphasis>m</emphasis> the partition number, both starting from zero. This
|
---|
[0719866] | 44 | means, for instance, that partition <filename class="partition">hda1</filename> is (hd0,0) to
|
---|
| 45 | Grub, and <filename class="partition">hdb2</filename> is (hd1,1). In contrast to Linux, Grub
|
---|
[54ff0b9] | 46 | doesn't consider CD-ROM drives to be hard drives, so if you have a CD on
|
---|
[0719866] | 47 | <filename class="partition">hdb</filename>, for example, and a second hard drive on
|
---|
| 48 | <filename class="partition">hdc</filename>, that second hard drive would still be (hd1).</para>
|
---|
[1561534] | 49 |
|
---|
[54ff0b9] | 50 | <para>Using the above information, determine the appropriate designator for
|
---|
[5cd6caa] | 51 | your root partition (or boot partition, if you use a separate one). For the
|
---|
| 52 | following example, we'll assume your root (or separate boot) partition is
|
---|
[0719866] | 53 | <filename class="partition">hda4</filename>.</para>
|
---|
[1561534] | 54 |
|
---|
[54ff0b9] | 55 | <para>First, tell Grub where to search for its <filename>stage{1,2}</filename>
|
---|
[673b0d8] | 56 | files -- you can use the Tab key everywhere to make Grub show the alternatives:</para>
|
---|
[1561534] | 57 |
|
---|
[21ba4e3] | 58 | <screen><userinput>root (hd0,3)</userinput></screen>
|
---|
[1561534] | 59 |
|
---|
[e3a72b1] | 60 |
|
---|
| 61 | <warning><para>The following command will overwrite your current boot loader.
|
---|
| 62 | Don't run the command if this is not what you want. For example, you may be
|
---|
| 63 | using a third party boot manager to manage your MBR (Master Boot Record). In
|
---|
| 64 | this scenario, it would probably make more sense to install Grub into the
|
---|
[673b0d8] | 65 | <quote>boot sector</quote> of the LFS partition, in which case this next command
|
---|
| 66 | would become: <userinput>setup (hd0,3)</userinput>.</para></warning>
|
---|
[e3a72b1] | 67 |
|
---|
| 68 |
|
---|
[673b0d8] | 69 | <para>Tell Grub to install itself into the MBR (Master Boot Record) of
|
---|
[0719866] | 70 | <filename class="partition">hda</filename>:</para>
|
---|
[1561534] | 71 |
|
---|
[21ba4e3] | 72 | <screen><userinput>setup (hd0)</userinput></screen>
|
---|
[54ff0b9] | 73 |
|
---|
| 74 | <para>If all is well, Grub will have reported finding its files in
|
---|
[0719866] | 75 | <filename class="directory">/boot/grub</filename>. That's all there is to it:</para>
|
---|
[54ff0b9] | 76 |
|
---|
[21ba4e3] | 77 | <screen><userinput>quit</userinput></screen>
|
---|
[54ff0b9] | 78 |
|
---|
[673b0d8] | 79 | <para>Now we need to create a <quote>menu list</quote> file, defining Grub's
|
---|
| 80 | boot menu:</para>
|
---|
[54ff0b9] | 81 |
|
---|
[0719866] | 82 | <screen><userinput>cat > /boot/grub/menu.lst << "EOF"
|
---|
[1561534] | 83 | # Begin /boot/grub/menu.lst
|
---|
| 84 |
|
---|
[54ff0b9] | 85 | # By default boot the first menu entry.
|
---|
[1561534] | 86 | default 0
|
---|
| 87 |
|
---|
[54ff0b9] | 88 | # Allow 30 seconds before booting the default.
|
---|
[1561534] | 89 | timeout 30
|
---|
| 90 |
|
---|
[54ff0b9] | 91 | # Use prettier colors.
|
---|
[1561534] | 92 | color green/black light-green/black
|
---|
| 93 |
|
---|
[54ff0b9] | 94 | # The first entry is for LFS.
|
---|
[52216a8] | 95 | title LFS &version;
|
---|
[bc362d4] | 96 | root (hd0,3)
|
---|
[eb443a3] | 97 | kernel /boot/lfskernel-&linux-version; root=/dev/hda4
|
---|
[0719866] | 98 | EOF</userinput></screen>
|
---|
[1561534] | 99 |
|
---|
[0719866] | 100 | <note><para>By default, Grub will automatically pass a <parameter>mem=xxx</parameter>
|
---|
[673b0d8] | 101 | command line argument to the kernel. However, Grub occasionally gets the amount
|
---|
| 102 | of memory wrong which can lead to problems in some circumstances. It's best to
|
---|
| 103 | disable this functionality and let the kernel determine the amount of memory
|
---|
[0719866] | 104 | itself, hence the use of the <parameter>--no-mem-option</parameter> above.</para>
|
---|
[673b0d8] | 105 | </note>
|
---|
[1969cea] | 106 |
|
---|
[17476c5] | 107 | <para>You may want to add an entry for your host distribution. It might look
|
---|
[54ff0b9] | 108 | like this:</para>
|
---|
[1561534] | 109 |
|
---|
[0719866] | 110 | <screen><userinput>cat >> /boot/grub/menu.lst << "EOF"
|
---|
[54ff0b9] | 111 | title Red Hat
|
---|
[bc362d4] | 112 | root (hd0,2)
|
---|
[1969cea] | 113 | kernel /boot/kernel-2.4.20 root=/dev/hda3
|
---|
[bc362d4] | 114 | initrd /boot/initrd-2.4.20
|
---|
[0719866] | 115 | EOF</userinput></screen>
|
---|
[1561534] | 116 |
|
---|
| 117 | <para>Also, if you happen to dual-boot Windows, the following entry should
|
---|
| 118 | allow booting it:</para>
|
---|
| 119 |
|
---|
[0719866] | 120 | <screen><userinput>cat >> /boot/grub/menu.lst << "EOF"
|
---|
[bc362d4] | 121 | title Windows
|
---|
| 122 | rootnoverify (hd0,0)
|
---|
| 123 | chainloader +1
|
---|
[0719866] | 124 | EOF</userinput></screen>
|
---|
[1561534] | 125 |
|
---|
[90e3cb3] | 126 | <para>If <command>info grub</command> doesn't tell you all you want to
|
---|
[54ff0b9] | 127 | know, you can find more information regarding Grub on its website, located at:
|
---|
[5cd6caa] | 128 | <ulink url="http://www.gnu.org/software/grub/"/>.</para>
|
---|
[955533b] | 129 |
|
---|
| 130 | </sect1>
|
---|