[673b0d8] | 1 | <?xml version="1.0" encoding="ISO-8859-1"?>
|
---|
[b06ca36] | 2 | <!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
|
---|
| 3 | "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
|
---|
[673b0d8] | 4 | <!ENTITY % general-entities SYSTEM "../general.ent">
|
---|
| 5 | %general-entities;
|
---|
| 6 | ]>
|
---|
[b78c747] | 7 |
|
---|
[4e82d47] | 8 | <sect1 id="ch-bootable-grub" role="wrap">
|
---|
[b78c747] | 9 | <?dbhtml filename="grub.html"?>
|
---|
| 10 |
|
---|
[4e82d47] | 11 | <sect1info condition="script">
|
---|
| 12 | <productname>grub</productname>
|
---|
| 13 | <productnumber>&grub-version;</productnumber>
|
---|
| 14 | <address>&grub-url;</address>
|
---|
| 15 | </sect1info>
|
---|
| 16 |
|
---|
[f9bcaec] | 17 | <title>Using GRUB to Set Up the Boot Process</title>
|
---|
[4e82d47] | 18 |
|
---|
[f9bcaec] | 19 | <sect2>
|
---|
| 20 | <title>Introduction</title>
|
---|
[4e82d47] | 21 |
|
---|
[483838e] | 22 | <warning><para>Configuring GRUB incorrectly can render your system
|
---|
| 23 | inoperable without an alternate boot device such as a CD-ROM. This
|
---|
| 24 | section is not required to boot your LFS system. You may just
|
---|
| 25 | want to modify your current boot loader, e.g. Grub-Legacy, GRUB2, or
|
---|
| 26 | LILO.</para></warning>
|
---|
| 27 |
|
---|
| 28 |
|
---|
[f868dbc6] | 29 | <para> Ensure that an emergency boot disk is ready to <quote>rescue</quote>
|
---|
| 30 | the computer if the computer becomes unusable (un-bootable). If you do not
|
---|
| 31 | already have a boot device, you can create one. In order for the procedure
|
---|
| 32 | below to work, you need to jump ahead to BLFS and install
|
---|
| 33 | <userinput>xorriso</userinput> from the <ulink
|
---|
[0ee07e5] | 34 | url="&blfs-book;multimedia/libisoburn.html">
|
---|
[f868dbc6] | 35 | libisoburn</ulink> package.</para>
|
---|
[4e82d47] | 36 |
|
---|
[b304545] | 37 | <screen role="nodump"><userinput>cd /tmp
|
---|
| 38 | grub-mkrescue --output=grub-img.iso
|
---|
[483838e] | 39 | xorriso -as cdrecord -v dev=/dev/cdrw blank=as_needed grub-img.iso</userinput></screen>
|
---|
[1561534] | 40 |
|
---|
[d730742] | 41 | <note><para>Most newer systems now come with system firmware that is in
|
---|
| 42 | UEFI ((Unified Extensible Firmware Interface) mode by default. To boot LFS
|
---|
| 43 | on these systems using the instructions here, the UEFI Mode and Secure Boot
|
---|
| 44 | capabilities need to be turned off. There are ways to boot with these
|
---|
| 45 | capabilities still enabled, but are not covered here. For details, see
|
---|
| 46 | <ulink
|
---|
| 47 | url="http://www.linuxfromscratch.org/hints/downloads/files/lfs-uefi.txt">the
|
---|
| 48 | lfs-uefi.txt hint</ulink> at
|
---|
| 49 | http://www.linuxfromscratch.org/hints/downloads/files/lfs-uefi.txt.</para></note>
|
---|
| 50 |
|
---|
[483838e] | 51 | </sect2>
|
---|
[154c0ce] | 52 |
|
---|
[483838e] | 53 | <sect2>
|
---|
| 54 | <title>GRUB Naming Conventions</title>
|
---|
[1561534] | 55 |
|
---|
[4e82d47] | 56 | <para>GRUB uses its own naming structure for drives and partitions in
|
---|
| 57 | the form of <emphasis>(hdn,m)</emphasis>, where <emphasis>n</emphasis>
|
---|
| 58 | is the hard drive number and <emphasis>m</emphasis> is the partition
|
---|
[920932e] | 59 | number. The hard drive number starts from zero, but the partition number
|
---|
[2ca8941] | 60 | starts from one for normal partitions and five for extended partitions.
|
---|
| 61 | Note that this is different from earlier versions where
|
---|
[f9bcaec] | 62 | both numbers started from zero. For example, partition <filename
|
---|
| 63 | class="partition">sda1</filename> is <emphasis>(hd0,1)</emphasis> to
|
---|
| 64 | GRUB and <filename class="partition">sdb3</filename> is
|
---|
| 65 | <emphasis>(hd1,3)</emphasis>. In contrast to Linux, GRUB does not
|
---|
[4e82d47] | 66 | consider CD-ROM drives to be hard drives. For example, if using a CD
|
---|
| 67 | on <filename class="partition">hdb</filename> and a second hard drive
|
---|
| 68 | on <filename class="partition">hdc</filename>, that second hard drive
|
---|
| 69 | would still be <emphasis>(hd1)</emphasis>.</para>
|
---|
| 70 |
|
---|
[483838e] | 71 | </sect2>
|
---|
| 72 |
|
---|
| 73 | <sect2>
|
---|
| 74 | <title>Setting Up the Configuration</title>
|
---|
| 75 |
|
---|
[2ca8941] | 76 | <para>GRUB works by writing data to the first physical track of the
|
---|
[483838e] | 77 | hard disk. This area is not part of any file system. The programs
|
---|
| 78 | there access GRUB modules in the boot partition. The default location
|
---|
| 79 | is /boot/grub/.</para>
|
---|
| 80 |
|
---|
[f9bcaec] | 81 | <para>The location of the boot partition is a choice of the user that
|
---|
| 82 | affects the configuration. One recommendation is to have a separate small
|
---|
| 83 | (suggested size is 100 MB) partition just for boot information. That way
|
---|
| 84 | each build, whether LFS or some commercial distro, can access the same boot
|
---|
| 85 | files and access can be made from any booted system. If you choose to do
|
---|
| 86 | this, you will need to mount the separate partition, move all files in the
|
---|
| 87 | current <filename class="directory">/boot</filename> directory (e.g. the
|
---|
| 88 | linux kernel you just built in the previous section) to the new partition.
|
---|
| 89 | You will then need to unmount the partition and remount it as <filename
|
---|
| 90 | class="directory">/boot</filename>. If you do this, be sure to update
|
---|
| 91 | <filename>/etc/fstab</filename>.</para>
|
---|
| 92 |
|
---|
| 93 | <para>Using the current lfs partition will also work, but configuration
|
---|
| 94 | for multiple systems is more difficult.</para>
|
---|
| 95 |
|
---|
[4e82d47] | 96 | <para>Using the above information, determine the appropriate
|
---|
| 97 | designator for the root partition (or boot partition, if a separate
|
---|
| 98 | one is used). For the following example, it is assumed that the root
|
---|
| 99 | (or separate boot) partition is <filename
|
---|
[f9bcaec] | 100 | class="partition">sda2</filename>.</para>
|
---|
| 101 |
|
---|
| 102 | <para>Install the GRUB files into <filename
|
---|
[2ca8941] | 103 | class="directory">/boot/grub</filename> and set up the boot track:</para>
|
---|
[f9bcaec] | 104 |
|
---|
[483838e] | 105 | <warning>
|
---|
| 106 | <para>The following command will overwrite the current boot loader. Do not
|
---|
| 107 | run the command if this is not desired, for example, if using a third party
|
---|
[2ca8941] | 108 | boot manager to manage the Master Boot Record (MBR).</para>
|
---|
[483838e] | 109 | </warning>
|
---|
[f9bcaec] | 110 |
|
---|
[483838e] | 111 | <screen role="nodump"><userinput>grub-install /dev/sda</userinput></screen>
|
---|
[f9bcaec] | 112 |
|
---|
[6d53efc] | 113 | <!-- This does not seem to be true any more
|
---|
[2ca8941] | 114 | <note><para><application>grub-install</application> is a script and calls another
|
---|
| 115 | program, grub-probe, that may fail with a message "cannot stat `/dev/root'".
|
---|
[483838e] | 116 | If so, create a temporary symbolic link from your root partition to /dev/root:</para>
|
---|
[f9bcaec] | 117 |
|
---|
[483838e] | 118 | <screen role="nodump"><userinput>ln -sv /dev/sda2 /dev/root</userinput></screen>
|
---|
[f9bcaec] | 119 |
|
---|
[483838e] | 120 | <para>The symbolic link will only be present until the system is rebooted.
|
---|
| 121 | The link is only needed for the installation procedure.
|
---|
| 122 | </para></note>
|
---|
[6d53efc] | 123 | -->
|
---|
[f9bcaec] | 124 | </sect2>
|
---|
| 125 |
|
---|
[bf58c1e] | 126 | <sect2 id="grub-cfg">
|
---|
| 127 | <title>Creating the GRUB Configuration File</title>
|
---|
[1561534] | 128 |
|
---|
[483838e] | 129 | <para>Generate <filename>/boot/grub/grub.cfg</filename>:</para>
|
---|
[1561534] | 130 |
|
---|
[483838e] | 131 | <screen><userinput>cat > /boot/grub/grub.cfg << "EOF"
|
---|
| 132 | <literal># Begin /boot/grub/grub.cfg
|
---|
| 133 | set default=0
|
---|
| 134 | set timeout=5
|
---|
[1561534] | 135 |
|
---|
[483838e] | 136 | insmod ext2
|
---|
| 137 | set root=(hd0,2)
|
---|
[1561534] | 138 |
|
---|
[483838e] | 139 | menuentry "GNU/Linux, Linux &linux-version;-lfs-&version;" {
|
---|
[fe1643e] | 140 | linux /boot/vmlinuz-&linux-version;-lfs-&version; root=/dev/sda2 ro
|
---|
[483838e] | 141 | }</literal>
|
---|
| 142 | EOF</userinput></screen>
|
---|
| 143 |
|
---|
[f48e5aa] | 144 | <note><para>From <application>GRUB</application>'s perspective, the
|
---|
| 145 | kernel files are relative to the partition used. If you
|
---|
| 146 | used a separate /boot partition, remove /boot from the above
|
---|
| 147 | <emphasis>linux</emphasis> line. You will also need to change the
|
---|
| 148 | <emphasis>set root</emphasis> line to point to the boot partition.
|
---|
[2ca8941] | 149 | </para></note>
|
---|
[f48e5aa] | 150 |
|
---|
[483838e] | 151 | <para>GRUB is an extremely powerful program and it provides a tremendous
|
---|
| 152 | number of options for booting from a wide variety of devices, operating
|
---|
[2ca8941] | 153 | systems, and partition types. There are also many options for customization
|
---|
[483838e] | 154 | such as graphical splash screens, playing sounds, mouse input, etc. The
|
---|
| 155 | details of these options are beyond the scope of this introduction.</para>
|
---|
| 156 |
|
---|
[f48e5aa] | 157 | <caution><para>There is a command, <application>grub-mkconfig</application>, that
|
---|
[483838e] | 158 | can write a configuration file automatically. It uses a set of scripts in
|
---|
| 159 | /etc/grub.d/ and will destroy any customizations that you make. These scripts
|
---|
[2ca8941] | 160 | are designed primarily for non-source distributions and are not recommended for
|
---|
| 161 | LFS. If you install a commercial Linux distribution, there is a good chance
|
---|
| 162 | that this program will be run. Be sure to back up your grub.cfg file.</para></caution>
|
---|
[312e7dd] | 163 |
|
---|
[f9bcaec] | 164 | </sect2>
|
---|
[4e82d47] | 165 |
|
---|
[955533b] | 166 | </sect1>
|
---|