source: chapter08/grub.xml@ f868dbc6

10.0 10.0-rc1 10.1 10.1-rc1 11.0 11.0-rc1 11.0-rc2 11.0-rc3 11.1 11.1-rc1 11.2 11.2-rc1 11.3 11.3-rc1 12.0 12.0-rc1 12.1 12.1-rc1 7.2 7.3 7.4 7.5 7.5-systemd 7.6 7.6-systemd 7.7 7.7-systemd 7.8 7.8-systemd 7.9 7.9-systemd 8.0 8.1 8.2 8.3 8.4 9.0 9.1 arm bdubbs/gcc13 ml-11.0 multilib renodr/libudev-from-systemd s6-init trunk xry111/arm64 xry111/arm64-12.0 xry111/clfs-ng xry111/lfs-next xry111/loongarch xry111/loongarch-12.0 xry111/loongarch-12.1 xry111/mips64el xry111/pip3 xry111/rust-wip-20221008 xry111/update-glibc
Last change on this file since f868dbc6 was f868dbc6, checked in by Bruce Dubbs <bdubbs@…>, 12 years ago

Correct reference to new BLFS package libisoburn

git-svn-id: http://svn.linuxfromscratch.org/LFS/trunk/BOOK@9840 4aa44e1e-78dd-0310-a6d2-fbcd4c07a689

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