<?xml version="1.0" encoding="UTF-8"?>
<!--
.... Copyright (c) 1980, 1991, 1993
....	The Regents of the University of California.  All rights reserved.
....
.... Rewritten by Jonathan de Boyne Pollard.
.... 
.... Redistribution and use in source and binary forms, with or without
.... modification, are permitted provided that the following conditions
.... are met:
.... 1. Redistributions of source code must retain the above copyright
....    notice, this list of conditions and the following disclaimer.
.... 2. Redistributions in binary form must reproduce the above copyright
....    notice, this list of conditions and the following disclaimer in the
....    documentation and/or other materials provided with the distribution.
.... 4. Neither the name of the University nor the names of its contributors
....    may be used to endorse or promote products derived from this software
....    without specific prior written permission.
....
.... THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
.... ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.... IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.... ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
.... FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.... DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.... OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.... HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.... LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.... OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.... SUCH DAMAGE.
....
.-->
<?xml-stylesheet href="docbook-xml.css" type="text/css"?>

<refentry id="boot">

<refmeta xmlns:xi="http://www.w3.org/2001/XInclude">
<refentrytitle>boot</refentrytitle>
<manvolnum>8</manvolnum>
<refmiscinfo class="manual">system administrator's manual</refmiscinfo>
<refmiscinfo class="source">FreeBSD</refmiscinfo>
</refmeta>

<refnamediv>
<refname>boot</refname>
<refpurpose>system bootstrapping procedures</refpurpose>
</refnamediv>

<refsection><title>Description</title>

<para>
What happens at power-on, as the result of a cold start or when power is restored after a power failure, is determined by the machine firmware.
Normally, the firmware is configured to begin bootstrapping an operating system, although some hardware platforms have the option to not automatically begin bootstrap after power comes on, requiring that the operator explicitly press a power button.
If that operating system is FreeBSD, the system performs automatic checks of the filesystem and begins multi-user operations.
</para>

<para>
A similar bootstrap process is followed by a warm start, after a commanded reboot or a system crash.
</para>

<refsection><title>UEFI firmware</title>

<para>
Modern systems have UEFI firmware, and the firmware itself finds, loads, and runs the first FreeBSD program, <citerefentry><refentrytitle>loader.efi</refentrytitle><manvolnum>8</manvolnum></citerefentry>, usually stored alongside other loaders for other systems and other firmware&#x2010;specific programs on a dedicated UEFI disc partition (the <quote>EFI System Partition</quote>), as detailed in full in <citerefentry><refentrytitle>uefi</refentrytitle><manvolnum>8</manvolnum></citerefentry>.
</para>

<para>
Such systems encompass PC systems where the UEFI firmware is in non&#x2010;volatile memory and SOC machines where the machine bootstrap loads and runs TianoCore from mass storage.
</para>

<para>
The <citerefentry><refentrytitle>gptboot.efi</refentrytitle><manvolnum>8</manvolnum></citerefentry> program might be used in place of <citerefentry><refentrytitle>loader.efi</refentrytitle><manvolnum>8</manvolnum></citerefentry>.
Instead of relying upon normal UEFI native configuration, where the UEFI boot manager is configured with both the location of the loader and what FreeBSD kernel to tell the loader to load, it mimics the <citerefentry><refentrytitle>gptboot</refentrytitle><manvolnum>8</manvolnum></citerefentry> program (used on old PC firmware), finding, loading, and running a loader from a UFS (only) FreeBSD partition that has been marked in the partition table.
</para>

</refsection>

<refsection><title>Old PC firmware</title>

<para>
Old Intel Architecture (i386 and amd64) PC systems have <quote>BIOS</quote> firmware, and the firmware loads and runs the code stored in the first sector of a removable or a fixed disc device.
This code may be FreeBSD&#x2010;supplied, in which case the system runs a FreeBSD&#x2010;supplied bootstrap program whose exact nature varies according to whether the disc is a non&#x2010;partitioned or a partitioned disc, and the partitioning scheme used on the latter.
</para>

