- Timestamp:
- 10/29/2009 05:41:46 AM (15 years ago)
- Branches:
- 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, 6.6, 6.7, 6.8, 7.0, 7.1, 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
- Children:
- b43488e
- Parents:
- 258deb1
- Location:
- chapter08
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
chapter08/grub.xml
r258deb1 rf9bcaec 15 15 </sect1info> 16 16 17 <title>GRUB-&grub-version;</title> 18 19 <indexterm zone="ch-bootable-grub"> 20 <primary sortas="a-Grub">GRUB</primary> 21 </indexterm> 22 23 <sect2 role="package"> 24 <title/> 25 26 <para>The GRUB package contains the GRand Unified Bootloader.</para> 27 28 <segmentedlist> 29 <segtitle>&buildtime;</segtitle> 30 <segtitle>&diskspace;</segtitle> 31 32 <seglistitem> 33 <seg>&grub-ch6-sbu;</seg> 34 <seg>&grub-ch6-du;</seg> 35 </seglistitem> 36 </segmentedlist> 37 38 </sect2> 39 40 <sect2 role="installation"> 41 <title>Installation of GRUB</title> 42 43 <para>Your shiny new LFS system is almost complete. One of the last 44 things to do is to ensure that the system can be properly booted.</para> 45 46 <caution> 47 <para>This package will only build for x86 and x86_64 architectures 48 containing 32-bit libs. If you chose to build on x86_64 without 32-bit 49 libraries (no multilib), then you must use LILO instead. Information on 50 <quote>boot loading</quote> for other architectures should be available in 51 the usual resource-specific locations for those architectures.</para> 52 </caution> 53 54 <para>This package is known to have issues when its default 55 optimization flags (including the <parameter>-march</parameter> and 56 <parameter>-mcpu</parameter> options) are changed. If any environment 57 variables that override default optimizations have been defined, such 58 as <envar>CFLAGS</envar> and <envar>CXXFLAGS</envar>, 59 unset them when building GRUB.</para> 60 61 <para>Start by applying the following patch to allow for better drive 62 detection, fix some GCC 4.x issues, and provide better SATA support 63 for some disk controllers:</para> 64 65 <screen><userinput remap="pre">patch -Np1 -i ../&grub-geometry-patch;</userinput></screen> 66 67 <para>By default, GRUB doesn't support ext2 filesystems with 256-byte inodes. 68 Fix this by applying the following patch:</para> 69 70 <screen><userinput remap="pre">patch -Np1 -i ../&grub-inode-patch;</userinput></screen> 71 72 <para>Prepare GRUB for compilation:</para> 73 74 <screen><userinput remap="configure">./configure --prefix=/usr</userinput></screen> 75 76 <para>Compile the package, but use custom optimization flags to 77 prevent an error flagged in the test routines:</para> 78 79 <screen><userinput remap="make">make CFLAGS="-march=i486 -mtune=native -Os"</userinput></screen> 80 81 <para>To test the results, issue:</para> 82 83 <screen><userinput remap="test">make check</userinput></screen> 84 85 <para>Install the package:</para> 86 87 <screen><userinput remap="install">make install 88 mkdir -v /boot/grub 89 cp -v /usr/lib/grub/i386-pc/stage{1,2} /boot/grub</userinput></screen> 90 91 <para>Replace <filename class="directory">i386-pc</filename> with whatever 92 directory is appropriate for the hardware in use.</para> 93 94 <para>The <filename class="directory">i386-pc</filename> directory 95 contains a number of <filename>*stage1_5</filename> files, different 96 ones for different file systems. Review the files available and copy 97 the appropriate ones to the <filename 98 class="directory">/boot/grub</filename> directory. Most users will 99 copy the <filename>e2fs_stage1_5</filename> and/or 100 <filename>reiserfs_stage1_5</filename> files.</para> 101 102 </sect2> 103 104 <sect2 role="configuration"> 105 <title>Configuring GRUB</title> 106 17 <title>Using GRUB to Set Up the Boot Process</title> 18 19 <sect2> 20 <title>Introduction</title> 107 21 108 22 <para>Boot loading can be a complex area, so a few cautionary … … 114 28 115 29 <para>The procedure involves writing some special GRUB files to specific 116 locations on the hard drive. We highly recommend creating a GRUB boot floppy 117 diskette as a backup. Insert a blank floppy diskette and run the following 118 commands:</para> 119 120 <screen><userinput>dd if=/boot/grub/stage1 of=/dev/fd0 bs=512 count=1 121 dd if=/boot/grub/stage2 of=/dev/fd0 bs=512 seek=1</userinput></screen> 122 123 <para>Remove the diskette and store it somewhere safe. Now, run the 124 <command>grub</command> shell:</para> 125 126 <screen><userinput>grub</userinput></screen> 30 locations on the hard drive. We highly recommend creating a GRUB boot 31 floppy diskette as a backup. Insert a blank floppy diskette and run the 32 following commands:</para> 33 34 <screen role="nodump"><userinput>cd /tmp 35 grub-mkrescue --image-type=floppy floppy.img 36 dd if=floppy.img of =/def/fd0 bs=1440 count=1</userinput></screen> 127 37 128 38 <para>GRUB uses its own naming structure for drives and partitions in 129 39 the form of <emphasis>(hdn,m)</emphasis>, where <emphasis>n</emphasis> 130 40 is the hard drive number and <emphasis>m</emphasis> is the partition 131 number, both starting from zero. For example, partition <filename 132 class="partition">hda1</filename> is <emphasis>(hd0,0)</emphasis> to 133 GRUB and <filename class="partition">hdb3</filename> is 134 <emphasis>(hd1,2)</emphasis>. In contrast to Linux, GRUB does not 41 number. The hard drive number starts from zero, but he partition number 42 starts from one for normal partitions and five for extended partitions. 43 Note that this is different form earlier versions where 44 both numbers started from zero. For example, partition <filename 45 class="partition">sda1</filename> is <emphasis>(hd0,1)</emphasis> to 46 GRUB and <filename class="partition">sdb3</filename> is 47 <emphasis>(hd1,3)</emphasis>. In contrast to Linux, GRUB does not 135 48 consider CD-ROM drives to be hard drives. For example, if using a CD 136 49 on <filename class="partition">hdb</filename> and a second hard drive … … 138 51 would still be <emphasis>(hd1)</emphasis>.</para> 139 52 53 <para>You can determine what GRUB thinks your disk devices are by running:</para> 54 55 <screen role="nodump"><userinput>grub-mkdevicemap --verbose --device-map=device.map 56 cat device.map</userinput></screen> 57 58 <para>The location of the boot partition is a choice of the user that 59 affects the configuration. One recommendation is to have a separate small 60 (suggested size is 100 MB) partition just for boot information. That way 61 each build, whether LFS or some commercial distro, can access the same boot 62 files and access can be made from any booted system. If you choose to do 63 this, you will need to mount the separate partition, move all files in the 64 current <filename class="directory">/boot</filename> directory (e.g. the 65 linux kernel you just built in the previous section) to the new partition. 66 You will then need to unmount the partition and remount it as <filename 67 class="directory">/boot</filename>. If you do this, be sure to update 68 <filename>/etc/fstab</filename>.</para> 69 70 <para>Using the current lfs partition will also work, but configuration 71 for multiple systems is more difficult.</para> 72 </sect2> 73 74 <sect2> 75 <title>Setting Up the Configuration</title> 76 140 77 <para>Using the above information, determine the appropriate 141 78 designator for the root partition (or boot partition, if a separate 142 79 one is used). For the following example, it is assumed that the root 143 80 (or separate boot) partition is <filename 144 class="partition">hda4</filename>.</para> 145 146 <para>Tell GRUB where to search for its 147 <filename>stage{1,2}</filename> files. The Tab key can be used 148 everywhere to make GRUB show the alternatives:</para> 149 150 <screen><userinput>root (hd0,3)</userinput></screen> 81 class="partition">sda2</filename>.</para> 82 83 <para>Install the GRUB files into <filename 84 class="directory">/boot/grub</filename>:</para> 85 86 <screen role="nodump"><userinput>grub-install --grub-setup=/bin/true /dev/sda</userinput></screen> 87 88 <para>We use --grub-setup=/bin/true for now to prevent update the 89 Master Boot Record (MBR). In this way, we can test our installation 90 before committing to a change that is hard to revert.</para> 91 92 <para>Generate <filename>/boot/grub/grub.cfg</filename>:</para> 93 94 <screen role="nodump"><userinput>grub-mkconfig -o /boot/grub/grub.cfg</userinput></screen> 95 96 <para>Here <command>grub-mkconfig</command> uses the files in <filename 97 class="directory">/etc/grub.d/</filename> to determine the contents 98 of this file. The configuration file will look something like:</para> 99 <screen><computeroutput># 100 # DO NOT EDIT THIS FILE 101 # 102 # It is automatically generated by /usr/sbin/grub-mkconfig using templates 103 # from /etc/grub.d and settings from /etc/default/grub 104 # 105 106 ### BEGIN /etc/grub.d/00_header ### 107 set default=0 108 set timeout=5 109 ### END /etc/grub.d/00_header ### 110 111 ### BEGIN /etc/grub.d/10_linux ### 112 menuentry "GNU/Linux, Linux 2.6.30.2-lfs65" { 113 insmod ext2 114 set root=(hd0,2) 115 search --no-floppy --fs-uuid --set 915852a7-859e-45a6-9ff0-d3ebfdb5cea2 116 linux /boot/vmlinux-&linux-version;-lfs-&version; root=/dev/sda2 ro 117 } 118 menuentry "GNU/Linux, Linux 2.6.30.2-lfs65 (recovery mode)" { 119 insmod ext2 120 set root=(hd0,2) 121 search --no-floppy --fs-uuid --set 915852a7-859e-45a6-9ff0-d3ebfdb5cea2 122 linux /boot/vmlinux-&linux-version;-lfs-&version; root=/dev/sda2 ro single 123 } 124 menuentry "GNU/Linux, Linux 2.6.28-11-server" { 125 insmod ext2 126 set root=(hd0,2) 127 search --no-floppy --fs-uuid --set 6b4c0339-5501-4a85-8351-e398e5252be8 128 linux /boot/vmlinuz-2.6.28-11-server root=UUID=6b4c0339-5501-4a85-8351-e398e5252be8 ro 129 initrd /boot/initrd.img-2.6.28-11-server 130 } 131 menuentry "GNU/Linux, Linux 2.6.28-11-server (recovery mode)" { 132 insmod ext2 133 set root=(hd0,2) 134 search --no-floppy --fs-uuid --set 6b4c0339-5501-4a85-8351-e398e5252be8 135 linux /boot/vmlinuz-2.6.28-11-server root=UUID=6b4c0339-5501-4a85-8351-e398e5252be8 ro single 136 initrd /boot/initrd.img-2.6.28-11-server 137 } 138 ### END /etc/grub.d/10_linux ### 139 140 ### BEGIN /etc/grub.d/30_os-prober ### 141 ### END /etc/grub.d/30_os-prober ### 142 143 ### BEGIN /etc/grub.d/40_custom ### 144 # This file provides an easy way to add custom menu entries. Simply type the 145 # menu entries you want to add after this comment. Be careful not to change 146 # the 'exec tail' line above. 147 ### END /etc/grub.d/40_custom ### 148 </computeroutput></screen> 149 150 <para>Note that even though there is a warning not to edit the file, you can 151 do so as long as you do not re-reun <command>grub-mkconfig</command>. The 152 <emphasis>search</emphasis> lines are not meaningful for LFS systems as that 153 command needs an initrd image for processing. If installing on a separate 154 partition the linux and initrd lines will not have the /boot on the file 155 names. In this example the kernel files for a Ubuntu installation are 156 also found in <filename class="directory">/boot</filename>.</para> 157 158 </sect2> 159 160 <sect2> 161 <title>Testing the Configuration</title> 162 163 <para>The core image of GRUB is also a Multiboot kernel, so if you already 164 have GRUB Legacy loaded you can load GRUB-&grub-version; through your old 165 boot loader. To accomplish this, you will need to exit the 166 <command>chroot</command> environment and re-enter it to finish the 167 few remaining portions of the book.</para> 168 169 <screen role="nodump"><userinput>/sbin/reboot 170 ... 171 grub> root (hd0,1) 172 grub> kernel /boot/grub/core.img 173 grub> boot</userinput></screen> 174 175 <para>Note that the GRUB commands above are assumed to be GRUB Legacy. 176 At this point the GRUB prompt will appear (very similar to GRUB Legacy) and 177 you can explore the interface or boot to one of the systems in the grub.cfg 178 file.</para> 179 180 </sect2> 181 182 <sect2> 183 <title>Updating the Master Boot Record</title> 184 185 <para>If you tested the GRUB configuration as specified above, re-enter 186 the <command>chroot</command> envronment.</para> 151 187 152 188 <warning> 153 189 <para>The following command will overwrite the current boot loader. Do not 154 190 run the command if this is not desired, for example, if using a third party 155 boot manager to manage the Master Boot Record (MBR). In this scenario, it 156 would make more sense to install GRUB into the <quote>boot sector</quote> 157 of the LFS partition. In this case, this next command would become 158 <userinput>setup (hd0,3)</userinput>.</para> 191 boot manager to manage the Master Boot Record (MBR).</para> 159 192 </warning> 160 193 161 <para>Tell GRUB to install itself into the MBR of 162 <filename class="partition">hda</filename>:</para> 163 164 <screen><userinput>setup (hd0)</userinput></screen> 165 166 <para>If all went well, GRUB will have reported finding its files in 167 <filename class="directory">/boot/grub</filename>. That's all there is 168 to it. Quit the <command>grub</command> shell:</para> 169 170 <screen><userinput>quit</userinput></screen> 171 172 <para>Create a <quote>menu list</quote> file defining GRUB's boot menu:</para> 173 174 <screen><userinput>cat > /boot/grub/menu.lst << "EOF" 175 <literal># Begin /boot/grub/menu.lst 176 177 # By default boot the first menu entry. 178 default 0 179 180 # Allow 30 seconds before booting the default. 181 timeout 30 182 183 # Use prettier colors. 184 color green/black light-green/black 185 186 # The first entry is for LFS. 187 title LFS &version; 188 root (hd0,3) 189 kernel /boot/lfskernel-&linux-version; root=/dev/hda4</literal> 190 EOF</userinput></screen> 191 192 <para>Add an entry for the host distribution if desired. It might look 193 like this:</para> 194 195 <screen><userinput>cat >> /boot/grub/menu.lst << "EOF" 196 <literal>title Red Hat 197 root (hd0,2) 198 kernel /boot/kernel-2.6.5 root=/dev/hda3 199 initrd /boot/initrd-2.6.5</literal> 200 EOF</userinput></screen> 201 202 <para>If dual-booting Windows, the following entry will allow 203 booting it:</para> 204 205 <screen><userinput>cat >> /boot/grub/menu.lst << "EOF" 206 <literal>title Windows 207 rootnoverify (hd0,0) 208 chainloader +1</literal> 209 EOF</userinput></screen> 210 211 <para>If <command>info grub</command> does not provide all necessary material, 212 additional information regarding GRUB is located on its website at: 213 <ulink url="http://www.gnu.org/software/grub/"/>.</para> 214 215 <para>The FHS stipulates that GRUB's <filename>menu.lst</filename> file should 216 be symlinked to <filename class="symlink">/etc/grub/menu.lst</filename>. To 217 satisfy this requirement, issue the following command:</para> 218 219 <screen><userinput>mkdir -v /etc/grub 220 ln -sv /boot/grub/menu.lst /etc/grub</userinput></screen> 221 222 </sect2> 223 224 <sect2 id="contents-gRUB" role="content"> 225 <title>Contents of GRUB</title> 226 227 <segmentedlist> 228 <segtitle>Installed programs</segtitle> 229 230 <seglistitem> 231 <seg>grub, grub-install, grub-md5-crypt, grub-set-default, 232 grub-terminfo, and mbchk</seg> 233 </seglistitem> 234 </segmentedlist> 235 236 <variablelist> 237 <bridgehead renderas="sect3">Short Descriptions</bridgehead> 238 <?dbfo list-presentation="list"?> 239 <?dbhtml list-presentation="table"?> 240 241 <varlistentry id="grub"> 242 <term><command>grub</command></term> 243 <listitem> 244 <para>The Grand Unified Bootloader's command shell</para> 245 <indexterm zone="ch-bootable-grub grub"> 246 <primary sortas="b-grub">grub</primary> 247 </indexterm> 248 </listitem> 249 </varlistentry> 250 251 <varlistentry id="grub-install"> 252 <term><command>grub-install</command></term> 253 <listitem> 254 <para>Installs GRUB on the given device</para> 255 <indexterm zone="ch-bootable-grub grub-install"> 256 <primary sortas="b-grub-install">grub-install</primary> 257 </indexterm> 258 </listitem> 259 </varlistentry> 260 261 <varlistentry id="grub-md5-crypt"> 262 <term><command>grub-md5-crypt</command></term> 263 <listitem> 264 <para>Encrypts a password in MD5 format</para> 265 <indexterm zone="ch-bootable-grub grub-md5-crypt"> 266 <primary sortas="b-grub-md5-crypt">grub-md5-crypt</primary> 267 </indexterm> 268 </listitem> 269 </varlistentry> 270 271 <varlistentry id="grub-set-default"> 272 <term><command>grub-set-default</command></term> 273 <listitem> 274 <para>Sets the default boot entry for GRUB</para> 275 <indexterm zone="ch-bootable-grub grub-set-default"> 276 <primary sortas="b-grub-set-default">grub-set-default</primary> 277 </indexterm> 278 </listitem> 279 </varlistentry> 280 281 <varlistentry id="grub-terminfo"> 282 <term><command>grub-terminfo</command></term> 283 <listitem> 284 <para>Generates a terminfo command from a terminfo name; it can be 285 employed if an unknown terminal is being used</para> 286 <indexterm zone="ch-bootable-grub grub-terminfo"> 287 <primary sortas="b-grub-terminfo">grub-terminfo</primary> 288 </indexterm> 289 </listitem> 290 </varlistentry> 291 292 <varlistentry id="mbchk"> 293 <term><command>mbchk</command></term> 294 <listitem> 295 <para>Checks the format of a multi-boot kernel</para> 296 <indexterm zone="ch-bootable-grub mbchk"> 297 <primary sortas="b-mbchk">mbchk</primary> 298 </indexterm> 299 </listitem> 300 </varlistentry> 301 302 </variablelist> 303 304 </sect2> 194 <para>Update the MBR with:</para> 195 196 <screen role="nodump"><userinput>grub-setup</userinput></screen> 197 198 <para>This program uses the following defaults and are correct if you did not 199 deviate from the instructions above:</para> 200 201 <itemizedlist> 202 <listitem><para>boot image - boot.img </para></listitem> 203 <listitem><para>core image - core.img </para></listitem> 204 <listitem><para>directory - /boot/grub</para></listitem> 205 <listitem><para>device map - device.map</para></listitem> 206 <listitem><para>root device - guessed </para></listitem> 207 </itemizedlist> 208 209 </sect2> 305 210 306 211 </sect1> -
chapter08/kernel.xml
r258deb1 rf9bcaec 116 116 the <filename class="directory">/boot</filename> directory.</para> 117 117 118 <para>The path to the kernel image may vary depending on the platform 119 being used. The following command assumes an x86 architecture:</para> 120 121 <screen><userinput remap="install">cp -v arch/x86/boot/bzImage /boot/lfskernel-&linux-version;</userinput></screen> 118 <para>The path to the kernel image may vary depending on the platform being 119 used. The filename below can be changed to suit your taste, but the stem of 120 the filename should be <emphasis>vmlinux</emphasis> to be compatible with 121 the automatic setup of the boot process described in the next section. The 122 following command assumes an x86 architecture:</para> 123 124 <screen><userinput remap="install">cp -v arch/x86/boot/bzImage /boot/vmlinux-&linux-version;-lfs-&version;</userinput></screen> 122 125 123 126 <para><filename>System.map</filename> is a symbol file for the kernel.
Note:
See TracChangeset
for help on using the changeset viewer.