xref: /freebsd/stand/man/loader.efi.8 (revision 75a91c70f8d12825ded5a6d14841bf3065ba6595)
12b6d38a1SWarner Losh.\"
29ecf6e0fSMateusz Piotrowski.\" SPDX-License-Identifier: BSD-2-Clause-FreeBSD
39ecf6e0fSMateusz Piotrowski.\"
4*75a91c70SWarner Losh.\" Copyright (c) 2019-2022 Netflix, Inc
59ecf6e0fSMateusz Piotrowski.\" Copyright (c) 2022 Mateusz Piotrowski <0mp@FreeBSD.org>
62b6d38a1SWarner Losh.\"
72b6d38a1SWarner Losh.\" Redistribution and use in source and binary forms, with or without
82b6d38a1SWarner Losh.\" modification, are permitted provided that the following conditions
92b6d38a1SWarner Losh.\" are met:
102b6d38a1SWarner Losh.\" 1. Redistributions of source code must retain the above copyright
112b6d38a1SWarner Losh.\"    notice, this list of conditions and the following disclaimer.
122b6d38a1SWarner Losh.\" 2. Redistributions in binary form must reproduce the above copyright
132b6d38a1SWarner Losh.\"    notice, this list of conditions and the following disclaimer in the
142b6d38a1SWarner Losh.\"    documentation and/or other materials provided with the distribution.
152b6d38a1SWarner Losh.\"
162b6d38a1SWarner Losh.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
172b6d38a1SWarner Losh.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
182b6d38a1SWarner Losh.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
192b6d38a1SWarner Losh.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
202b6d38a1SWarner Losh.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
212b6d38a1SWarner Losh.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
222b6d38a1SWarner Losh.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
232b6d38a1SWarner Losh.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
242b6d38a1SWarner Losh.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
252b6d38a1SWarner Losh.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
262b6d38a1SWarner Losh.\" SUCH DAMAGE.
272b6d38a1SWarner Losh.\"
282b6d38a1SWarner Losh.\" $FreeBSD$
292b6d38a1SWarner Losh.\"
30*75a91c70SWarner Losh.Dd August 31, 2022
312b6d38a1SWarner Losh.Dt LOADER.EFI 8
322b6d38a1SWarner Losh.Os
332b6d38a1SWarner Losh.Sh NAME
342b6d38a1SWarner Losh.Nm loader.efi
352b6d38a1SWarner Losh.Nd UEFI kernel loader
362b6d38a1SWarner Losh.Sh DESCRIPTION
372b6d38a1SWarner LoshOn UEFI systems,
382b6d38a1SWarner Losh.Nm
392b6d38a1SWarner Loshloads the kernel.
409ecf6e0fSMateusz Piotrowski.Pp
412b6d38a1SWarner Losh.Xr boot1.efi 8
422b6d38a1SWarner Loshis used to load
432b6d38a1SWarner Losh.Nm
44*75a91c70SWarner Loshwhen it is placed within a UFS or ZFS file system.
45*75a91c70SWarner LoshAlternatively,
46*75a91c70SWarner Losh.Nm
47*75a91c70SWarner Loshis used directly when configured with
48*75a91c70SWarner Losh.Xr efibootmgr 8 ,
49*75a91c70SWarner Loshor when placed directly as the default boot program as described in
50*75a91c70SWarner Losh.Xr uefi 8 .
51*75a91c70SWarner LoshWhen a system is built using
52*75a91c70SWarner Losh.Xr bsdinstall 8 ,
53*75a91c70SWarner Losh.Nm
54*75a91c70SWarner Loshwill be used directly.
55*75a91c70SWarner Losh.Ss Console Considerations
56*75a91c70SWarner LoshThe EFI BIOS provides a generic console.
57*75a91c70SWarner LoshIn
58*75a91c70SWarner Losh.Nm
59*75a91c70SWarner Loshthis is selected by specifying
60*75a91c70SWarner Losh.Dq efi
61*75a91c70SWarner Loshusing the
62*75a91c70SWarner Losh.Dv console
63*75a91c70SWarner Loshvariable.
64*75a91c70SWarner Losh.Nm
65*75a91c70SWarner Loshexamines the
66*75a91c70SWarner Losh.Dv 8be4df61-93ca-11d2-aa0d-00e098032b8c-ConOut
67*75a91c70SWarner LoshUEFI environment variable to guess what the
68*75a91c70SWarner Losh.Dq efi
69*75a91c70SWarner Loshconsole points to.
70*75a91c70SWarner Losh.Nm
71*75a91c70SWarner Loshwill output its prompts and menus to all the places specified by ConOut.
72*75a91c70SWarner LoshHowever, the
73*75a91c70SWarner Losh.Fx
74*75a91c70SWarner Loshkernel has a limitation when more than one console is present.
75*75a91c70SWarner LoshThe kernel outputs to all configured consoles.
76*75a91c70SWarner LoshOnly the primary console will get the log messages from the
77*75a91c70SWarner Losh.Xr rc 8
78*75a91c70SWarner Loshsystem, and prompts for things like
79*75a91c70SWarner Losh.Xr geli 8
80*75a91c70SWarner Loshpasswords.
81*75a91c70SWarner LoshIf
82*75a91c70SWarner Losh.Nm
83*75a91c70SWarner Loshfinds a video device first, then
84*75a91c70SWarner Losh.Nm
85*75a91c70SWarner Loshtells the kernel to use the video console as primary.
86*75a91c70SWarner LoshLikewise, if a serial device is first in the
87*75a91c70SWarner Losh.Dv ConOut
88*75a91c70SWarner Loshlist, the serial port will be the primary console.
89*75a91c70SWarner Losh.Pp
90*75a91c70SWarner LoshIf there is no
91*75a91c70SWarner Losh.Dv ConOut
92*75a91c70SWarner Loshvariable, both serial and video are attempted.
93*75a91c70SWarner Losh.Nm
94*75a91c70SWarner Loshuses the
95*75a91c70SWarner Losh.Dq efi
96*75a91c70SWarner Loshconsole for the video (which may or may not work) and
97*75a91c70SWarner Losh.Dq comconsole
98*75a91c70SWarner Loshfor the serial on
99*75a91c70SWarner Losh.Dv COM1
100*75a91c70SWarner Loshat the default baud rate.
101*75a91c70SWarner LoshThe kernel will use a dual console, with the video console
102*75a91c70SWarner Loshprimary if a UEFI graphics device is detected, or the serial console
103*75a91c70SWarner Loshas primary if not.
104*75a91c70SWarner Losh.Pp
105*75a91c70SWarner LoshOn x86 platforms, if you wish to redirect the loader's output to a serial port
106*75a91c70SWarner Loshwhen the EFI BIOS doesn't support it, or to a serial port that isn't the one the
107*75a91c70SWarner LoshEFI BIOS redirects its output to, set
108*75a91c70SWarner Losh.Dv console
109*75a91c70SWarner Loshto
110*75a91c70SWarner Losh.Dq comconsole .
111*75a91c70SWarner LoshThe default port is
112*75a91c70SWarner Losh.Dv COM1
113*75a91c70SWarner Loshwith an I/O address of 0x3f8.
114*75a91c70SWarner Losh.Dv comconsole_port
115*75a91c70SWarner Loshis used to set this to a different port address.
116*75a91c70SWarner Losh.Dv comconsole_speed
117*75a91c70SWarner Loshis used to set the of the serial port (the default is 9600).
118*75a91c70SWarner LoshIf you have
119*75a91c70SWarner Losh.Dv console
120*75a91c70SWarner Loshset to
121*75a91c70SWarner Losh.Dq efi,comconsole
122*75a91c70SWarner Loshyou will get output on both the EFI console and the serial port.
123*75a91c70SWarner LoshIf this causes a doubling of characters, set
124*75a91c70SWarner Losh.Dv console
125*75a91c70SWarner Loshto
126*75a91c70SWarner Losh.Dq efi ,
127*75a91c70SWarner Loshsince your EFI BIOS is redirecting to the serial port already.
128*75a91c70SWarner Losh.Pp
129*75a91c70SWarner LoshIf your EFI BIOS redirects the serial port, you may need to tell the kernel
130*75a91c70SWarner Loshwhich address to use.
131*75a91c70SWarner LoshEFI uses ACPI's UID to identify the serial port, but
132*75a91c70SWarner Losh.Nm
133*75a91c70SWarner Loshdoes not have an ACPI parser, so it cannot convert that to an I/O port.
134*75a91c70SWarner LoshThe
135*75a91c70SWarner Losh.Fx
136*75a91c70SWarner Loshkernel initializes its consoles before it can decode ACPI resources.
137*75a91c70SWarner LoshThe
138*75a91c70SWarner Losh.Fx
139*75a91c70SWarner Loshkernel will look at the
140*75a91c70SWarner Losh.Dv hw.uart.console
141*75a91c70SWarner Loshvariable to set its serial console.
142*75a91c70SWarner LoshIts format should be described in
143*75a91c70SWarner Losh.Xr uart 4
144*75a91c70SWarner Loshbut is not.
145*75a91c70SWarner LoshSet it to
146*75a91c70SWarner Losh.Dq io:0x3f8,br:115200
147*75a91c70SWarner Loshwith the proper port address.
148*75a91c70SWarner LoshPCI or memory mapped ports are beyond the scope of this man page.
149*75a91c70SWarner Losh.Pp
150*75a91c70SWarner LoshThe serial ports are assigned as follows on IBM PC compatible systems:
151*75a91c70SWarner Losh.Bl -column -offset indent ".Sy Windows Name" ".Sy I/O Port Address" ".Sy Typical FreeBSD device"
152*75a91c70SWarner Losh.It Sy Windows Name Ta Sy I/O Port Address Ta Sy Typical FreeBSD device
153*75a91c70SWarner Losh.It COM1 Ta 0x3f8 Ta Pa /dev/uart0
154*75a91c70SWarner Losh.It COM2 Ta 0x2f8 Ta Pa /dev/uart1
155*75a91c70SWarner Losh.It COM3 Ta 0x3e8 Ta Pa /dev/uart2
156*75a91c70SWarner Losh.It COM4 Ta 0x2e8 Ta Pa /dev/uart3
157*75a91c70SWarner Losh.El
158*75a91c70SWarner LoshThough
159*75a91c70SWarner Losh.Dv COM3
160*75a91c70SWarner Loshand
161*75a91c70SWarner Losh.Dv COM4
162*75a91c70SWarner Loshcan vary.
163*75a91c70SWarner Losh.Pp
164*75a91c70SWarner Losh.Ss Primary Console
165*75a91c70SWarner LoshThe primary console is set using the boot flags.
166*75a91c70SWarner LoshThese command line arguments set corresponding flags for the kernel.
167*75a91c70SWarner LoshThese flags can be controlled by setting loader environment variables
168*75a91c70SWarner Loshto
169*75a91c70SWarner Losh.Dq yes
170*75a91c70SWarner Loshor
171*75a91c70SWarner Losh.Dq no .
172*75a91c70SWarner LoshBoot flags may be set on the command line to the boot command.
173*75a91c70SWarner LoshInside the kernel, the RB_ flags are used to control behavior, sometimes
174*75a91c70SWarner Loshin architecturally specific ways and are included to aid in discovery
175*75a91c70SWarner Loshof any behavior not covered in this document.
176*75a91c70SWarner Losh.Bl -column -offset indent ".Sy boot flag" ".Sy loader variable" ".Sy Kernel RB_ flag"
177*75a91c70SWarner Losh.It Sy boot flag Ta Sy loader variable Ta Sy Kernel RB_ flag
178*75a91c70SWarner Losh.It Fl a Ta Dv boot_askme Ta Va RB_ASKNAME
179*75a91c70SWarner Losh.It Fl c Ta Dv boot_cdrom Ta Va RB_CDROM
180*75a91c70SWarner Losh.It Fl d Ta Dv boot_ddb Ta Va RB_KDB
181*75a91c70SWarner Losh.It Fl r Ta Dv boot_dfltroot Ta Va RB_DFLTROOT
182*75a91c70SWarner Losh.It Fl D Ta Dv boot_multiple Ta Va RB_MULTIPLE
183*75a91c70SWarner Losh.It Fl m Ta Dv boot_mute Ta Va RB_MUTE
184*75a91c70SWarner Losh.It Fl g Ta Dv boot_gdb Ta Va RB_GDB
185*75a91c70SWarner Losh.It Fl h Ta Dv boot_serial Ta Va RB_SERIAL
186*75a91c70SWarner Losh.It Fl p Ta Dv boot_pause Ta Va RB_PAUSE
187*75a91c70SWarner Losh.It Fl P Ta Dv boot_probe Ta Va RB_PROBE
188*75a91c70SWarner Losh.It Fl s Ta Dv boot_single Ta Va RB_SINGLE
189*75a91c70SWarner Losh.It Fl v Ta Dv boot_verbose Ta Va RB_VERBOSE
190*75a91c70SWarner Losh.El
191*75a91c70SWarner LoshAnd the following flags determine the primary console:
192*75a91c70SWarner Losh.Bl -column -offset indent ".Sy Flags" ".Sy Kernel Flags" ".Sy Kernel Consoles" ".Sy Primary Console"
193*75a91c70SWarner Losh.It Sy Flags Ta Sy Kernel Flags Ta Sy Kernel Consoles Ta Sy Primary Console
194*75a91c70SWarner Losh.It none Ta 0 Ta Video Ta Video
195*75a91c70SWarner Losh.It Fl h Ta RB_SERIAL Ta Serial Ta Serial
196*75a91c70SWarner Losh.It Fl D Ta RB_MULTIPLE Ta Serial, Video Ta Video
197*75a91c70SWarner Losh.It Fl Dh Ta RB_SERIAL | RB_MULTIPLE Ta Serial, Video Ta Serial
198*75a91c70SWarner Losh.El
199*75a91c70SWarner Losh.Pp
200*75a91c70SWarner Losh.Nm
201*75a91c70SWarner Loshdoes not implement the probe
202*75a91c70SWarner Losh.Fl P
203*75a91c70SWarner Loshfunctionality where we use the video console if a keyboard is connected and a
204*75a91c70SWarner Loshserial console otherwise.
2059ecf6e0fSMateusz Piotrowski.Sh FILES
2069ecf6e0fSMateusz Piotrowski.Bl -tag -width "/boot/loader.efi"
2079ecf6e0fSMateusz Piotrowski.It Pa /boot/loader.efi
2089ecf6e0fSMateusz PiotrowskiThe location of the UEFI kernel loader within the system.
2099ecf6e0fSMateusz Piotrowski.El
2109ecf6e0fSMateusz Piotrowski.Ss EFI System Partition
2119ecf6e0fSMateusz Piotrowski.Nm
212*75a91c70SWarner Loshis installed on the ESP (EFI System Partition) in one of the following locations:
2139ecf6e0fSMateusz Piotrowski.Bl -tag -width "efi/freebsd/loader.efi"
2149ecf6e0fSMateusz Piotrowski.It Pa efi/boot/bootXXX.efi
2159ecf6e0fSMateusz PiotrowskiThe default location for any EFI loader
2169ecf6e0fSMateusz Piotrowski.Po see
2179ecf6e0fSMateusz Piotrowski.Xr uefi 8
2189ecf6e0fSMateusz Piotrowskifor values to replace
2199ecf6e0fSMateusz Piotrowski.Ql XXX
2209ecf6e0fSMateusz Piotrowskiwith
2219ecf6e0fSMateusz Piotrowski.Pc .
2229ecf6e0fSMateusz Piotrowski.It Pa efi/freebsd/loader.efi
2239ecf6e0fSMateusz PiotrowskiThe location reserved specifically for the
2249ecf6e0fSMateusz Piotrowski.Fx
2259ecf6e0fSMateusz PiotrowskiEFI loader.
2269ecf6e0fSMateusz Piotrowski.El
2279ecf6e0fSMateusz Piotrowski.Pp
2289ecf6e0fSMateusz PiotrowskiThe default location for the ESP mount point is documented in
2299ecf6e0fSMateusz Piotrowski.Xr hier 7 .
2309ecf6e0fSMateusz Piotrowski.Sh EXAMPLES
231*75a91c70SWarner Losh.Ss Updating loader.efi on the ESP
2329ecf6e0fSMateusz PiotrowskiThe following examples shows how to install a new
2339ecf6e0fSMateusz Piotrowski.Nm
234*75a91c70SWarner Loshon the ESP.
2359ecf6e0fSMateusz Piotrowski.Pp
2369ecf6e0fSMateusz PiotrowskiFirst, find the partition of type
2379ecf6e0fSMateusz Piotrowski.Dq efi :
2389ecf6e0fSMateusz Piotrowski.Bd -literal -offset indent
2399ecf6e0fSMateusz Piotrowski# gpart list | grep -Ew '(Name|efi)'
2409ecf6e0fSMateusz Piotrowski1. Name: nvd0p1
2419ecf6e0fSMateusz Piotrowski   type: efi
2429ecf6e0fSMateusz Piotrowski2. Name: nvd0p2
2439ecf6e0fSMateusz Piotrowski3. Name: nvd0p3
2449ecf6e0fSMateusz Piotrowski4. Name: nvd0p4
2459ecf6e0fSMateusz Piotrowski1. Name: nvd0
2469ecf6e0fSMateusz Piotrowski.Ed
2479ecf6e0fSMateusz Piotrowski.Pp
248*75a91c70SWarner LoshThe name of the ESP on this system is
2499ecf6e0fSMateusz Piotrowski.Pa nvd0p1 .
2509ecf6e0fSMateusz Piotrowski.Pp
251*75a91c70SWarner LoshSecond, let's mount the ESP, copy
2529ecf6e0fSMateusz Piotrowski.Nm
2539ecf6e0fSMateusz Piotrowskito the special location reserved for
2549ecf6e0fSMateusz Piotrowski.Fx
2559ecf6e0fSMateusz PiotrowskiEFI loaders, and unmount once finished:
2569ecf6e0fSMateusz Piotrowski.Bd -literal -offset indent
2579ecf6e0fSMateusz Piotrowski# mount_msdosfs /dev/nvd0p1 /boot/efi
2589ecf6e0fSMateusz Piotrowski# cp /boot/loader.efi /boot/efi/efi/freebsd/loader.efi
2599ecf6e0fSMateusz Piotrowski# umount /boot/efi
260*75a91c70SWarner Losh.Ed
2619ecf6e0fSMateusz Piotrowski.Sh SEE ALSO
262f70de61eSEd Maste.Xr loader 8 ,
2639ecf6e0fSMateusz Piotrowski.Xr uefi 8
264*75a91c70SWarner Losh.Sh BUGS
265*75a91c70SWarner LoshSystems that do not have a
266*75a91c70SWarner Losh.Dv ConOut
267*75a91c70SWarner Loshvariable set are not conformant with the standard, and likely have unexpected
268*75a91c70SWarner Loshresults.
269*75a91c70SWarner Losh.Pp
270*75a91c70SWarner LoshNon-x86 serial console handling is even more confusing and less well documented.
271*75a91c70SWarner Losh.Pp
272*75a91c70SWarner LoshSometimes when the serial port speed isn't set, 9600 is used.
273*75a91c70SWarner LoshOther times the result is typically 115200 since the speed remains unchanged
274*75a91c70SWarner Loshfrom the default.
275