Overhauled discussions of boot managers, adding some details.

Approved by:    keramida (mentor)
This commit is contained in:
Gary W. Swearingen 2005-10-01 21:54:12 +00:00
parent cb1e6a96b9
commit ae4003ac85
Notes: svn2git 2020-12-08 03:00:23 +00:00
svn path=/head/; revision=25782

View file

@ -71,32 +71,47 @@
load the operating system, which has become shortened to
<quote>booting</quote>.</para>
<indexterm><primary>BIOS</primary></indexterm>
<indexterm><primary>Basic Input/Output System</primary><see>BIOS</see></indexterm>
<para>On x86 hardware the Basic Input/Output System (BIOS) is responsible
for loading the operating system. To do this, the BIOS looks on the
hard disk for the Master Boot Record (MBR), which must be located on a
specific place on the disk. The BIOS has enough knowledge to load and
run the MBR, and assumes that the MBR can then carry out the rest of the
tasks involved in loading the operating system.</para>
tasks involved in loading the operating system,
possibly with the help of the BIOS.</para>
<indexterm>
<primary>BIOS</primary>
</indexterm>
<indexterm><primary>Master Boot Record (MBR)</primary></indexterm>
<indexterm>
<primary>Basic Input/Output System</primary>
<see>BIOS</see>
</indexterm>
<indexterm><primary>Boot Manager</primary></indexterm>
<para>If you only have one operating system installed on your disks then
the standard MBR will suffice. This MBR searches for the first bootable
slice on the disk, and then runs the code on that slice to load the
remainder of the operating system.</para>
<indexterm><primary>Boot Loader</primary></indexterm>
<para>The code within the MBR is usually referred to as a <emphasis>boot
manager</emphasis>, especially when it interacts with the user. In this case
the boot manager usually has more code in the first
<emphasis>track</emphasis> of the disk or within some OS's file system. (A
boot manager is sometimes also called a <emphasis>boot loader</emphasis>,
but FreeBSD uses that term for a later stage of booting.) Popular boot
managers include <application>boot0</application> (a.k.a. <application>Boot
Easy</application>, the standard &os; boot manager),
<application>Grub</application>, <application>GAG</application>, and
<application>LILO</application>.
(Only <application>boot0</application> fits within the MBR.)</para>
<para>If you have only one operating system installed on your disks then
a standard PC MBR will suffice. This MBR searches for the first bootable
(a.k.a. active) slice on the disk, and then runs the code on that slice to
load the remainder of the operating system. The MBR installed by
&man.fdisk.8;, by default, is such an MBR. It is based on
<filename>/boot/mbr</filename>.</para>
<para>If you have installed multiple operating systems on your disks then
you can install a different MBR, one that can display a list of
you can install a different boot manager, one that can display a list of
different operating systems, and allows you to choose the one to boot
from. FreeBSD comes with one such MBR which can be installed, and other
operating system vendors also provide alternative MBRs.</para>
from. Two of these are discussed in the next subsection.</para>
<para>The remainder of the FreeBSD bootstrap system is divided into three
stages. The first stage is run by the MBR, which knows just enough to
@ -122,28 +137,28 @@
</sect1>
<sect1 id="boot-blocks">
<title>The MBR, and Boot Stages One, Two, and Three</title>
<title>The Boot Manager and Boot Stages</title>
<indexterm><primary>Boot Manager</primary></indexterm>
<sect2 id="boot-boot0">
<title>MBR, <filename>/boot/boot0</filename></title>
<title>The Boot Manager</title>
<indexterm><primary>Master Boot Record (MBR)</primary></indexterm>
<para>The MBR installed by FreeBSD's installer and by boot0cfg(8)
are based on <filename>/boot/boot0</filename>. The MBR is the first
sector of a disk, outside slices. (The MBR installed by fdisk(8),
by default, is based on <filename>/boot/mbr</filename>; it is
similar to the PC-DOS MBR and it boots the slice marked
<emphasis>active</emphasis> without prompting the user as the
FreeBSD MBR does.)
<para>The code in the MBR or boot manager is sometimes referred to as
<emphasis>stage zero</emphasis> of the boot process. This subsection
discusses two of the boot managers previously mentioned:
<application>boot0</application> and <application>LILO</application>.</para>
<para><filename>boot0</filename> is very simple, since the
program in the <abbrev>MBR</abbrev> can only be 512 bytes in
size.
(Actually, it can only be 446 bytes because of the slice
table and the 0x55AA identifier at the end of the MBR).
If you have installed the FreeBSD MBR and have installed
multiple operating systems on your hard disks then you will see a
display similar to this one at boot time:</para>
<formalpara><title>The <application>boot0</application> Boot Manager:</title>
<para>The MBR installed by FreeBSD's installer or &man.boot0cfg.8;, by
default, is based on <filename>/boot/boot0</filename>.
(The <application>boot0</application> program is very simple, since the
program in the <abbrev>MBR</abbrev> can only be 446 bytes long because of the slice
table and 0x55AA identifier at the end of the MBR.)
If you have installed <application>boot0</application> and
multiple operating systems on your hard disks, then you will see a
display similar to this one at boot time:</para></formalpara>
<example id="boot-boot0-example">
<title><filename>boot0</filename> Screenshot</title>
@ -164,38 +179,34 @@ Default: F2</screen>
<screen>&prompt.root; <userinput>fdisk -B -b /boot/boot0 <replaceable>device</replaceable></userinput></screen>
<para>Where <replaceable>device</replaceable> is the device that you
<para>where <replaceable>device</replaceable> is the device that you
boot from, such as <devicename>ad0</devicename> for the first IDE
disk, <devicename>ad2</devicename> for the first IDE disk on a second
IDE controller, <devicename>da0</devicename> for the first SCSI disk,
and so on.</para>
and so on. Or, if you want a custom configuration of the MBR,
use &man.boot0cfg.8;.</para>
<para>If you are a Linux user, however, and prefer that
<application>LILO</application> control the boot process, you can
edit the <filename>/etc/lilo.conf</filename> file for FreeBSD, or
select <option>Leave The Master Boot Record Untouched</option>
during the FreeBSD installation process. If you have installed the
FreeBSD boot manager, you can boot back into Linux and modify the
<application>LILO</application> configuration file
<filename>/etc/lilo.conf</filename> and add the following
option:</para>
<formalpara><title>The LILO Boot Manager:</title>
<para>To install this boot manager so it will also boot FreeBSD, first
start Linux and add the following to your existing
<filename>/etc/lilo.conf</filename> configuration file:</para>
<programlisting>other=/dev/hdXY
table=/dev/hdb
table=/dev/hdX
loader=/boot/chain.b
label=FreeBSD</programlisting>
<para>which will permit the booting of FreeBSD and Linux via
<application>LILO</application>. In our example, we use
<replaceable>XY</replaceable> to determine drive number and
partition. If you are using a <acronym>SCSI</acronym> drive, you
will want to change <replaceable>/dev/hdXY</replaceable> to read
something similar to <replaceable>/dev/sdXY</replaceable>, which
again uses the <replaceable>XY</replaceable> syntax. The
<option>loader=/boot/chain.b</option> can be omitted if you have
both operating systems on the same drive. You can now run
<command>/sbin/lilo -v</command> to commit your new changes to the
system, this should be verified with screen messages.</para>
<para>In the above, specify FreeBSD's primary partition and drive using
Linux specifiers, replacing <replaceable>X</replaceable> with the Linux
drive letter and <replaceable>Y</replaceable> with the Linux primary
partition number. If you are using a <acronym>SCSI</acronym> drive, you
will need to change <replaceable>/dev/hd</replaceable> to read something
similar to <replaceable>/dev/sd</replaceable>. The
<option>loader=/boot/chain.b</option> line can be omitted if you have
both operating systems on the same drive. Now run
<command>/sbin/lilo&nbsp;-v</command> to commit your new changes to the
system; this should be verified by checking its screen messages.</para>
</sect2>
<sect2 id="boot-boot1">
@ -205,17 +216,18 @@ label=FreeBSD</programlisting>
<para>Conceptually the first and second stages are part of the same
program, on the same area of the disk. Because of space constraints
they have been split into two, but you would always install them
together.</para>
together. They are copied from the combined file
<filename>/boot/boot</filename> by the installer or
<application>disklabel</application> (see below).</para>
<para>They are found on the boot sector of
the boot slice, which is where <link
linkend="boot-boot0">boot0</link>, or any other program on the
<abbrev>MBR</abbrev> expects to find the program to run to
continue the boot process. The files in the
<filename>/boot</filename> directory are copies of the real files,
which are stored outside of the FreeBSD file system.</para>
<para>They are located outside file systems, in the first track of
the boot slice, starting with the first sector. This is where <link
linkend="boot-boot0">boot0</link>, or any other boot manager,
expects to find a program to run which will
continue the boot process. The number of sectors used is easily
determined from the size of <filename>/boot/boot</filename>.</para>
<para><filename>boot1</filename> is very simple, since it too
<para><filename>boot1</filename> is very simple, since it
can only be 512 bytes
in size, and knows just enough about the FreeBSD
<firstterm>disklabel</firstterm>, which stores information