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.\" 25*e405ae30SMateusz Piotrowski.Dd March 18, 2022 26ca987d46SWarner Losh.Dt GPTBOOT 8 27ca987d46SWarner Losh.Os 28ca987d46SWarner Losh.Sh NAME 29ca987d46SWarner Losh.Nm gptboot 30ca987d46SWarner Losh.Nd GPT bootcode for UFS on BIOS-based computers 31ca987d46SWarner Losh.Sh DESCRIPTION 32ca987d46SWarner Losh.Nm 33ca987d46SWarner Loshis used on BIOS-based computers to boot from a UFS partition on a 34ca987d46SWarner LoshGPT-partitioned disk. 35ca987d46SWarner Losh.Nm 36ca987d46SWarner Loshis installed in a 37ca987d46SWarner Losh.Cm freebsd-boot 38ca987d46SWarner Loshpartition with 39ca987d46SWarner Losh.Xr gpart 8 . 4042cd37dfSWarner LoshFor UEFI, 4142cd37dfSWarner Losh.Xr gptboot.efi 8 4242cd37dfSWarner Loshis used instead. 4342cd37dfSWarner LoshWhile conceptually similar, the details differ. 44ba761eacSIan Lepore.Pp 45ba761eacSIan LeporeWhen it starts, 46ba761eacSIan Lepore.Nm 47ba761eacSIan Leporefirst reads the GPT and determines which drive and partition to 48ba761eacSIan Leporeboot from, as described under 49ba761eacSIan Lepore.Sx BOOTING , 50ba761eacSIan Leporebelow. 51ba761eacSIan LeporeIf it does not find an eligible partition, or if the user hits a 52ba761eacSIan Leporekey within three seconds, 53ba761eacSIan Lepore.Nm 54ba761eacSIan Leporeswitches from auto-boot to interactive mode. 55ba761eacSIan LeporeInteractive mode allows manual selection of the disk, partition, 56ba761eacSIan Leporefilename, and boot option flags, as described in 57ba761eacSIan Lepore.Xr boot 8 . 58ca987d46SWarner Losh.Sh IMPLEMENTATION NOTES 59ca987d46SWarner LoshThe GPT standard allows a variable number of partitions, but 60ca987d46SWarner Losh.Nm 61ca987d46SWarner Loshonly boots from tables with 128 partitions or less. 62ca987d46SWarner Losh.Sh PARTITION ATTRIBUTES 63ca987d46SWarner Losh.Nm 64ca987d46SWarner Loshchecks and manages several attributes of GPT UFS partitions. 65ca987d46SWarner Losh.Bl -tag -width ".Cm bootfailed" 66ca987d46SWarner Losh.It Cm bootme 67ca987d46SWarner LoshAttempt to boot from this partition. 68ca987d46SWarner LoshIf more than one partition has the 69ca987d46SWarner Losh.Cm bootme 70ca987d46SWarner Loshattribute set, 71ca987d46SWarner Losh.Nm 72ca987d46SWarner Loshwill attempt to boot each one until successful. 73ca987d46SWarner Losh.It Cm bootonce 74ca987d46SWarner LoshAttempt to boot from this partition only one time. 75ca987d46SWarner LoshSetting this attribute with 76ca987d46SWarner Losh.Xr gpart 8 77ca987d46SWarner Loshautomatically also sets the 78ca987d46SWarner Losh.Cm bootme 79ca987d46SWarner Loshattribute. 80ca987d46SWarner LoshMultiple partitions may have the 81ca987d46SWarner Losh.Cm bootonce 82ca987d46SWarner Loshand 83ca987d46SWarner Losh.Cm bootme 84ca987d46SWarner Loshattributes set. 85ca987d46SWarner Losh.It Cm bootfailed 86ca987d46SWarner LoshThe 87ca987d46SWarner Losh.Cm bootfailed 88ca987d46SWarner Loshattribute marks partitions that had the 89ca987d46SWarner Losh.Cm bootonce 90ca987d46SWarner Loshattribute set, but failed to boot. 91ca987d46SWarner LoshThis attribute is managed by the system. 92ca987d46SWarner LoshSee 93ca987d46SWarner Losh.Sx "BOOTING" 94ca987d46SWarner Loshand 95ca987d46SWarner Losh.Sx "POST-BOOT ACTIONS" 96ca987d46SWarner Loshbelow for details. 97ca987d46SWarner Losh.El 98ca987d46SWarner Losh.Sh USAGE 99ca987d46SWarner LoshFor normal usage, the user does not have to set or manage any of the 100ca987d46SWarner Loshpartition attributes. 101ca987d46SWarner Losh.Nm 102ca987d46SWarner Loshwill boot from the first UFS partition found. 103ca987d46SWarner Losh.Pp 104ca987d46SWarner LoshThe 105ca987d46SWarner Losh.Cm bootonce 106ca987d46SWarner Loshattribute can be used for testing an upgraded operating system on 107ca987d46SWarner Loshan already-working computer. 108ca987d46SWarner LoshThe existing system partition is left untouched, and the new version 109ca987d46SWarner Loshof the operating system to be tested is installed on another partition. 110ca987d46SWarner LoshThe 111ca987d46SWarner Losh.Cm bootonce 112ca987d46SWarner Loshattribute is set on that new test partition. 113ca987d46SWarner LoshThe next boot is attempted from the test partition. 114ca987d46SWarner LoshSuccess or failure will be shown in the system log files. 115ca987d46SWarner LoshAfter a successful boot of the test partition, a user script can check 116ca987d46SWarner Loshthe logs and change the 117ca987d46SWarner Losh.Cm bootme 118ca987d46SWarner Loshattributes so the test partition becomes the new system partition. 119ca987d46SWarner LoshBecause the 120ca987d46SWarner Losh.Cm bootonce 121ca987d46SWarner Loshattribute is cleared after an attempted boot, a failed boot will not 122ca987d46SWarner Loshleave the system attempting to boot from a partition that will never 123ca987d46SWarner Loshsucceed. 124ca987d46SWarner LoshInstead, the system will boot from the older, known-working operating 125ca987d46SWarner Loshsystem that has not been modified. 126ca987d46SWarner LoshIf the 127ca987d46SWarner Losh.Cm bootme 128ca987d46SWarner Loshattribute is set on any partitions, booting will be attempted from them 129ca987d46SWarner Loshfirst. 130ca987d46SWarner LoshIf no partitions with 131ca987d46SWarner Losh.Cm bootme 132ca987d46SWarner Loshattributes are found, booting will be attempted from the first UFS 133ca987d46SWarner Loshpartition found. 134ca987d46SWarner Losh.Sh BOOTING 135ca987d46SWarner Losh.Nm 136ca987d46SWarner Loshfirst reads the partition table. 137ca987d46SWarner LoshAll 138ca987d46SWarner Losh.Cm freebsd-ufs 139ca987d46SWarner Loshpartitions with only the 140ca987d46SWarner Losh.Cm bootonce 141ca987d46SWarner Loshattribute set, indicating a failed boot, are set to 142ca987d46SWarner Losh.Cm bootfailed . 143ca987d46SWarner Losh.Nm 144ca987d46SWarner Loshthen scans through all of the 145ca987d46SWarner Losh.Cm freebsd-ufs 146ca987d46SWarner Loshpartitions. 147ca987d46SWarner LoshBoot behavior depends on the combination of 148ca987d46SWarner Losh.Cm bootme 149ca987d46SWarner Loshand 150ca987d46SWarner Losh.Cm bootonce 151ca987d46SWarner Loshattributes set on those partitions. 152ca987d46SWarner Losh.Bl -tag -width ".Cm bootonce + .Cm bootme" 153ca987d46SWarner Losh.It Cm bootonce + Cm bootme 154ca987d46SWarner LoshHighest priority: booting is attempted from each of the 155ca987d46SWarner Losh.Cm freebsd-ufs 156ca987d46SWarner Loshpartitions with both of these attributes. 157ca987d46SWarner LoshOn each partition, the 158ca987d46SWarner Losh.Cm bootme 159ca987d46SWarner Loshattribute is removed and the boot attempted. 160ca987d46SWarner Losh.It Cm bootme 161ca987d46SWarner LoshMiddle priority: booting is attempted from each of the 162ca987d46SWarner Losh.Cm freebsd-ufs 163ca987d46SWarner Loshpartitions with the 164ca987d46SWarner Losh.Cm bootme 165ca987d46SWarner Loshattribute. 166ca987d46SWarner Losh.El 167ca987d46SWarner Losh.Pp 168ca987d46SWarner LoshIf neither 169ca987d46SWarner Losh.Cm bootonce 170ca987d46SWarner Loshnor 171ca987d46SWarner Losh.Cm bootme 172ca987d46SWarner Loshattributes are found on any partitions, booting is attempted from the 173ca987d46SWarner Loshfirst 174ca987d46SWarner Losh.Cm freebsd-ufs 175ca987d46SWarner Loshpartition on the disk. 176ca987d46SWarner Losh.Sh POST-BOOT ACTIONS 177ca987d46SWarner LoshThe startup script 178ca987d46SWarner Losh.Pa /etc/rc.d/gptboot 179ca987d46SWarner Loshchecks the attributes of 180ca987d46SWarner Losh.Cm freebsd-ufs 181ca987d46SWarner Loshpartitions on all GPT disks. 182ca987d46SWarner LoshPartitions with the 183ca987d46SWarner Losh.Cm bootfailed 184ca987d46SWarner Loshattribute generate a 185ca987d46SWarner Losh.Dq boot from X failed 186ca987d46SWarner Loshsystem log message. 187ca987d46SWarner LoshPartitions with only the 188ca987d46SWarner Losh.Cm bootonce 189ca987d46SWarner Loshattribute, indicating a partition that successfully booted, generate a 190ca987d46SWarner Losh.Dq boot from X succeeded 191ca987d46SWarner Loshsystem log message. 192ca987d46SWarner LoshThe 193ca987d46SWarner Losh.Cm bootfailed 194ca987d46SWarner Loshattributes are cleared from all the partitions. 195ca987d46SWarner LoshThe 196ca987d46SWarner Losh.Cm bootonce 197ca987d46SWarner Loshattribute is cleared from the partition that successfully booted. 198ca987d46SWarner LoshThere is normally only one of these. 199ca987d46SWarner Losh.Sh FILES 200ca987d46SWarner Losh.Bl -tag -width /boot/gptboot -compact 201ca987d46SWarner Losh.It Pa /boot/gptboot 202ca987d46SWarner Loshbootcode binary 203ca987d46SWarner Losh.It Pa /boot.config 204ca987d46SWarner Loshparameters for the boot blocks 205ca987d46SWarner Losh.Pq optional 206ca987d46SWarner Losh.El 207ca987d46SWarner Losh.Sh EXAMPLES 208ca987d46SWarner Losh.Nm 209ca987d46SWarner Loshis installed in a 210ca987d46SWarner Losh.Cm freebsd-boot 211ca987d46SWarner Loshpartition, usually the first partition on the disk. 212ca987d46SWarner LoshA 213ca987d46SWarner Losh.Dq protective MBR 214ca987d46SWarner Losh.Po 215ca987d46SWarner Loshsee 216ca987d46SWarner Losh.Xr gpart 8 217ca987d46SWarner Losh.Pc 218ca987d46SWarner Loshis typically installed in combination with 219ca987d46SWarner Losh.Nm . 220ca987d46SWarner Losh.Pp 221ca987d46SWarner LoshInstall 222ca987d46SWarner Losh.Nm 223ca987d46SWarner Loshon the 224ca987d46SWarner Losh.Pa ada0 225ca987d46SWarner Loshdrive: 226ca987d46SWarner Losh.Bd -literal -offset indent 227ca987d46SWarner Loshgpart bootcode -b /boot/pmbr -p /boot/gptboot -i 1 ada0 228ca987d46SWarner Losh.Ed 229ca987d46SWarner Losh.Pp 230ca987d46SWarner Losh.Nm 231ca987d46SWarner Loshcan also be installed without the PMBR: 232ca987d46SWarner Losh.Bd -literal -offset indent 233ca987d46SWarner Loshgpart bootcode -p /boot/gptboot -i 1 ada0 234ca987d46SWarner Losh.Ed 235ca987d46SWarner Losh.Pp 236ca987d46SWarner LoshSet the 237ca987d46SWarner Losh.Cm bootme 238ca987d46SWarner Loshattribute for partition 2: 239ca987d46SWarner Losh.Bd -literal -offset indent 240ca987d46SWarner Loshgpart set -a bootme -i 2 ada0 241ca987d46SWarner Losh.Ed 242ca987d46SWarner Losh.Pp 243ca987d46SWarner LoshSet the 244ca987d46SWarner Losh.Cm bootonce 245ca987d46SWarner Loshattribute for partition 2, automatically also setting the 246ca987d46SWarner Losh.Cm bootme 247ca987d46SWarner Loshattribute: 248ca987d46SWarner Losh.Bd -literal -offset indent 249ca987d46SWarner Loshgpart set -a bootonce -i 2 ada0 250ca987d46SWarner Losh.Ed 251ca987d46SWarner Losh.Sh SEE ALSO 252ca987d46SWarner Losh.Xr boot.config 5 , 253ca987d46SWarner Losh.Xr rc.conf 5 , 254ca987d46SWarner Losh.Xr boot 8 , 255ca987d46SWarner Losh.Xr gpart 8 256ca987d46SWarner Losh.Sh HISTORY 257ca987d46SWarner Losh.Nm 258*e405ae30SMateusz Piotrowskiappeared in 259*e405ae30SMateusz Piotrowski.Fx 7.1 . 260ca987d46SWarner Losh.Sh AUTHORS 261*e405ae30SMateusz PiotrowskiThis manual page was written by 262ca987d46SWarner Losh.An Warren Block Aq wblock@FreeBSD.org . 263