source: chapter08/grub.xml@ 8e65a6a3

10.0 10.0-rc1 10.1 10.1-rc1 11.0 11.0-rc1 11.0-rc2 11.0-rc3 8.0 8.0-rc1 8.1 8.1-rc1 8.1-rc2 8.2 8.2-rc1 8.3 8.3-rc1 8.3-rc2 8.4 8.4-rc1 9.0 9.0-rc1 9.1 9.1-rc1 cross-chap5 ml-11.0 multilib old-trunk trunk xry111/git-transition xry111/glibc-2.34 xry111/tester-nohack xry111/usr-move
Last change on this file since 8e65a6a3 was 8e65a6a3, checked in by Bruce Dubbs <bdubbs@…>, 5 years ago

Expand discussion of UEFI in kernel and grub sections

git-svn-id: 4aa44e1e-78dd-0310-a6d2-fbcd4c07a689

  • Property mode set to 100644
File size: 7.8 KB
1<?xml version="1.0" encoding="ISO-8859-1"?>
2<!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
3 "" [
4 <!ENTITY % general-entities SYSTEM "../general.ent">
5 %general-entities;
8<sect1 id="ch-bootable-grub" role="wrap">
9 <?dbhtml filename="grub.html"?>
11 <sect1info condition="script">
12 <productname>grub</productname>
13 <productnumber>&grub-version;</productnumber>
14 <address>&grub-url;</address>
15 </sect1info>
17 <title>Using GRUB to Set Up the Boot Process</title>
19 <sect2>
20 <title>Introduction</title>
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>
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
34 url="&blfs-book;multimedia/libisoburn.html">
35 libisoburn</ulink> package.</para>
37<screen role="nodump"><userinput>cd /tmp
38grub-mkrescue --output=grub-img.iso
39xorriso -as cdrecord -v dev=/dev/cdrw blank=as_needed grub-img.iso</userinput></screen>
41 <note>
42 <para>
43 To boot LFS on host systems that have UEFI enabled, the kernel needs to
44 have been built with the CONFIG_EFI_STUB capabality described in the
45 previous section. However, LFS can be booted using GRUB2 without such
46 an addition. To do this, the UEFI Mode and Secure Boot capabilities in
47 the host system's BIOS need to be turned off. For details, see <ulink
48 url="">
49 the lfs-uefi.txt hint</ulink> at
51 </para>
52 </note>
54 </sect2>
56 <sect2>
57 <title>GRUB Naming Conventions</title>
59 <para>GRUB uses its own naming structure for drives and partitions in
60 the form of <emphasis>(hdn,m)</emphasis>, where <emphasis>n</emphasis>
61 is the hard drive number and <emphasis>m</emphasis> is the partition
62 number. The hard drive number starts from zero, but the partition number
63 starts from one for normal partitions and five for extended partitions.
64 Note that this is different from earlier versions where
65 both numbers started from zero. For example, partition <filename
66 class="partition">sda1</filename> is <emphasis>(hd0,1)</emphasis> to
67 GRUB and <filename class="partition">sdb3</filename> is
68 <emphasis>(hd1,3)</emphasis>. In contrast to Linux, GRUB does not
69 consider CD-ROM drives to be hard drives. For example, if using a CD
70 on <filename class="partition">hdb</filename> and a second hard drive
71 on <filename class="partition">hdc</filename>, that second hard drive
72 would still be <emphasis>(hd1)</emphasis>.</para>
74 </sect2>
76 <sect2>
77 <title>Setting Up the Configuration</title>
79 <para>GRUB works by writing data to the first physical track of the
80 hard disk. This area is not part of any file system. The programs
81 there access GRUB modules in the boot partition. The default location
82 is /boot/grub/.</para>
84 <para>The location of the boot partition is a choice of the user that
85 affects the configuration. One recommendation is to have a separate small
86 (suggested size is 100 MB) partition just for boot information. That way
87 each build, whether LFS or some commercial distro, can access the same boot
88 files and access can be made from any booted system. If you choose to do
89 this, you will need to mount the separate partition, move all files in the
90 current <filename class="directory">/boot</filename> directory (e.g. the
91 linux kernel you just built in the previous section) to the new partition.
92 You will then need to unmount the partition and remount it as <filename
93 class="directory">/boot</filename>. If you do this, be sure to update
94 <filename>/etc/fstab</filename>.</para>
96 <para>Using the current lfs partition will also work, but configuration
97 for multiple systems is more difficult.</para>
99 <para>Using the above information, determine the appropriate
100 designator for the root partition (or boot partition, if a separate
101 one is used). For the following example, it is assumed that the root
102 (or separate boot) partition is <filename
103 class="partition">sda2</filename>.</para>
105 <para>Install the GRUB files into <filename
106 class="directory">/boot/grub</filename> and set up the boot track:</para>
108 <warning>
109 <para>The following command will overwrite the current boot loader. Do not
110 run the command if this is not desired, for example, if using a third party
111 boot manager to manage the Master Boot Record (MBR).</para>
112 </warning>
114<screen role="nodump"><userinput>grub-install /dev/sda</userinput></screen>
116<!-- This does not seem to be true any more
117 <note><para><application>grub-install</application> is a script and calls another
118 program, grub-probe, that may fail with a message "cannot stat `/dev/root'".
119 If so, create a temporary symbolic link from your root partition to /dev/root:</para>
121<screen role="nodump"><userinput>ln -sv /dev/sda2 /dev/root</userinput></screen>
123 <para>The symbolic link will only be present until the system is rebooted.
124 The link is only needed for the installation procedure.
125 </para></note>
127 </sect2>
129 <sect2 id="grub-cfg">
130 <title>Creating the GRUB Configuration File</title>
132 <para>Generate <filename>/boot/grub/grub.cfg</filename>:</para>
134 <screen revision="sysv"><userinput>cat &gt; /boot/grub/grub.cfg &lt;&lt; "EOF"
135<literal># Begin /boot/grub/grub.cfg
136set default=0
137set timeout=5
139insmod ext2
140set root=(hd0,2)
142menuentry "GNU/Linux, Linux &linux-version;-lfs-&version;" {
143 linux /boot/vmlinuz-&linux-version;-lfs-&version; root=/dev/sda2 ro
147 <screen revision="systemd"><userinput>cat &gt; /boot/grub/grub.cfg &lt;&lt; "EOF"
148<literal># Begin /boot/grub/grub.cfg
149set default=0
150set timeout=5
152insmod ext2
153set root=(hd0,2)
155menuentry "GNU/Linux, Linux &linux-version;-lfs-&versiond;" {
156 linux /boot/vmlinuz-&linux-version;-lfs-&versiond; root=/dev/sda2 ro
161 <note><para>From <application>GRUB</application>'s perspective, the
162 kernel files are relative to the partition used. If you
163 used a separate /boot partition, remove /boot from the above
164 <emphasis>linux</emphasis> line. You will also need to change the
165 <emphasis>set root</emphasis> line to point to the boot partition.
166 </para></note>
168 <para>GRUB is an extremely powerful program and it provides a tremendous
169 number of options for booting from a wide variety of devices, operating
170 systems, and partition types. There are also many options for customization
171 such as graphical splash screens, playing sounds, mouse input, etc. The
172 details of these options are beyond the scope of this introduction.</para>
174 <caution><para>There is a command, <application>grub-mkconfig</application>, that
175 can write a configuration file automatically. It uses a set of scripts in
176 /etc/grub.d/ and will destroy any customizations that you make. These scripts
177 are designed primarily for non-source distributions and are not recommended for
178 LFS. If you install a commercial Linux distribution, there is a good chance
179 that this program will be run. Be sure to back up your grub.cfg file.</para></caution>
181 </sect2>
Note: See TracBrowser for help on using the repository browser.