summaryrefslogtreecommitdiff
path: root/static/freebsd/man8/gptboot.efi.8
blob: e520509e35e6c021fbc79357b2b5b48a933fe01c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
.\" Copyright (c) 2013 Warren Block All rights reserved.
.\" Copyright (c) 2021 Warner Losh
.\"
.\" 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.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS 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 AUTHORS 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.
.\"
.Dd April 13, 2023
.Dt GPTBOOT.EFI 8
.Os
.Sh NAME
.Nm gptboot.efi
.Nd GPT bootcode for UFS on UEFI computers
.Sh DESCRIPTION
.Nm
is used on UEFI computers to boot from a UFS partition on a
GPT-partitioned disk.
.Nm
is installed in the EFI System Partition (ESP).
For BIOS-based computers,
see
.Xr gptboot 8
for details.
While conceptually similar, the details differ.
.Nm
works only with UFS root file systems.
Users with ZFS partitions should use
.Xr loader.efi 8
with
.Xr bectl 8
to control what dataset is used for root.
.Pp
What UEFI computers boot is usually controlled via the mechanisms explained in
.Xr efibootmgr 8
using
.Xr loader.efi 8
or
.Xr boot1.efi 8 .
However, some setups cannot use those mechanisms.
When the users cannot rely on host-supplied UEFI variables
or they want the contents of the media alone to decide root,
.Nm
accomplishes these goals.
.Pp
When it starts,
.Nm
first reads the GPT and determines which drive and partition to
boot from, as described under
.Sx BOOTING ,
below.
If it does not find an eligible partition, it returns to the UEFI
firmware.
The firmware will then try the next bootable item in the UEFI Boot Manager's
list, if any, usually a different disk.
.Sh IMPLEMENTATION NOTES
The GPT standard allows a variable number of partitions, but
.Nm
only boots from tables with 128 partitions or less.
.Sh PARTITION ATTRIBUTES
.Nm
checks and manages several attributes of GPT UFS partitions.
These flags are
.Fx
specific and non-standard.
.Bl -tag -width ".Cm bootfailed"
.It Cm bootme
Attempt to boot from this partition.
If more than one partition has the
.Cm bootme
attribute set,
.Nm
will attempt to boot each one until successful.
.It Cm bootonce
Attempt to boot from this partition only one time.
Setting this attribute with
.Xr gpart 8
automatically also sets the
.Cm bootme
attribute.
Multiple partitions may have the
.Cm bootonce
and
.Cm bootme
attributes set.
.It Cm bootfailed
The
.Cm bootfailed
attribute marks partitions that had the
.Cm bootonce
attribute set, but failed to boot.
This attribute is managed by the system.
See
.Sx "BOOTING"
and
.Sx "POST-BOOT ACTIONS"
below for details.
.El
.Sh USAGE
For normal usage, the user does not have to set or manage any of the
partition attributes.
.Nm
will boot from the first UFS partition found on the device.
.Pp
The
.Cm bootonce
attribute can be used for testing an upgraded operating system on
an already-working computer.
The existing system partition is left untouched, and the new version
of the operating system to be tested is installed on another partition.
The
.Cm bootonce
attribute is set on that new test partition.
The next boot is attempted from the test partition.
Success or failure will be shown in the system log files.
After a successful boot of the test partition, a user script can check
the logs and change the
.Cm bootme
attributes so the test partition becomes the new system partition.
Because the
.Cm bootonce
attribute is cleared after an attempted boot, a failed boot will not
leave the system attempting to boot from a partition that will never
succeed.
Instead, the system will boot from the older, known-working operating
system that has not been modified.
If the
.Cm bootme
attribute is set on any partitions, booting will be attempted from them
first.
If no partitions with
.Cm bootme
attributes are found, booting will be attempted from the first UFS
partition found.
.Sh BOOTING
.Nm
first reads the partition table.
All
.Cm freebsd-ufs
partitions with only the
.Cm bootonce
attribute set, indicating a failed boot, are set to
.Cm bootfailed .
.Nm
then scans through all of the
.Cm freebsd-ufs
partitions.
Boot behavior depends on the combination of
.Cm bootme
and
.Cm bootonce
attributes set on those partitions.
.Bl -tag -width ".Cm bootonce + .Cm bootme"
.It Cm bootonce + Cm bootme
Highest priority: booting is attempted from each of the
.Cm freebsd-ufs
partitions with both of these attributes.
On each partition, the
.Cm bootme
attribute is removed and the boot attempted.
.It Cm bootme
Middle priority: booting is attempted from each of the
.Cm freebsd-ufs
partitions with the
.Cm bootme
attribute.
.El
.Pp
If neither
.Cm bootonce
nor
.Cm bootme
attributes are found on any partitions, booting is attempted from the
first
.Cm freebsd-ufs
partition on the disk.
.Sh POST-BOOT ACTIONS
The startup script
.Pa /etc/rc.d/gptboot
checks the attributes of
.Cm freebsd-ufs
partitions on all GPT disks.
Partitions with the
.Cm bootfailed
attribute generate a
.Dq boot from X failed
system log message.
Partitions with only the
.Cm bootonce
attribute, indicating a partition that successfully booted, generate a
.Dq boot from X succeeded
system log message.
The
.Cm bootfailed
attributes are cleared from all the partitions.
The
.Cm bootonce
attribute is cleared from the partition that successfully booted.
There is normally only one of these.
.Sh FILES
.Bl -tag -width /boot/gptboot.efi -compact
.It Pa /boot/gptboot.efi
bootcode binary
.It Pa /boot/efi/efi/boot/bootx64.efi
Default boot loader for amd64 systems.
.It Pa /boot/efi/efi/boot/bootaa64.efi
Default boot loader for arm64 systems.
.It Pa /boot/efi/efi/boot/bootarm.efi
Default boot loader for arm systems.
.It Pa /boot/efi/efi/boot/bootriscv64.efi
Default boot loader for riscv systems.
.El
.Sh EXAMPLES
.Nm
is installed in the ESP with
.Xr cp 1 .
.Pp
Install
.Nm
into the ESP for the system.
This assumes the ESP is mounted in the standard
.Pa /boot/efi
directory.
For amd64, use the following
.Bd -literal -offset indent -compact
cp /boot/gptboot.efi /boot/efi/efi/boot/bootx64.efi
.Ed
For other systems, use the file listed in the
.Sx FILES
section.
.Pp
Set the
.Cm bootme
attribute for partition 2:
.Bd -literal -offset indent
gpart set -a bootme -i 2 ada0
.Ed
.Pp
Set the
.Cm bootonce
attribute for partition 2, automatically also setting the
.Cm bootme
attribute:
.Bd -literal -offset indent
gpart set -a bootonce -i 2 ada0
.Ed
.Sh SEE ALSO
.Xr rc.conf 5 ,
.Xr boot 8 ,
.Xr efibootmgr 8 ,
.Xr gpart 8 ,
.Xr gptboot 8 ,
.Xr loader.efi 8
.Sh HISTORY
.Nm
appeared in
.Fx 13.0
.Sh AUTHORS
This manual page was written by
.An Warner Losh Aq imp@FreeBSD.org .
It is based heavily on the
.Xr gptboot 8
man page by
.An Warren Block Aq wblock@FreeBSD.org .