source: chapter08/grub.xml@ 673b0d8

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.0 6.1 6.1.1 6.3 6.4 6.5 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 v5_1 v5_1_1 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 673b0d8 was 673b0d8, checked in by Matthew Burgess <matthew@…>, 20 years ago
  • Merged newxml into HEAD

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

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