xref: /freebsd/stand/man/loader.efi.8 (revision bc919e81e0b7dadf0ef550d83d0ef910cc20c5bf)
12b6d38a1SWarner Losh.\"
24d846d26SWarner Losh.\" SPDX-License-Identifier: BSD-2-Clause
39ecf6e0fSMateusz Piotrowski.\"
475a91c70SWarner Losh.\" Copyright (c) 2019-2022 Netflix, Inc
59ecf6e0fSMateusz Piotrowski.\" Copyright (c) 2022 Mateusz Piotrowski <0mp@FreeBSD.org>
6dab59af3SLi-Wen Hsu.\" Copyright 2022 The FreeBSD Foundation
785c8c0b7SKonstantin Belousov.\"
885c8c0b7SKonstantin Belousov.\" Part of this documentation was written by
985c8c0b7SKonstantin Belousov.\" Konstantin Belousov <kib@FreeBSD.org> under sponsorship
1085c8c0b7SKonstantin Belousov.\" from the FreeBSD Foundation.
112b6d38a1SWarner Losh.\"
122b6d38a1SWarner Losh.\" Redistribution and use in source and binary forms, with or without
132b6d38a1SWarner Losh.\" modification, are permitted provided that the following conditions
142b6d38a1SWarner Losh.\" are met:
152b6d38a1SWarner Losh.\" 1. Redistributions of source code must retain the above copyright
162b6d38a1SWarner Losh.\"    notice, this list of conditions and the following disclaimer.
172b6d38a1SWarner Losh.\" 2. Redistributions in binary form must reproduce the above copyright
182b6d38a1SWarner Losh.\"    notice, this list of conditions and the following disclaimer in the
192b6d38a1SWarner Losh.\"    documentation and/or other materials provided with the distribution.
202b6d38a1SWarner Losh.\"
212b6d38a1SWarner Losh.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
222b6d38a1SWarner Losh.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
232b6d38a1SWarner Losh.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
242b6d38a1SWarner Losh.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
252b6d38a1SWarner Losh.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
262b6d38a1SWarner Losh.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
272b6d38a1SWarner Losh.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
282b6d38a1SWarner Losh.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
292b6d38a1SWarner Losh.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
302b6d38a1SWarner Losh.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
312b6d38a1SWarner Losh.\" SUCH DAMAGE.
322b6d38a1SWarner Losh.\"
3318f7683eSJessica Clarke.Dd September 3, 2024
342b6d38a1SWarner Losh.Dt LOADER.EFI 8
352b6d38a1SWarner Losh.Os
362b6d38a1SWarner Losh.Sh NAME
372b6d38a1SWarner Losh.Nm loader.efi
382b6d38a1SWarner Losh.Nd UEFI kernel loader
392b6d38a1SWarner Losh.Sh DESCRIPTION
402b6d38a1SWarner LoshOn UEFI systems,
412b6d38a1SWarner Losh.Nm
422b6d38a1SWarner Loshloads the kernel.
439ecf6e0fSMateusz Piotrowski.Pp
442b6d38a1SWarner Losh.Xr boot1.efi 8
452b6d38a1SWarner Loshis used to load
462b6d38a1SWarner Losh.Nm
4775a91c70SWarner Loshwhen it is placed within a UFS or ZFS file system.
4875a91c70SWarner LoshAlternatively,
4975a91c70SWarner Losh.Nm
5075a91c70SWarner Loshis used directly when configured with
5175a91c70SWarner Losh.Xr efibootmgr 8 ,
5275a91c70SWarner Loshor when placed directly as the default boot program as described in
5375a91c70SWarner Losh.Xr uefi 8 .
5475a91c70SWarner LoshWhen a system is built using
5575a91c70SWarner Losh.Xr bsdinstall 8 ,
5675a91c70SWarner Losh.Nm
5775a91c70SWarner Loshwill be used directly.
5875a91c70SWarner Losh.Ss Console Considerations
5975a91c70SWarner LoshThe EFI BIOS provides a generic console.
6075a91c70SWarner LoshIn
6175a91c70SWarner Losh.Nm
6275a91c70SWarner Loshthis is selected by specifying
6375a91c70SWarner Losh.Dq efi
6475a91c70SWarner Loshusing the
6575a91c70SWarner Losh.Dv console
6675a91c70SWarner Loshvariable.
6775a91c70SWarner Losh.Nm
6875a91c70SWarner Loshexamines the
6975a91c70SWarner Losh.Dv 8be4df61-93ca-11d2-aa0d-00e098032b8c-ConOut
7075a91c70SWarner LoshUEFI environment variable to guess what the
7175a91c70SWarner Losh.Dq efi
7275a91c70SWarner Loshconsole points to.
7375a91c70SWarner Losh.Nm
7475a91c70SWarner Loshwill output its prompts and menus to all the places specified by ConOut.
7575a91c70SWarner LoshHowever, the
7675a91c70SWarner Losh.Fx
7775a91c70SWarner Loshkernel has a limitation when more than one console is present.
7875a91c70SWarner LoshThe kernel outputs to all configured consoles.
7975a91c70SWarner LoshOnly the primary console will get the log messages from the
8075a91c70SWarner Losh.Xr rc 8
8175a91c70SWarner Loshsystem, and prompts for things like
8275a91c70SWarner Losh.Xr geli 8
8375a91c70SWarner Loshpasswords.
8475a91c70SWarner LoshIf
8575a91c70SWarner Losh.Nm
8675a91c70SWarner Loshfinds a video device first, then
8775a91c70SWarner Losh.Nm
8875a91c70SWarner Loshtells the kernel to use the video console as primary.
8975a91c70SWarner LoshLikewise, if a serial device is first in the
9075a91c70SWarner Losh.Dv ConOut
9175a91c70SWarner Loshlist, the serial port will be the primary console.
9275a91c70SWarner Losh.Pp
9375a91c70SWarner LoshIf there is no
9475a91c70SWarner Losh.Dv ConOut
9575a91c70SWarner Loshvariable, both serial and video are attempted.
9675a91c70SWarner Losh.Nm
9775a91c70SWarner Loshuses the
9875a91c70SWarner Losh.Dq efi
9975a91c70SWarner Loshconsole for the video (which may or may not work) and
10075a91c70SWarner Losh.Dq comconsole
10175a91c70SWarner Loshfor the serial on
10275a91c70SWarner Losh.Dv COM1
10375a91c70SWarner Loshat the default baud rate.
10475a91c70SWarner LoshThe kernel will use a dual console, with the video console
10575a91c70SWarner Loshprimary if a UEFI graphics device is detected, or the serial console
10675a91c70SWarner Loshas primary if not.
10775a91c70SWarner Losh.Pp
10875a91c70SWarner LoshOn x86 platforms, if you wish to redirect the loader's output to a serial port
10975a91c70SWarner Loshwhen the EFI BIOS doesn't support it, or to a serial port that isn't the one the
11075a91c70SWarner LoshEFI BIOS redirects its output to, set
11175a91c70SWarner Losh.Dv console
11275a91c70SWarner Loshto
11375a91c70SWarner Losh.Dq comconsole .
11475a91c70SWarner LoshThe default port is
11575a91c70SWarner Losh.Dv COM1
11675a91c70SWarner Loshwith an I/O address of 0x3f8.
11775a91c70SWarner Losh.Dv comconsole_port
11875a91c70SWarner Loshis used to set this to a different port address.
11975a91c70SWarner Losh.Dv comconsole_speed
12075a91c70SWarner Loshis used to set the of the serial port (the default is 9600).
12175a91c70SWarner LoshIf you have
12275a91c70SWarner Losh.Dv console
12375a91c70SWarner Loshset to
12475a91c70SWarner Losh.Dq efi,comconsole
12575a91c70SWarner Loshyou will get output on both the EFI console and the serial port.
12675a91c70SWarner LoshIf this causes a doubling of characters, set
12775a91c70SWarner Losh.Dv console
12875a91c70SWarner Loshto
12975a91c70SWarner Losh.Dq efi ,
13075a91c70SWarner Loshsince your EFI BIOS is redirecting to the serial port already.
13175a91c70SWarner Losh.Pp
13275a91c70SWarner LoshIf your EFI BIOS redirects the serial port, you may need to tell the kernel
13375a91c70SWarner Loshwhich address to use.
13475a91c70SWarner LoshEFI uses ACPI's UID to identify the serial port, but
13575a91c70SWarner Losh.Nm
13675a91c70SWarner Loshdoes not have an ACPI parser, so it cannot convert that to an I/O port.
13775a91c70SWarner LoshThe
13875a91c70SWarner Losh.Fx
13975a91c70SWarner Loshkernel initializes its consoles before it can decode ACPI resources.
14075a91c70SWarner LoshThe
14175a91c70SWarner Losh.Fx
14275a91c70SWarner Loshkernel will look at the
14375a91c70SWarner Losh.Dv hw.uart.console
14475a91c70SWarner Loshvariable to set its serial console.
14575a91c70SWarner LoshIts format should be described in
14675a91c70SWarner Losh.Xr uart 4
14775a91c70SWarner Loshbut is not.
14875a91c70SWarner LoshSet it to
14975a91c70SWarner Losh.Dq io:0x3f8,br:115200
15075a91c70SWarner Loshwith the proper port address.
15175a91c70SWarner LoshPCI or memory mapped ports are beyond the scope of this man page.
15275a91c70SWarner Losh.Pp
15375a91c70SWarner LoshThe serial ports are assigned as follows on IBM PC compatible systems:
15475a91c70SWarner Losh.Bl -column -offset indent ".Sy Windows Name" ".Sy I/O Port Address" ".Sy Typical FreeBSD device"
15575a91c70SWarner Losh.It Sy Windows Name Ta Sy I/O Port Address Ta Sy Typical FreeBSD device
15675a91c70SWarner Losh.It COM1 Ta 0x3f8 Ta Pa /dev/uart0
15775a91c70SWarner Losh.It COM2 Ta 0x2f8 Ta Pa /dev/uart1
15875a91c70SWarner Losh.It COM3 Ta 0x3e8 Ta Pa /dev/uart2
15975a91c70SWarner Losh.It COM4 Ta 0x2e8 Ta Pa /dev/uart3
16075a91c70SWarner Losh.El
16175a91c70SWarner LoshThough
16275a91c70SWarner Losh.Dv COM3
16375a91c70SWarner Loshand
16475a91c70SWarner Losh.Dv COM4
16575a91c70SWarner Loshcan vary.
16675a91c70SWarner Losh.Pp
16775a91c70SWarner Losh.Ss Primary Console
16875a91c70SWarner LoshThe primary console is set using the boot flags.
16975a91c70SWarner LoshThese command line arguments set corresponding flags for the kernel.
17075a91c70SWarner LoshThese flags can be controlled by setting loader environment variables
17175a91c70SWarner Loshto
17275a91c70SWarner Losh.Dq yes
17375a91c70SWarner Loshor
17475a91c70SWarner Losh.Dq no .
17575a91c70SWarner LoshBoot flags may be set on the command line to the boot command.
17675a91c70SWarner LoshInside the kernel, the RB_ flags are used to control behavior, sometimes
17775a91c70SWarner Loshin architecturally specific ways and are included to aid in discovery
17875a91c70SWarner Loshof any behavior not covered in this document.
17975a91c70SWarner Losh.Bl -column -offset indent ".Sy boot flag" ".Sy loader variable" ".Sy Kernel RB_ flag"
18075a91c70SWarner Losh.It Sy boot flag Ta Sy loader variable Ta Sy Kernel RB_ flag
18175a91c70SWarner Losh.It Fl a Ta Dv boot_askme Ta Va RB_ASKNAME
18275a91c70SWarner Losh.It Fl c Ta Dv boot_cdrom Ta Va RB_CDROM
18375a91c70SWarner Losh.It Fl d Ta Dv boot_ddb Ta Va RB_KDB
18475a91c70SWarner Losh.It Fl r Ta Dv boot_dfltroot Ta Va RB_DFLTROOT
18575a91c70SWarner Losh.It Fl D Ta Dv boot_multiple Ta Va RB_MULTIPLE
18675a91c70SWarner Losh.It Fl m Ta Dv boot_mute Ta Va RB_MUTE
18775a91c70SWarner Losh.It Fl g Ta Dv boot_gdb Ta Va RB_GDB
18875a91c70SWarner Losh.It Fl h Ta Dv boot_serial Ta Va RB_SERIAL
18975a91c70SWarner Losh.It Fl p Ta Dv boot_pause Ta Va RB_PAUSE
19075a91c70SWarner Losh.It Fl P Ta Dv boot_probe Ta Va RB_PROBE
19175a91c70SWarner Losh.It Fl s Ta Dv boot_single Ta Va RB_SINGLE
19275a91c70SWarner Losh.It Fl v Ta Dv boot_verbose Ta Va RB_VERBOSE
19375a91c70SWarner Losh.El
19475a91c70SWarner LoshAnd the following flags determine the primary console:
19575a91c70SWarner Losh.Bl -column -offset indent ".Sy Flags" ".Sy Kernel Flags" ".Sy Kernel Consoles" ".Sy Primary Console"
19675a91c70SWarner Losh.It Sy Flags Ta Sy Kernel Flags Ta Sy Kernel Consoles Ta Sy Primary Console
19775a91c70SWarner Losh.It none Ta 0 Ta Video Ta Video
19875a91c70SWarner Losh.It Fl h Ta RB_SERIAL Ta Serial Ta Serial
19975a91c70SWarner Losh.It Fl D Ta RB_MULTIPLE Ta Serial, Video Ta Video
20075a91c70SWarner Losh.It Fl Dh Ta RB_SERIAL | RB_MULTIPLE Ta Serial, Video Ta Serial
20175a91c70SWarner Losh.El
20275a91c70SWarner Losh.Pp
20375a91c70SWarner Losh.Nm
20475a91c70SWarner Loshdoes not implement the probe
20575a91c70SWarner Losh.Fl P
20675a91c70SWarner Loshfunctionality where we use the video console if a keyboard is connected and a
20775a91c70SWarner Loshserial console otherwise.
208bce72871SGuido Falsi.Ss Additional Environment Variables
209bce72871SGuido Falsi.Nm
210bce72871SGuido Falsiloads some extra variables early in startup from
211bce72871SGuido Falsi.Pa /efi/freebsd/loader.env
21294eca4b5SBenedict Reuschlingfrom the EFI partition.
21394eca4b5SBenedict ReuschlingOnly simple variables can be set here.
21494eca4b5SBenedict ReuschlingIt can be useful to specify the root filesystem:
215bce72871SGuido Falsi.Bd -literal -offset indent
216bce72871SGuido Falsirootdev=disk0s1a
217bce72871SGuido Falsi.Ed
21885c8c0b7SKonstantin Belousov.Ss Staging Slop
21985c8c0b7SKonstantin BelousovThe kernel must parse the firmware memory map tables to know what memory
22085c8c0b7SKonstantin Belousovit can use.
22185c8c0b7SKonstantin BelousovSince it must allocate memory to do this,
22285c8c0b7SKonstantin Belousov.Nm
22385c8c0b7SKonstantin Belousovensures there's extra memory available, called
22485c8c0b7SKonstantin Belousov.Dq slop ,
22585c8c0b7SKonstantin Belousovafter everything it loads
22685c8c0b7SKonstantin Belousov.Po
22785c8c0b7SKonstantin Belousovthe kernel, modules and metadata
22885c8c0b7SKonstantin Belousov.Pc
22985c8c0b7SKonstantin Belousovfor the kernel to bootstrap the memory allocator.
23085c8c0b7SKonstantin Belousov.Pp
23185c8c0b7SKonstantin BelousovBy default, amd64 reserves 8MB.
23285c8c0b7SKonstantin BelousovThe
23385c8c0b7SKonstantin Belousov.Ic staging_slop
23485c8c0b7SKonstantin Belousovcommand allows for tuning the slop size.
23585c8c0b7SKonstantin BelousovIt takes a single argument, the size of the slop in bytes.
23685c8c0b7SKonstantin Belousov.Ss amd64 Nocopy
23785c8c0b7SKonstantin Belousov.Nm
23885c8c0b7SKonstantin Belousovwill load the kernel into memory that is 2MB aligned below 4GB.
23985c8c0b7SKonstantin BelousovIt cannot load to a fixed address because the UEFI firmware may reserve
24085c8c0b7SKonstantin Belousovarbitrary memory for its use at runtime.
24185c8c0b7SKonstantin BelousovPrior to
24285c8c0b7SKonstantin Belousov.Fx 13.1 ,
24385c8c0b7SKonstantin Belousovkernels retained the old BIOS-boot protocol of loading at exactly 2MB.
24485c8c0b7SKonstantin BelousovSuch kernels must be copied from their loaded location to 2MB prior
24585c8c0b7SKonstantin Belousovstarting them up.
24685c8c0b7SKonstantin BelousovThe
24785c8c0b7SKonstantin Belousov.Ic copy_staging
24885c8c0b7SKonstantin Belousovcommand is used to enable this copying for older kernels.
24985c8c0b7SKonstantin BelousovIt takes a single argument
25085c8c0b7SKonstantin Belousovwhich can be one of
25185c8c0b7SKonstantin Belousov.Bl -tag -width disable
25285c8c0b7SKonstantin Belousov.It Ar disable
25385c8c0b7SKonstantin BelousovForce-disable copying staging area to
25485c8c0b7SKonstantin Belousov.Ad 2M .
25585c8c0b7SKonstantin Belousov.It Ar enable
25685c8c0b7SKonstantin BelousovForce-enable copying staging area to
25785c8c0b7SKonstantin Belousov.Ad 2M .
25885c8c0b7SKonstantin Belousov.It Ar auto
25985c8c0b7SKonstantin BelousovSelects the behaviour based on the kernel's capability of boostraping
26085c8c0b7SKonstantin Belousovfrom non-2M physical base.
26185c8c0b7SKonstantin BelousovThe kernel reports this capability by exporting the symbol
26285c8c0b7SKonstantin Belousov.Va kernphys .
26385c8c0b7SKonstantin Belousov.El
26485c8c0b7SKonstantin Belousov.Pp
26585c8c0b7SKonstantin BelousovArm64 loaders have operated in the
26685c8c0b7SKonstantin Belousov.Sq nocopy
26785c8c0b7SKonstantin Belousovmode from their inception, so there is no
26885c8c0b7SKonstantin Belousov.Ic copy_staging
26985c8c0b7SKonstantin Belousovcommand on that platform.
27085c8c0b7SKonstantin BelousovRiscv, 32-bit arm and arm64 have always loaded at any
27185c8c0b7SKonstantin Belousov.Ad 2MB
27285c8c0b7SKonstantin Belousovaligned location, so do not provide
27385c8c0b7SKonstantin Belousov.Ic copy_staging .
27485c8c0b7SKonstantin Belousov.Pp
27585c8c0b7SKonstantin Belousov.Bd -ragged -offset indent
27685c8c0b7SKonstantin Belousov.Sy Note.
27785c8c0b7SKonstantin BelousovBIOS loaders on i386 and amd64 put the staging area starting
27885c8c0b7SKonstantin Belousovat the physical address
27985c8c0b7SKonstantin Belousov.Ad 2M ,
28085c8c0b7SKonstantin Belousovthen enable paging with identical mapping for the low
28185c8c0b7SKonstantin Belousov.Ad 1G .
28285c8c0b7SKonstantin BelousovThe initial port of
28385c8c0b7SKonstantin Belousov.Nm
28485c8c0b7SKonstantin Belousovfollowed the same scheme for handing control to the kernel,
28585c8c0b7SKonstantin Belousovsince it avoided modifications for the loader/kernel hand-off protocol,
28685c8c0b7SKonstantin Belousovand for the kernel page table bootstrap.
28785c8c0b7SKonstantin Belousov.Pp
28885c8c0b7SKonstantin BelousovThis approach is incompatible with the UEFI specification,
28985c8c0b7SKonstantin Belousovand as a practical matter, caused troubles on many boards,
29085c8c0b7SKonstantin Belousovbecause UEFI firmware is free to use any memory for its own needs.
29185c8c0b7SKonstantin BelousovApplications like
29285c8c0b7SKonstantin Belousov.Nm
29385c8c0b7SKonstantin Belousovmust only use memory explicitly allocated using boot interfaces.
29485c8c0b7SKonstantin BelousovThe original way also potentially destroyed UEFI runtime interfaces data.
29585c8c0b7SKonstantin Belousov.Pp
29685c8c0b7SKonstantin BelousovEventually,
29785c8c0b7SKonstantin Belousov.Nm
29885c8c0b7SKonstantin Belousovand the kernel were improved to avoid this problem.
29985c8c0b7SKonstantin Belousov.Ed
30085c8c0b7SKonstantin Belousov.Ss amd64 Faults
30185c8c0b7SKonstantin BelousovBecause it executes in x86 protected mode, the amd64 version of
30285c8c0b7SKonstantin Belousov.Nm
30385c8c0b7SKonstantin Belousovis susceptible to CPU faults due to programmer mistakes and
30485c8c0b7SKonstantin Belousovmemory corruption.
30585c8c0b7SKonstantin BelousovTo make debugging such faults easier, amd64
30685c8c0b7SKonstantin Belousov.Nm
30785c8c0b7SKonstantin Belousovcan provide detailed reporting of the CPU state at the time
30885c8c0b7SKonstantin Belousovof the fault.
30985c8c0b7SKonstantin Belousov.Pp
31085c8c0b7SKonstantin BelousovThe
31185c8c0b7SKonstantin Belousov.Ic grab_faults
31285c8c0b7SKonstantin Belousovcommand installs a handler for faults directly in the IDT,
31385c8c0b7SKonstantin Belousovavoiding the use of the UEFI debugging interface
31485c8c0b7SKonstantin Belousov.Fn EFI_DEBUG_SUPPORT_PROTOCOL.RegisterExceptionCallback .
31585c8c0b7SKonstantin BelousovThat interface is left available for advanced debuggers in
31685c8c0b7SKonstantin Belousovthe UEFI environment.
31785c8c0b7SKonstantin BelousovThe
31885c8c0b7SKonstantin Belousov.Ic ungrab_faults
31985c8c0b7SKonstantin Belousovcommand tries to deinstall the fault handler, returning TSS and IDT
32085c8c0b7SKonstantin BelousovCPU tables to their pre-installation state.
32185c8c0b7SKonstantin BelousovThe
32285c8c0b7SKonstantin Belousov.Ic fault
32385c8c0b7SKonstantin Belousovcommand produces a fault in the
32485c8c0b7SKonstantin Belousov.Nm
32585c8c0b7SKonstantin Belousovenvironment for testing purposes, by executing the
32685c8c0b7SKonstantin Belousov.Ic ud2
32785c8c0b7SKonstantin Belousovprocessor instruction.
3289ecf6e0fSMateusz Piotrowski.Sh FILES
3299ecf6e0fSMateusz Piotrowski.Bl -tag -width "/boot/loader.efi"
3309ecf6e0fSMateusz Piotrowski.It Pa /boot/loader.efi
3319ecf6e0fSMateusz PiotrowskiThe location of the UEFI kernel loader within the system.
3329ecf6e0fSMateusz Piotrowski.El
3339ecf6e0fSMateusz Piotrowski.Ss EFI System Partition
3349ecf6e0fSMateusz Piotrowski.Nm
33575a91c70SWarner Loshis installed on the ESP (EFI System Partition) in one of the following locations:
3369ecf6e0fSMateusz Piotrowski.Bl -tag -width "efi/freebsd/loader.efi"
3379ecf6e0fSMateusz Piotrowski.It Pa efi/boot/bootXXX.efi
3389ecf6e0fSMateusz PiotrowskiThe default location for any EFI loader
3399ecf6e0fSMateusz Piotrowski.Po see
3409ecf6e0fSMateusz Piotrowski.Xr uefi 8
3419ecf6e0fSMateusz Piotrowskifor values to replace
3429ecf6e0fSMateusz Piotrowski.Ql XXX
3439ecf6e0fSMateusz Piotrowskiwith
3449ecf6e0fSMateusz Piotrowski.Pc .
3459ecf6e0fSMateusz Piotrowski.It Pa efi/freebsd/loader.efi
3469ecf6e0fSMateusz PiotrowskiThe location reserved specifically for the
3479ecf6e0fSMateusz Piotrowski.Fx
3489ecf6e0fSMateusz PiotrowskiEFI loader.
3499ecf6e0fSMateusz Piotrowski.El
3509ecf6e0fSMateusz Piotrowski.Pp
3519ecf6e0fSMateusz PiotrowskiThe default location for the ESP mount point is documented in
3529ecf6e0fSMateusz Piotrowski.Xr hier 7 .
3539ecf6e0fSMateusz Piotrowski.Sh EXAMPLES
35475a91c70SWarner Losh.Ss Updating loader.efi on the ESP
3558ec79e8aSMateusz PiotrowskiThe following example shows how to install a new
3569ecf6e0fSMateusz Piotrowski.Nm
35775a91c70SWarner Loshon the ESP.
358871911a4SWarner LoshThe exact placement is complicated due to the diversity of
359871911a4SWarner Loshinstallations, setups and situations.
360871911a4SWarner LoshIn this section, paths that are all lower case are Unix paths.
361871911a4SWarner LoshPaths that are all upper case are relative to the ESP mount point,
362871911a4SWarner Loshthough they may appear as lower case on your system because the
363871911a4SWarner LoshFAT filesystem of the ESP is case insensitive.
3649ecf6e0fSMateusz Piotrowski.Pp
365871911a4SWarner LoshLocate the ESP, which has its own partition type of
3669ecf6e0fSMateusz Piotrowski.Dq efi :
3679ecf6e0fSMateusz Piotrowski.Bd -literal -offset indent
368871911a4SWarner Losh# gpart show nda0
369871911a4SWarner Losh=>        40  7501476448  nda0  GPT  (3.5T)
370871911a4SWarner Losh          40      614400     1  efi  (300M)
371871911a4SWarner Losh      614440  7500862048     2  freebsd-zfs  (3.5T)
3729ecf6e0fSMateusz Piotrowski.Ed
3739ecf6e0fSMateusz Piotrowski.Pp
37475a91c70SWarner LoshThe name of the ESP on this system is
375871911a4SWarner Losh.Pa nda0p1 .
376871911a4SWarner LoshBy default, this will be mounted on
377871911a4SWarner Losh.Pa /boot/efi .
378871911a4SWarner LoshTo check:
3799ecf6e0fSMateusz Piotrowski.Bd -literal -offset indent
380871911a4SWarner Losh# mount | grep nda0p1
381871911a4SWarner Losh/dev/nda0p1 on /boot/efi (msdosfs, local)
382871911a4SWarner Losh.Ed
383871911a4SWarner LoshIf it's not mounted, you will need to mount it:
384871911a4SWarner Losh.Bd -literal -offset indent
385871911a4SWarner Losh# mount -t msdosfs /dev/nda0p1 /boot/efi
386871911a4SWarner Losh.Ed
387871911a4SWarner Losh.Pp
388871911a4SWarner Losh.Xr efibootmgr 8
389871911a4SWarner Loshreports what we booted from.
390871911a4SWarner Losh.Bd -literal -offset indent
391871911a4SWarner Losh# efibootmgr -v
392871911a4SWarner LoshBoot to FW : false
393871911a4SWarner LoshBootCurrent: 0001
394871911a4SWarner LoshTimeout    : 2 seconds
395871911a4SWarner LoshBootOrder  : 0000, 0001, 0003, 0004, 0005, 0006, 0001, 0008, 000A, 000B, 000C, 000E, 0007
396759ddb4dSGraham Percival\&...
397*bc919e81SGraham Percival+Boot0001* FreeBSD ZPOOL HD(1,GPT,b5d0f86b-265d-1e1b-18aa-0ed55e1e73bd,0x28,0x96000)/File(\eEFI\eFREEBSD\eLOADER.EFI)
398871911a4SWarner Losh                            nda0p1:/EFI/FREEBSD/LOADER.EFI /boot/efi//EFI/FREEBSD/LOADER.EFI
399759ddb4dSGraham Percival\&...
400871911a4SWarner Losh.Ed
401871911a4SWarner LoshOften there are several options, depending on the BIOS.
402871911a4SWarner LoshThe entry that we booted with is marked with a
403871911a4SWarner Losh.Sq +
404871911a4SWarner Loshat the start of the line, as shown above.
405871911a4SWarner LoshSo in this case, this firmware is using
406871911a4SWarner Losh.Pa /EFI/FREEBSD/LOADER.EFI
407871911a4SWarner Loshfrom the ESP.
408871911a4SWarner LoshOften times it will be the UEFI
409871911a4SWarner Losh.Dq default
410871911a4SWarner Loshloader, which varies by architecture.
411871911a4SWarner Losh.Bl -column -offset indent "Architecture" "Default Path"
412871911a4SWarner Losh.It Sy Architecture Ta Sy Default Path
413871911a4SWarner Losh.It amd64 Ta Pa /EFI/BOOT/BOOTX64.EFI
414871911a4SWarner Losh.It arm Ta Pa /EFI/BOOT/BOOTARM.EFI
415871911a4SWarner Losh.It arm64 Ta Pa /EFI/BOOT/BOOTAA64.EFI
416871911a4SWarner Losh.It i386 Ta Pa /EFI/BOOT/BOOTIA32.EFI
417871911a4SWarner Losh.It riscv Ta Pa /EFI/BOOT/BOOTRISCV64.EFI
418871911a4SWarner Losh.El
419871911a4SWarner LoshHowever, care must be taken: some multiple-boot environments rely on a special
420871911a4SWarner Losh.Pa bootXXX.efi
421871911a4SWarner Loshto function.
422871911a4SWarner LoshBefore updating a
423871911a4SWarner Losh.Pa bootXXX.efi
424871911a4SWarner Loshfile, make sure it is the FreeBSD boot loader before updating it:
425871911a4SWarner Losh.Bd -literal -offset indent
426871911a4SWarner Losh# strings /boot/efi/EFI/BOOT/BOOTX64.EFI | grep FreeBSD | grep EFI
427871911a4SWarner LoshFreeBSD/amd64 EFI loader, Revision 3.0
428871911a4SWarner Losh.Ed
429871911a4SWarner Losh.Pp
430871911a4SWarner Losh.Xr bsdinstall 8
431871911a4SWarner Loshcopies
432871911a4SWarner Losh.Pa loader.efi
433871911a4SWarner Loshto the default name if there wasn't one there before.
434871911a4SWarner LoshCheck to see if they are copies before updating (with X64 substituted using the
435871911a4SWarner Loshabove table):
436871911a4SWarner Losh.Bd -literal -offset indent
43745001ab4SGraham Perrin# cmp /boot/efi/EFI/FREEBSD/LOADER.EFI /boot/efi/EFI/BOOT/BOOTX64.EFI
438871911a4SWarner Losh.Ed
439871911a4SWarner LoshCopy the loader:
440871911a4SWarner Losh.Bd -literal -offset indent
441871911a4SWarner Losh# cp /boot/loader.efi /boot/efi/EFI/FREEBSD/LOADER.EFI
442871911a4SWarner Losh.Ed
443871911a4SWarner Loshreplacing the all caps part of the example with the proper path.
444871911a4SWarner Losh.Pp
445871911a4SWarner LoshIf ESP path was
446871911a4SWarner Losh.Pa /FREEBSD/LOADER.EFI
447871911a4SWarner Loshand LOADER.EFI and BOOTX64.EFI were identical in the cmp step,
448871911a4SWarner Loshcopy the loader to the default location:
449871911a4SWarner Losh.Bd -literal -offset indent
450871911a4SWarner Losh# cp /boot/loader.efi /boot/efi/EFI/BOOT/BOOTX64.EFI
451871911a4SWarner Losh.Ed
452871911a4SWarner Losh.Pp
453871911a4SWarner LoshFinally, if you mounted the ESP, you may wish to unmount it.
454871911a4SWarner Losh.Bd -literal -offset indent
4559ecf6e0fSMateusz Piotrowski# umount /boot/efi
45675a91c70SWarner Losh.Ed
4579ecf6e0fSMateusz Piotrowski.Sh SEE ALSO
458f70de61eSEd Maste.Xr loader 8 ,
4599ecf6e0fSMateusz Piotrowski.Xr uefi 8
46075a91c70SWarner Losh.Sh BUGS
46175a91c70SWarner LoshNon-x86 serial console handling is even more confusing and less well documented.
46275a91c70SWarner Losh.Pp
46375a91c70SWarner LoshSometimes when the serial port speed isn't set, 9600 is used.
46475a91c70SWarner LoshOther times the result is typically 115200 since the speed remains unchanged
46575a91c70SWarner Loshfrom the default.
466871911a4SWarner Losh.Pp
467871911a4SWarner LoshU-Boot implements a subset of the UEFI standard.
468871911a4SWarner LoshSome versions do not support fetching loader variables, so
469871911a4SWarner Losh.Pa efibootmgr
470871911a4SWarner Loshmay not work.
471871911a4SWarner LoshIn addition,
472871911a4SWarner Losh.Pa efibootmgr
473871911a4SWarner Loshis not supported on armv7 or riscv.
474871911a4SWarner LoshIn these instances, the user has to understand what was booted to update
475871911a4SWarner Loshit properly (and in most cases, it will be the FreeBSD path and the UEFI default
476871911a4SWarner Loshso just copy loader.efi there if there are loaders there).
477871911a4SWarner LoshTypically in these embedded situations, there is only one .efi file (loader.efi
478871911a4SWarner Loshor a copy of loader.efi).
479871911a4SWarner LoshThe path to this file is typically the default removable path above.
480871911a4SWarner Losh.Pp
481871911a4SWarner LoshManaging booting multiple OSes on UEFI varies greatly, so extra caution when
482871911a4SWarner Loshupdating the UEFI default loader.
483871911a4SWarner Losh.Pp
484871911a4SWarner LoshThe old, now obsolete, boot1.efi was installed as bootx64.efi in
485871911a4SWarner Losh.Fx 10
486871911a4SWarner Loshand earlier.
487871911a4SWarner LoshSince it was quite limited in functionality, we created very small
488871911a4SWarner LoshESPs by default.
489871911a4SWarner LoshA modern loader.efi will not fit.
490871911a4SWarner LoshHowever, if the old boot1.efi still works, there's no need to update
491871911a4SWarner Loshit since it will chain boot /boot/loader.efi from a copy that
492871911a4SWarner Loshmake installworld updates.
493