From nobody Tue Jan 24 22:09:47 2023 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4P1h3H5Tcqz3bdlc; Tue, 24 Jan 2023 22:09:47 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4P1h3H46nwz4H2x; Tue, 24 Jan 2023 22:09:47 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1674598187; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=1+imdih8NUSrYK9GxQ+aBbKIrQhatCIWxnE+7XuIPvM=; b=i5Gbx7USWEnUx4ZAQwoTW8rGC9NaVbuuWQkz1Rr3wxTOYBmGb14k5YyqijhXn4VIQERQJp 1gPw7X0B9K7QcCzPwOqATukjsQYaiaHgTZy7vI1MSo0OxZkPS6en6elECOslw8CcsZarLa soh9g+G29k2yqF8mk/+ycCbbMhwdsFJikiZVF3w/97PR+FxtNIuTJCczarVxUqnM68QfsA 7/qZaDR+ycUHwoF1pwqAwheFXEtJkbM0fwDQ8dPAtz0gok0oTpbENA+tFdTZAz4XaDkT/D h/tuj2+jng5U03MAZSDN3aRilrBBjE3K2g3xHMnz8hUMWNb0kH6hkSBWZfbDKQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1674598187; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=1+imdih8NUSrYK9GxQ+aBbKIrQhatCIWxnE+7XuIPvM=; b=yFU7Q3N7V1HIWPSnr8Zk54+3IRstfx5wO1KMTvFQtM5WR8PvMC3TI7aw4E8sH8ddNK3jNl 66feLxrsmPad6w5XUpNKhsXZB9JTL7WS7UO7a5y25HbiNc/56lH9kLTR1pPj7rQ62ok3e9 GK9uXOn9gMRrcUCW9j+SJknnqaR8xNGnxcninYrC9nm+6O15Ss3QYM5PII4lmM1ZJduL9r ke9f/E9Y52Cvkn9UeKUabrGITVL7fLbN4h2Hyc66eC/0v49RLaXCqTBLc6zPmVgG7CS7jX U+gCuEuxb0AuppUt6ygUGQS6pUnmt9nYgL4/iNX06mZhi66/wUBJAI0jQrTteA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1674598187; a=rsa-sha256; cv=none; b=WIDQx4GuqiSndmJWKfua1mTAygqioEPk7DNIeykGTd78ZQvcLsFjnxH3FUsJH5F/D9V56l XwCGasJjizQZP4LIBwSBu9Jrud0nvLIWxEyA9Q8jfDq70eKir8fQyB0y7RCD0Q9bjULD1q efmew7q5wpGzyC+TuTFv2Ib4m7fpQNjAvt6FZLk89oXhTS2JEg6qJjlURc/lGj4Iqnr/sY W4K+Ok641s71mp5D87t99qDRlfyx/QD9ortc1G8wDF0XYW8aESKNmIVJo78UXB++VHtQjo dV+qLHJBPnZoW7d1OIQOzmKLoTBbNiP6C2+VAj60sxT4RfOY1qhV1AsRueAMKw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4P1h3H3Cy6zQ7K; Tue, 24 Jan 2023 22:09:47 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 30OM9lE9070772; Tue, 24 Jan 2023 22:09:47 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 30OM9lG1070771; Tue, 24 Jan 2023 22:09:47 GMT (envelope-from git) Date: Tue, 24 Jan 2023 22:09:47 GMT Message-Id: <202301242209.30OM9lG1070771@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Warner Losh Subject: git: a12800fd291e - stable/13 - gptboot.efi: Add man page List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: imp X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: a12800fd291e9551147cc9d1fb6ae6c6612592fc Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=a12800fd291e9551147cc9d1fb6ae6c6612592fc commit a12800fd291e9551147cc9d1fb6ae6c6612592fc Author: Warner Losh AuthorDate: 2021-04-06 05:55:08 +0000 Commit: Warner Losh CommitDate: 2023-01-24 21:49:16 +0000 gptboot.efi: Add man page Add a man page for gptboot.efi. Describe when and how to use this as it differs from the BIOS cases. Include cross reference for the preferred method described in efibootmgr(8) as well as cross links in both gptboot(8) and gptboot.efi(8) to the other. This man page was heavily copied from the gptboot.8 man page by Warren Block. They are different enough to need separate man pages for clarity, but there's enough similarity that I worry about the duplication. In the really long term, gptboot(8) will disappear, so having the same info here will help when that day comes. In the short to medium term, the information is likely to not change in gptboot(8) and any changes to gptboot.efi(8) will be easier to make in a separate copy. loader.efi(8) needs a complete rewrite from scratch, otherwise I'd have referenced gptboot.efi(8) from there. Suggetions from: cress@, mhorne@ Reviewed by: rpokala@ Differential Revision: https://reviews.freebsd.org/D29591 (cherry picked from commit 42cd37dfbd1b2feff8f7aba32d2577e08b058231) Sponsored by: Netflix --- stand/efi/gptboot/Makefile | 1 + stand/efi/gptboot/gptboot.efi.8 | 282 ++++++++++++++++++++++++++++++++++++++++ stand/i386/gptboot/gptboot.8 | 6 +- stand/man/boot1.efi.8 | 14 +- 4 files changed, 300 insertions(+), 3 deletions(-) diff --git a/stand/efi/gptboot/Makefile b/stand/efi/gptboot/Makefile index 7d6dee85f93f..2dcf8dda8f59 100644 --- a/stand/efi/gptboot/Makefile +++ b/stand/efi/gptboot/Makefile @@ -6,6 +6,7 @@ MK_LOADER_ZFS=no EFI_DEBUG=yes BOOT1?= gptboot +MAN= gptboot.efi.8 .PATH: ${SRCTOP}/stand/efi/boot1 ${SRCTOP}/stand/libsa CFLAGS+= -I${SRCTOP}/stand/efi/boot1 CFLAGS+= -I${.CURDIR} diff --git a/stand/efi/gptboot/gptboot.efi.8 b/stand/efi/gptboot/gptboot.efi.8 new file mode 100644 index 000000000000..134c5353e9f1 --- /dev/null +++ b/stand/efi/gptboot/gptboot.efi.8 @@ -0,0 +1,282 @@ +.\" 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. +.\" +.\" $FreeBSD$ +.\" +.Dd April 6, 2021 +.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 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 . diff --git a/stand/i386/gptboot/gptboot.8 b/stand/i386/gptboot/gptboot.8 index b812cdbefffc..e68d73758f89 100644 --- a/stand/i386/gptboot/gptboot.8 +++ b/stand/i386/gptboot/gptboot.8 @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd March 18, 2022 +.Dd January 23, 2023 .Dt GPTBOOT 8 .Os .Sh NAME @@ -39,6 +39,10 @@ is installed in a .Cm freebsd-boot partition with .Xr gpart 8 . +For UEFI, +.Xr gptboot.efi 8 +is used instead. +While conceptually similar, the details differ. .Pp When it starts, .Nm diff --git a/stand/man/boot1.efi.8 b/stand/man/boot1.efi.8 index 74758a0c5660..efd3c2c93d5e 100644 --- a/stand/man/boot1.efi.8 +++ b/stand/man/boot1.efi.8 @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd September 1, 2020 +.Dd April 6, 2021 .Dt BOOT1.EFI 8 .Os .Sh NAME @@ -33,13 +33,19 @@ .Sh DESCRIPTION .Nm has been deprecated and will be removed from a future release. -.Xr loader.efi 8 handles all its former use cases with more flexibility. +.Xr loader.efi 8 +handles all its former use cases with more flexibility. .Pp On UEFI systems, .Nm loads .Pa /boot/loader.efi from the default root file system and transfers execution there. +Some systems may need to use +.Xr gptboot.efi 8 +when +.Xr loader.efi 8 +cannot be used directly on the ESP (EFI System Partition). .Ss Initialization Before looking for the boot device, .Nm @@ -94,6 +100,10 @@ When configuring a serial console for FreeBSD, but not for UEFI, no output will show up on the serial console from boot1.efi. .It There's no support for marking partitions as the preferred one. +See +.Xr gptboot.efi 8 . .It There's no support for boot-once functionality. +See +.Xr gptboot.efi 8 . .El