<para>
On partitioned discs, a chain of various programs is run, beginning with the program in that first sector.
The chain varies according to the partitioning scheme used on the disc.
The full details are in the "BOOTSTRAPPING" section of <citerefentry><refentrytitle>gpart</refentrytitle><manvolnum>8</manvolnum></citerefentry>.
The culmination is loading and running a <citerefentry><refentrytitle>loader</refentrytitle><manvolnum>8</manvolnum></citerefentry> program from a UFS or ZFS partition or disc slice.
</para>

<para>
On non&#x2010;partitioned discs, or on partitioned discs where a <citerefentry><refentrytitle>bsdlabel</refentrytitle><manvolnum>8</manvolnum></citerefentry> is used, the procedure followed is described in <citerefentry><refentrytitle>boot_i386</refentrytitle><manvolnum>8</manvolnum></citerefentry>.
The culmination is, again, loading and running a <citerefentry><refentrytitle>loader</refentrytitle><manvolnum>8</manvolnum></citerefentry> program from the disc.
</para>

<para>
If the code is non&#x2010;FreeBSD&#x2010;supplied, some unspecified chain of third&#x2010;party boot managers and boot loaders ends up loading and running the first sector of a FreeBSD disc partition, which then enters the <citerefentry><refentrytitle>boot_i386</refentrytitle><manvolnum>8</manvolnum></citerefentry> procedure at stage 1.
</para>

<para>
Bootstrapping from CD-ROM with old PC firmware is done via the <citerefentry><refentrytitle>cdboot</refentrytitle><manvolnum>8</manvolnum></citerefentry> program.
</para>

</refsection>

</refsection>

<refsection><title>History</title>

<para>
This manual page used to be an alias for the <citerefentry><refentrytitle>boot_i386</refentrytitle><manvolnum>8</manvolnum></citerefentry> manual page.
</para>

<para>
There used to be a <citerefentry><refentrytitle>boot1.efi</refentrytitle><manvolnum>8</manvolnum></citerefentry> program that loaded <citerefentry><refentrytitle>loader.efi</refentrytitle><manvolnum>8</manvolnum></citerefentry>.
The UEFI firmware now runs the latter directly.
</para>

</refsection>

<refsection><title>See also</title>

<variablelist>
<varlistentry>
<term><citerefentry><refentrytitle>loader.efi</refentrytitle><manvolnum>8</manvolnum></citerefentry></term>
<listitem><para>
loader program that uses UEFI&#x2010;supplied services to load the FreeBSD kernel proper
</para></listitem>
</varlistentry>
<varlistentry>
<term><citerefentry><refentrytitle>loader</refentrytitle><manvolnum>8</manvolnum></citerefentry></term>
<listitem><para>
loader program that uses old PC firmware&#x2010;supplied services to load the FreeBSD kernel proper
</para></listitem>
</varlistentry>
<varlistentry>
<term><citerefentry><refentrytitle>gptboot</refentrytitle><manvolnum>8</manvolnum></citerefentry></term>
<listitem><para>
program which is stored in a dedicated GPT disc partition, that uses old PC firmware&#x2010;supplied services to find, load, and run <citerefentry><refentrytitle>loader</refentrytitle><manvolnum>8</manvolnum></citerefentry> from another GPT partition containing FreeBSD on UFS
</para></listitem>
</varlistentry>
<varlistentry>
<term><citerefentry><refentrytitle>gptzfsboot</refentrytitle><manvolnum>8</manvolnum></citerefentry></term>
<listitem><para>
program which is stored in a dedicated GPT disc partition, that uses old PC firmware&#x2010;supplied services to find, load, and run <citerefentry><refentrytitle>loader</refentrytitle><manvolnum>8</manvolnum></citerefentry> from another GPT partition containing FreeBSD on ZFS
</para></listitem>
</varlistentry>
</variablelist>

</refsection>
<refsection><title>Author</title>
<author>
<personname><firstname>Jonathan</firstname><surname>de Boyne Pollard</surname></personname>
</author>
</refsection>

</refentry>
