Changeset View
Changeset View
Standalone View
Standalone View
usr.sbin/bsdinstall/scripts/bootconfig
Show First 20 Lines • Show All 118 Lines • ▼ Show 20 Lines | for geom in $(gpart status -sg | awk '{print $1}'); do | ||||
else | else | ||||
umount "${mntpt}" | umount "${mntpt}" | ||||
fi | fi | ||||
rmdir "${mntpt}" | rmdir "${mntpt}" | ||||
fi | fi | ||||
done | done | ||||
fi | fi | ||||
case $(uname -m) in | |||||
arm64) ARCHBOOTNAME=aa64 ;; | |||||
emaste: style nit - other bsdinstall source lines up the cases themselves under `case` | |||||
amd64) ARCHBOOTNAME=x64 ;; | |||||
# arm) ARCHBOOTNAME=arm ;; # No other support for arm install | |||||
# i386) ARCHBOOTNAME=ia32 ;; # no support for this in i386 kernels, rare machines | |||||
*) die "Unsupported arch $(uname -m) for UEFI install" | |||||
esac | |||||
BOOTNAME="/EFI/BOOT/BOOT${ARCHBOOTNAME}.EFI" | |||||
Not Done Inline ActionsDo we want BOOTx64.EFI or bootx64.efi emaste: Do we want `BOOTx64.EFI` or `bootx64.efi` | |||||
Not Done Inline ActionsSince the EFI partition has a FAT filesystem which isn't case-sensitive it doesn't matter. bcran: Since the EFI partition has a FAT filesystem which isn't case-sensitive it doesn't matter. | |||||
for esp in $ESPS; do | for esp in $ESPS; do | ||||
f_dprintf "Formatting /dev/${esp} as FAT32" | f_dprintf "Formatting /dev/${esp} as FAT32" | ||||
newfs_msdos -F 32 -c 1 -L EFISYS "/dev/$esp" > /dev/null 2>&1 | newfs_msdos -F 32 -c 1 -L EFISYS "/dev/$esp" > /dev/null 2>&1 | ||||
if [ $? -ne 0 ]; then | if [ $? -ne 0 ]; then | ||||
die "Failed to format ESP $esp as FAT32" | die "Failed to format ESP $esp as FAT32" | ||||
fi | fi | ||||
mntpt=$(mktemp -d $TMPDIR/stand-test.XXXXXX) | mntpt=$(mktemp -d $TMPDIR/stand-test.XXXXXX) | ||||
f_dprintf "Mounting ESP /dev/${esp}" | f_dprintf "Mounting ESP /dev/${esp}" | ||||
mount -t msdosfs "/dev/${esp}" "${mntpt}" | mount -t msdosfs "/dev/${esp}" "${mntpt}" | ||||
if [ $? -ne 0 ]; then | if [ $? -ne 0 ]; then | ||||
die "Failed to mount ESP ${dev} on ${mntpt}" | die "Failed to mount ESP ${dev} on ${mntpt}" | ||||
fi | fi | ||||
f_dprintf "Installing loader.efi onto ESP" | f_dprintf "Installing loader.efi onto ESP" | ||||
mkdir -p "$mntpt/EFI/freebsd" | mkdir -p "$mntpt/EFI/freebsd" | ||||
cp "$BSDINSTALL_CHROOT/boot/loader.efi" "${mntpt}/EFI/freebsd/loader.efi" | cp "$BSDINSTALL_CHROOT/boot/loader.efi" "${mntpt}/EFI/freebsd/loader.efi" | ||||
# | |||||
# The following shouldn't be necessary. UEFI defines a way to | |||||
# specifically select what to boot (which we do via | |||||
# efibootmgr). However, virtual environments often times lack | |||||
bcranUnsubmitted Not Done Inline ActionsThere are also ways to lose the boot manager entries on physical platforms too -- for example a firmware update often requires resetting the configuration, which is frustrating when BOOTx64.efi doesn't exist. bcran: There are also ways to lose the boot manager entries on physical platforms too -- for example a… | |||||
impUnsubmitted Not Done Inline ActionsTrue, but this can be worked around. imp: True, but this can be worked around.
http://bsdimp.blogspot.com/2020/10/how-to-recover-from… | |||||
# support for the NV variables efibootmgr sets. In addition, | |||||
# some BIOSes have features that interfere with the setting of | |||||
# these variables. To combat that, we install the default | |||||
# removable media boot file as a fallback if it doesn't | |||||
# exist. We don't install it all the time since that can | |||||
# interfere with other installations on the drive (like rEFInd). | |||||
# | |||||
if [ ! -f "${mntpt}/${BOOTNAME}" ]; then | |||||
cp "$BSDINSTALL_CHROOT/boot/loader.efi" "${mntpt}/${BOOTNAME}" | |||||
michaeloAuthorUnsubmitted Done Inline ActionsAre you certain that this will not overwrite existing entries? michaelo: Are you certain that this will not overwrite existing entries? | |||||
impUnsubmitted Done Inline Actions-f file True if file exists and is a regular file. ! expression True if expression is false. So if ! -f --> no file exists, then we copy. imp: -f file True if file exists and is a regular file.
! expression True if… | |||||
fi | |||||
if [ "$num_esps" -gt 1 ]; then | if [ "$num_esps" -gt 1 ]; then | ||||
bootlabel="FreeBSD (${esp})" | bootlabel="FreeBSD (${esp})" | ||||
else | else | ||||
bootlabel="FreeBSD" | bootlabel="FreeBSD" | ||||
fi | fi | ||||
f_dprintf "Creating UEFI boot entry" | f_dprintf "Creating UEFI boot entry" | ||||
Show All 11 Lines |
style nit - other bsdinstall source lines up the cases themselves under case