Editorial review of boot stages.

Format loader built-in commands as a table.
More commits to come.

Sponsored by:	iXsystems
This commit is contained in:
Dru Lavigne 2014-04-21 22:51:01 +00:00
parent 1179ed2018
commit b702784517
Notes: svn2git 2020-12-08 03:00:23 +00:00
svn path=/head/; revision=44623

View file

@ -173,18 +173,13 @@
<indexterm><primary>Master Boot Record
(<acronym>MBR</acronym>)</primary></indexterm>
<para>The code in the <acronym>MBR</acronym> or boot manager is
<para>The boot manager code in the <acronym>MBR</acronym> is
sometimes referred to as <emphasis>stage zero</emphasis> of the
boot process. This section discusses two boot managers:
<application>boot0</application> and
<application>LILO</application>.</para>
boot process. By default, &os; uses the
<application>boot0</application> boot manager.</para>
<formalpara>
<title>The <application>boot0</application> Boot
Manager:</title>
<para>The <acronym>MBR</acronym> installed by &os;'s installer
or &man.boot0cfg.8; is based on
<para>The <acronym>MBR</acronym> installed by the &os; installer
is based on
<filename>/boot/boot0</filename>. The size and capability of
<application>boot0</application> is restricted to 446 bytes
due to the slice table and <literal>0x55AA</literal>
@ -192,7 +187,6 @@
<application>boot0</application> and multiple operating
systems are installed, a message similar to this example will
be displayed at boot time:</para>
</formalpara>
<example xml:id="boot-boot0-example">
<title><filename>boot0</filename> Screenshot</title>
@ -203,7 +197,7 @@ F2 FreeBSD
Default: F2</screen>
</example>
<para>Other operating systems, in particular &windows;, will
<para>Other operating systems will
overwrite an existing <acronym>MBR</acronym> if they are
installed after &os;. If this happens, or to replace the
existing <acronym>MBR</acronym> with the &os;
@ -219,65 +213,37 @@ Default: F2</screen>
for the first <acronym>SCSI</acronym> disk. To create a
custom configuration of the <acronym>MBR</acronym>, refer to
&man.boot0cfg.8;.</para>
<formalpara>
<title>The LILO Boot Manager:</title>
<para>To install this boot manager so it will also boot &os;,
boot into Linux and add the following to the existing
<filename>/etc/lilo.conf</filename> configuration:</para>
</formalpara>
<programlisting>other=/dev/hdXY
table=/dev/hdX
loader=/boot/chain.b
label=FreeBSD</programlisting>
<para>Specify &os;'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. For a <acronym>SCSI</acronym>
drive, change <replaceable>/dev/hd</replaceable> to
<replaceable>/dev/sd</replaceable>. The
<option>loader=/boot/chain.b</option> line can be omitted if
both operating systems are installed on the same drive. Next,
run <command>/sbin/lilo&nbsp;-v</command> to commit the new
changes. Verify these are correct by checking the screen
messages.</para>
</sect2>
<sect2 xml:id="boot-boot1">
<title>Stage One and Stage Two</title>
<para>Conceptually, the first and second stages are part of the
same program, on the same area of the disk. Because of space
same program on the same area of the disk. Because of space
constraints, they have been split into two, but are always
installed together. They are copied from the combined
<filename>/boot/boot</filename> by the installer or
&man.bsdlabel.8;.</para>
<filename>/boot/boot</filename> by the &os; installer or
<command>bsdlabel</command>.</para>
<para>They are located outside file systems, in the first track
<para>These two stages are located outside file systems, in the first track
of the boot slice, starting with the first sector. This is
where boot0 (<xref linkend="boot-boot0"/>), or any other
where <application>boot0</application>, 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>
continue the boot process.</para>
<para><filename>boot1</filename> is very simple, since it can
only be 512 bytes in size, and knows just enough about the
<para>The first stage, <filename>boot1</filename>, is very simple, since it can
only be 512 bytes in size. It knows just enough about the
&os; <firstterm>bsdlabel</firstterm>, which stores
information about the slice, to find and execute
<filename>boot2</filename>.</para>
<para><filename>boot2</filename> is slightly more sophisticated,
and understands the &os; file system enough to find files, and
<para>Stage two, <filename>boot2</filename>, is slightly more sophisticated,
and understands the &os; file system enough to find files. It
can provide a simple interface to choose the kernel or loader
to run.</para>
<para>However, &man.loader.8; is much more sophisticated and
provides a boot configuration which is run by
<filename>boot2</filename>.</para>
to run. It runs <application>loader</application>, which is much more sophisticated and
provides a boot configuration file. If the boot process is
interrupted at stage two, the following interactive screen is
displayed:</para>
<example xml:id="boot-boot2-example">
<title><filename>boot2</filename> Screenshot</title>
@ -287,26 +253,23 @@ Default: 0:ad(0,a)/boot/loader
boot:</screen>
</example>
<para>&man.bsdlabel.8; can be used to replace the installed
<para>To replace the installed
<filename>boot1</filename> and
<filename>boot2</filename>:</para>
<filename>boot2</filename>, use <command>bsdlabel</command>,
where <replaceable>diskslice</replaceable> is the disk and
slice to boot from, such as <filename>ad0s1</filename>
for the first slice on the first <acronym>IDE</acronym>
disk:</para>
<screen>&prompt.root; <userinput>bsdlabel -B <replaceable>diskslice</replaceable></userinput></screen>
<para>where <replaceable>diskslice</replaceable> is the disk and
slice to boot from, such as <filename>ad0s1</filename>
for the first slice on the first <acronym>IDE</acronym>
disk.</para>
<warning>
<title>Dangerously Dedicated Mode</title>
<para>If just the disk name is used, such as
<filename>ad0</filename>, &man.bsdlabel.8; will create a
<quote>dangerously dedicated</quote> disk, without slices.
<filename>ad0</filename>, <command>bsdlabel</command> will create the disk in
<quote>dangerously dedicated mode</quote>, without slices.
This is probably not the desired action, so double check the
<replaceable>diskslice</replaceable> passed to
&man.bsdlabel.8; before pressing
<replaceable>diskslice</replaceable>
before pressing
<keycap>Return</keycap>.</para>
</warning>
</sect2>
@ -316,16 +279,16 @@ boot:</screen>
<indexterm><primary>boot-loader</primary></indexterm>
<para>The loader is the final stage of the three-stage
bootstrap, and is located on the file system, usually as
<para>The <application>loader</application> is the final stage of the three-stage
bootstrap process. It is located on the file system, usually as
<filename>/boot/loader</filename>.</para>
<para>The loader is intended as an interactive method for
<para>The <application>loader</application> is intended as an interactive method for
configuration, using a built-in command set, backed up by a
more powerful interpreter which has a more complex command
set.</para>
<para>During initialization, the loader will probe for a
<para>During initialization, <application>loader</application> will probe for a
console and for disks, and figure out which disk it is
booting from. It will set variables accordingly, and an
interpreter is started where user commands can be passed from
@ -334,7 +297,7 @@ boot:</screen>
<indexterm><primary>loader</primary></indexterm>
<indexterm><primary>loader configuration</primary></indexterm>
<para>The loader will then read
<para>The <application>loader</application> will then read
<filename>/boot/loader.rc</filename>, which by default reads
in <filename>/boot/defaults/loader.conf</filename> which sets
reasonable defaults for variables and reads
@ -343,166 +306,135 @@ boot:</screen>
these variables, loading whichever modules and kernel are
selected.</para>
<para>Finally, by default, the loader issues a 10 second wait
<para>Finally, by default, <application>loader</application> issues a 10 second wait
for key presses, and boots the kernel if it is not
interrupted. If interrupted, the user is presented with a
prompt which understands the command set, where the user may
adjust variables, unload all modules, load modules, and then
finally boot or reboot.</para>
finally boot or reboot. <xref
linkend="boot-loader-commands"/> lists the most
commonly used <application>loader</application> commands. For
a complete discussion of all available commands, refer to
&man.loader.8;.</para>
<sect3 xml:id="boot-loader-commands">
<table xml:id="boot-loader-commands" frame="none" pgwide="1">
<title>Loader Built-In Commands</title>
<para>These are the most commonly used loader commands. For a
complete discussion of all available commands, refer to
&man.loader.8;.</para>
<variablelist>
<varlistentry>
<term>autoboot <replaceable>seconds</replaceable></term>
<listitem>
<para>Proceeds to boot the kernel if not interrupted
<tgroup cols="2">
<thead>
<row>
<entry>Variable</entry>
<entry>Description</entry>
</row>
</thead>
<tbody>
<row>
<entry>autoboot <replaceable>seconds</replaceable></entry>
<entry>Proceeds to boot the kernel if not interrupted
within the time span given, in seconds. It displays a
countdown, and the default time span is 10
seconds.</para>
</listitem>
</varlistentry>
seconds.</entry>
</row>
<varlistentry>
<term>boot
<row>
<entry>boot
<optional><replaceable>-options</replaceable></optional>
<optional><replaceable>kernelname</replaceable></optional></term>
<listitem>
<para>Immediately proceeds to boot the kernel, with any
<optional><replaceable>kernelname</replaceable></optional></entry>
<entry>Immediately proceeds to boot the kernel, with any
specified options or kernel name. Providing a kernel
name on the command-line is only applicable after an
<emphasis>unload</emphasis> command has been issued;
otherwise the previously-loaded kernel will be
used.</para>
</listitem>
</varlistentry>
<command>unload</command> has been issued.
Otherwise the previously-loaded kernel will be
used.</entry>
</row>
<varlistentry>
<term>boot-conf</term>
<listitem>
<para>Goes through the same automatic configuration of
<row>
<entry>boot-conf</entry>
<entry>Goes through the same automatic configuration of
modules based on specified variables, most commonly
<envar>kernel</envar>. This only makes sense if
<command>unload</command> is used first, before
changing some variables.</para>
</listitem>
</varlistentry>
changing some variables.</entry>
</row>
<varlistentry>
<term>help
<optional><replaceable>topic</replaceable></optional></term>
<listitem>
<para>Shows help messages read from
<row>
<entry>help
<optional><replaceable>topic</replaceable></optional></entry>
<entry>Shows help messages read from
<filename>/boot/loader.help</filename>. If the topic
given is <literal>index</literal>, the list of
available topics is displayed.</para>
</listitem>
</varlistentry>
available topics is displayed.</entry>
</row>
<varlistentry>
<term>include <replaceable>filename</replaceable>
&hellip;</term>
<row>
<entry>include <replaceable>filename</replaceable>
&hellip;</entry>
<entry>Reads the specified file and interprets it line by line. An
error immediately stops the <command>include</command>.</entry>
</row>
<listitem>
<para>Processes the file with the given filename. The
file is read in and interpreted line by line. An
error immediately stops the include command.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>load <optional>-t
<row>
<entry>load <optional>-t
<replaceable>type</replaceable></optional>
<replaceable>filename</replaceable></term>
<listitem>
<para>Loads the kernel, kernel module, or file of the
<replaceable>filename</replaceable></entry>
<entry>Loads the kernel, kernel module, or file of the
type given, with the specified filename. Any
arguments after <replaceable>filename</replaceable>
are passed to the file.</para>
</listitem>
</varlistentry>
are passed to the file.</entry>
</row>
<varlistentry>
<term>ls <optional>-l</optional>
<optional><replaceable>path</replaceable></optional></term>
<listitem>
<para>Displays a listing of files in the given path, or
<row>
<entry>ls <optional>-l</optional>
<optional><replaceable>path</replaceable></optional></entry>
<entry>Displays a listing of files in the given path, or
the root directory, if the path is not specified. If
<option>-l</option> is specified, file sizes will
also be shown.</para>
</listitem>
</varlistentry>
also be shown.</entry>
</row>
<varlistentry>
<term>lsdev
<optional>-v</optional></term>
<listitem>
<para>Lists all of the devices from which it may be
<row>
<entry>lsdev
<optional>-v</optional></entry>
<entry>Lists all of the devices from which it may be
possible to load modules. If <option>-v</option> is
specified, more details are printed.</para>
</listitem>
</varlistentry>
specified, more details are printed.</entry>
</row>
<varlistentry>
<term>lsmod
<optional>-v</optional></term>
<row>
<entry>lsmod
<optional>-v</optional></entry>
<entry>Displays loaded modules. If <option>-v</option>
is specified, more details are shown.</entry>
</row>
<listitem>
<para>Displays loaded modules. If <option>-v</option>
is specified, more details are shown.</para>
</listitem>
</varlistentry>
<row>
<entry>more <replaceable>filename</replaceable></entry>
<entry>Displays the files specified, with a pause at each
<varname>LINES</varname> displayed.</entry>
</row>
<varlistentry>
<term>more <replaceable>filename</replaceable></term>
<row>
<entry>reboot</entry>
<entry>Immediately reboots the system.</entry>
</row>
<listitem>
<para>Displays the files specified, with a pause at each
<varname>LINES</varname> displayed.</para>
</listitem>
</varlistentry>
<row>
<entry>set <replaceable>variable</replaceable>, set
<replaceable>variable</replaceable>=<replaceable>value</replaceable></entry>
<entry>Sets the specified environment variables.</entry>
</row>
<varlistentry>
<term>reboot</term>
<row>
<entry>unload</entry>
<entry>Removes all loaded modules.</entry>
</row>
</tbody>
</tgroup>
</table>
</sect2>
<listitem>
<para>Immediately reboots the system.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>set <replaceable>variable</replaceable></term>
<term>set
<replaceable>variable</replaceable>=<replaceable>value</replaceable></term>
<listitem>
<para>Sets the loader's environment variables.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>unload</term>
<listitem>
<para>Removes all loaded modules.</para>
</listitem>
</varlistentry>
</variablelist>
</sect3>
<sect3 xml:id="boot-loader-examples">
<sect2 xml:id="boot-loader-examples">
<title>Loader Examples</title>
<para>Here are some practical examples of loader usage:</para>
@ -547,7 +479,6 @@ boot:</screen>
<screen><userinput>load -t userconfig_script <replaceable>/boot/kernel.conf</replaceable></userinput></screen>
</listitem>
</itemizedlist>
</sect3>
</sect2>
<sect2 xml:id="boot-kernel">