1ca987d46SWarner Losh.\" Copyright (c) 2013 Warren Block 2ca987d46SWarner Losh.\" All rights reserved. 3ca987d46SWarner Losh.\" 4ca987d46SWarner Losh.\" Redistribution and use in source and binary forms, with or without 5ca987d46SWarner Losh.\" modification, are permitted provided that the following conditions 6ca987d46SWarner Losh.\" are met: 7ca987d46SWarner Losh.\" 1. Redistributions of source code must retain the above copyright 8ca987d46SWarner Losh.\" notice, this list of conditions and the following disclaimer. 9ca987d46SWarner Losh.\" 2. Redistributions in binary form must reproduce the above copyright 10ca987d46SWarner Losh.\" notice, this list of conditions and the following disclaimer in the 11ca987d46SWarner Losh.\" documentation and/or other materials provided with the distribution. 12ca987d46SWarner Losh.\" 13ca987d46SWarner Losh.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND 14ca987d46SWarner Losh.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 15ca987d46SWarner Losh.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 16ca987d46SWarner Losh.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE 17ca987d46SWarner Losh.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18ca987d46SWarner Losh.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 19ca987d46SWarner Losh.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20ca987d46SWarner Losh.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 21ca987d46SWarner Losh.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 22ca987d46SWarner Losh.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 23ca987d46SWarner Losh.\" SUCH DAMAGE. 24ca987d46SWarner Losh.\" 25ca987d46SWarner Losh.\" $FreeBSD$ 26ca987d46SWarner Losh.\" 27*42cd37dfSWarner Losh.Dd April 6, 2021 28ca987d46SWarner Losh.Dt GPTBOOT 8 29ca987d46SWarner Losh.Os 30ca987d46SWarner Losh.Sh NAME 31ca987d46SWarner Losh.Nm gptboot 32ca987d46SWarner Losh.Nd GPT bootcode for UFS on BIOS-based computers 33ca987d46SWarner Losh.Sh DESCRIPTION 34ca987d46SWarner Losh.Nm 35ca987d46SWarner Loshis used on BIOS-based computers to boot from a UFS partition on a 36ca987d46SWarner LoshGPT-partitioned disk. 37ca987d46SWarner Losh.Nm 38ca987d46SWarner Loshis installed in a 39ca987d46SWarner Losh.Cm freebsd-boot 40ca987d46SWarner Loshpartition with 41ca987d46SWarner Losh.Xr gpart 8 . 42*42cd37dfSWarner LoshFor UEFI, 43*42cd37dfSWarner Losh.Xr gptboot.efi 8 44*42cd37dfSWarner Loshis used instead. 45*42cd37dfSWarner LoshWhile conceptually similar, the details differ. 46ba761eacSIan Lepore.Pp 47ba761eacSIan LeporeWhen it starts, 48ba761eacSIan Lepore.Nm 49ba761eacSIan Leporefirst reads the GPT and determines which drive and partition to 50ba761eacSIan Leporeboot from, as described under 51ba761eacSIan Lepore.Sx BOOTING , 52ba761eacSIan Leporebelow. 53ba761eacSIan LeporeIf it does not find an eligible partition, or if the user hits a 54ba761eacSIan Leporekey within three seconds, 55ba761eacSIan Lepore.Nm 56ba761eacSIan Leporeswitches from auto-boot to interactive mode. 57ba761eacSIan LeporeInteractive mode allows manual selection of the disk, partition, 58ba761eacSIan Leporefilename, and boot option flags, as described in 59ba761eacSIan Lepore.Xr boot 8 . 60ca987d46SWarner Losh.Sh IMPLEMENTATION NOTES 61ca987d46SWarner LoshThe GPT standard allows a variable number of partitions, but 62ca987d46SWarner Losh.Nm 63ca987d46SWarner Loshonly boots from tables with 128 partitions or less. 64ca987d46SWarner Losh.Sh PARTITION ATTRIBUTES 65ca987d46SWarner Losh.Nm 66ca987d46SWarner Loshchecks and manages several attributes of GPT UFS partitions. 67ca987d46SWarner Losh.Bl -tag -width ".Cm bootfailed" 68ca987d46SWarner Losh.It Cm bootme 69ca987d46SWarner LoshAttempt to boot from this partition. 70ca987d46SWarner LoshIf more than one partition has the 71ca987d46SWarner Losh.Cm bootme 72ca987d46SWarner Loshattribute set, 73ca987d46SWarner Losh.Nm 74ca987d46SWarner Loshwill attempt to boot each one until successful. 75ca987d46SWarner Losh.It Cm bootonce 76ca987d46SWarner LoshAttempt to boot from this partition only one time. 77ca987d46SWarner LoshSetting this attribute with 78ca987d46SWarner Losh.Xr gpart 8 79ca987d46SWarner Loshautomatically also sets the 80ca987d46SWarner Losh.Cm bootme 81ca987d46SWarner Loshattribute. 82ca987d46SWarner LoshMultiple partitions may have the 83ca987d46SWarner Losh.Cm bootonce 84ca987d46SWarner Loshand 85ca987d46SWarner Losh.Cm bootme 86ca987d46SWarner Loshattributes set. 87ca987d46SWarner Losh.It Cm bootfailed 88ca987d46SWarner LoshThe 89ca987d46SWarner Losh.Cm bootfailed 90ca987d46SWarner Loshattribute marks partitions that had the 91ca987d46SWarner Losh.Cm bootonce 92ca987d46SWarner Loshattribute set, but failed to boot. 93ca987d46SWarner LoshThis attribute is managed by the system. 94ca987d46SWarner LoshSee 95ca987d46SWarner Losh.Sx "BOOTING" 96ca987d46SWarner Loshand 97ca987d46SWarner Losh.Sx "POST-BOOT ACTIONS" 98ca987d46SWarner Loshbelow for details. 99ca987d46SWarner Losh.El 100ca987d46SWarner Losh.Sh USAGE 101ca987d46SWarner LoshFor normal usage, the user does not have to set or manage any of the 102ca987d46SWarner Loshpartition attributes. 103ca987d46SWarner Losh.Nm 104ca987d46SWarner Loshwill boot from the first UFS partition found. 105ca987d46SWarner Losh.Pp 106ca987d46SWarner LoshThe 107ca987d46SWarner Losh.Cm bootonce 108ca987d46SWarner Loshattribute can be used for testing an upgraded operating system on 109ca987d46SWarner Loshan already-working computer. 110ca987d46SWarner LoshThe existing system partition is left untouched, and the new version 111ca987d46SWarner Loshof the operating system to be tested is installed on another partition. 112ca987d46SWarner LoshThe 113ca987d46SWarner Losh.Cm bootonce 114ca987d46SWarner Loshattribute is set on that new test partition. 115ca987d46SWarner LoshThe next boot is attempted from the test partition. 116ca987d46SWarner LoshSuccess or failure will be shown in the system log files. 117ca987d46SWarner LoshAfter a successful boot of the test partition, a user script can check 118ca987d46SWarner Loshthe logs and change the 119ca987d46SWarner Losh.Cm bootme 120ca987d46SWarner Loshattributes so the test partition becomes the new system partition. 121ca987d46SWarner LoshBecause the 122ca987d46SWarner Losh.Cm bootonce 123ca987d46SWarner Loshattribute is cleared after an attempted boot, a failed boot will not 124ca987d46SWarner Loshleave the system attempting to boot from a partition that will never 125ca987d46SWarner Loshsucceed. 126ca987d46SWarner LoshInstead, the system will boot from the older, known-working operating 127ca987d46SWarner Loshsystem that has not been modified. 128ca987d46SWarner LoshIf the 129ca987d46SWarner Losh.Cm bootme 130ca987d46SWarner Loshattribute is set on any partitions, booting will be attempted from them 131ca987d46SWarner Loshfirst. 132ca987d46SWarner LoshIf no partitions with 133ca987d46SWarner Losh.Cm bootme 134ca987d46SWarner Loshattributes are found, booting will be attempted from the first UFS 135ca987d46SWarner Loshpartition found. 136ca987d46SWarner Losh.Sh BOOTING 137ca987d46SWarner Losh.Nm 138ca987d46SWarner Loshfirst reads the partition table. 139ca987d46SWarner LoshAll 140ca987d46SWarner Losh.Cm freebsd-ufs 141ca987d46SWarner Loshpartitions with only the 142ca987d46SWarner Losh.Cm bootonce 143ca987d46SWarner Loshattribute set, indicating a failed boot, are set to 144ca987d46SWarner Losh.Cm bootfailed . 145ca987d46SWarner Losh.Nm 146ca987d46SWarner Loshthen scans through all of the 147ca987d46SWarner Losh.Cm freebsd-ufs 148ca987d46SWarner Loshpartitions. 149ca987d46SWarner LoshBoot behavior depends on the combination of 150ca987d46SWarner Losh.Cm bootme 151ca987d46SWarner Loshand 152ca987d46SWarner Losh.Cm bootonce 153ca987d46SWarner Loshattributes set on those partitions. 154ca987d46SWarner Losh.Bl -tag -width ".Cm bootonce + .Cm bootme" 155ca987d46SWarner Losh.It Cm bootonce + Cm bootme 156ca987d46SWarner LoshHighest priority: booting is attempted from each of the 157ca987d46SWarner Losh.Cm freebsd-ufs 158ca987d46SWarner Loshpartitions with both of these attributes. 159ca987d46SWarner LoshOn each partition, the 160ca987d46SWarner Losh.Cm bootme 161ca987d46SWarner Loshattribute is removed and the boot attempted. 162ca987d46SWarner Losh.It Cm bootme 163ca987d46SWarner LoshMiddle priority: booting is attempted from each of the 164ca987d46SWarner Losh.Cm freebsd-ufs 165ca987d46SWarner Loshpartitions with the 166ca987d46SWarner Losh.Cm bootme 167ca987d46SWarner Loshattribute. 168ca987d46SWarner Losh.El 169ca987d46SWarner Losh.Pp 170ca987d46SWarner LoshIf neither 171ca987d46SWarner Losh.Cm bootonce 172ca987d46SWarner Loshnor 173ca987d46SWarner Losh.Cm bootme 174ca987d46SWarner Loshattributes are found on any partitions, booting is attempted from the 175ca987d46SWarner Loshfirst 176ca987d46SWarner Losh.Cm freebsd-ufs 177ca987d46SWarner Loshpartition on the disk. 178ca987d46SWarner Losh.Sh POST-BOOT ACTIONS 179ca987d46SWarner LoshThe startup script 180ca987d46SWarner Losh.Pa /etc/rc.d/gptboot 181ca987d46SWarner Loshchecks the attributes of 182ca987d46SWarner Losh.Cm freebsd-ufs 183ca987d46SWarner Loshpartitions on all GPT disks. 184ca987d46SWarner LoshPartitions with the 185ca987d46SWarner Losh.Cm bootfailed 186ca987d46SWarner Loshattribute generate a 187ca987d46SWarner Losh.Dq boot from X failed 188ca987d46SWarner Loshsystem log message. 189ca987d46SWarner LoshPartitions with only the 190ca987d46SWarner Losh.Cm bootonce 191ca987d46SWarner Loshattribute, indicating a partition that successfully booted, generate a 192ca987d46SWarner Losh.Dq boot from X succeeded 193ca987d46SWarner Loshsystem log message. 194ca987d46SWarner LoshThe 195ca987d46SWarner Losh.Cm bootfailed 196ca987d46SWarner Loshattributes are cleared from all the partitions. 197ca987d46SWarner LoshThe 198ca987d46SWarner Losh.Cm bootonce 199ca987d46SWarner Loshattribute is cleared from the partition that successfully booted. 200ca987d46SWarner LoshThere is normally only one of these. 201ca987d46SWarner Losh.Sh FILES 202ca987d46SWarner Losh.Bl -tag -width /boot/gptboot -compact 203ca987d46SWarner Losh.It Pa /boot/gptboot 204ca987d46SWarner Loshbootcode binary 205ca987d46SWarner Losh.It Pa /boot.config 206ca987d46SWarner Loshparameters for the boot blocks 207ca987d46SWarner Losh.Pq optional 208ca987d46SWarner Losh.El 209ca987d46SWarner Losh.Sh EXAMPLES 210ca987d46SWarner Losh.Nm 211ca987d46SWarner Loshis installed in a 212ca987d46SWarner Losh.Cm freebsd-boot 213ca987d46SWarner Loshpartition, usually the first partition on the disk. 214ca987d46SWarner LoshA 215ca987d46SWarner Losh.Dq protective MBR 216ca987d46SWarner Losh.Po 217ca987d46SWarner Loshsee 218ca987d46SWarner Losh.Xr gpart 8 219ca987d46SWarner Losh.Pc 220ca987d46SWarner Loshis typically installed in combination with 221ca987d46SWarner Losh.Nm . 222ca987d46SWarner Losh.Pp 223ca987d46SWarner LoshInstall 224ca987d46SWarner Losh.Nm 225ca987d46SWarner Loshon the 226ca987d46SWarner Losh.Pa ada0 227ca987d46SWarner Loshdrive: 228ca987d46SWarner Losh.Bd -literal -offset indent 229ca987d46SWarner Loshgpart bootcode -b /boot/pmbr -p /boot/gptboot -i 1 ada0 230ca987d46SWarner Losh.Ed 231ca987d46SWarner Losh.Pp 232ca987d46SWarner Losh.Nm 233ca987d46SWarner Loshcan also be installed without the PMBR: 234ca987d46SWarner Losh.Bd -literal -offset indent 235ca987d46SWarner Loshgpart bootcode -p /boot/gptboot -i 1 ada0 236ca987d46SWarner Losh.Ed 237ca987d46SWarner Losh.Pp 238ca987d46SWarner LoshSet the 239ca987d46SWarner Losh.Cm bootme 240ca987d46SWarner Loshattribute for partition 2: 241ca987d46SWarner Losh.Bd -literal -offset indent 242ca987d46SWarner Loshgpart set -a bootme -i 2 ada0 243ca987d46SWarner Losh.Ed 244ca987d46SWarner Losh.Pp 245ca987d46SWarner LoshSet the 246ca987d46SWarner Losh.Cm bootonce 247ca987d46SWarner Loshattribute for partition 2, automatically also setting the 248ca987d46SWarner Losh.Cm bootme 249ca987d46SWarner Loshattribute: 250ca987d46SWarner Losh.Bd -literal -offset indent 251ca987d46SWarner Loshgpart set -a bootonce -i 2 ada0 252ca987d46SWarner Losh.Ed 253ca987d46SWarner Losh.Sh SEE ALSO 254ca987d46SWarner Losh.Xr boot.config 5 , 255ca987d46SWarner Losh.Xr rc.conf 5 , 256ca987d46SWarner Losh.Xr boot 8 , 257ca987d46SWarner Losh.Xr gpart 8 258ca987d46SWarner Losh.Sh HISTORY 259ca987d46SWarner Losh.Nm 260ca987d46SWarner Loshappeared in FreeBSD 7.1. 261ca987d46SWarner Losh.Sh AUTHORS 262ca987d46SWarner LoshThis manual page written by 263ca987d46SWarner Losh.An Warren Block Aq wblock@FreeBSD.org . 264