aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAhmad Khalifa <vexeduxr@FreeBSD.org>2026-02-24 20:11:32 +0000
committerAhmad Khalifa <vexeduxr@FreeBSD.org>2026-02-26 03:13:15 +0000
commitcfdd90abab51581120da75b45018a79237228b33 (patch)
tree2fa660dc809d5837daa1afe8d9c24deca2e83f31
parent0f5900bf663b980c88546711077110aef88972a7 (diff)
bsdinstall: fix EFI boot entry creation
update_uefi_bootentry assumes that the caller sets FREEBSD_BOOTNAME and mntpt, which isn't the case anymore. The result is that there is no "FreeBSD" boot entry created/updated after install. Most machines manage to boot from the removable media path (if the loader is installed there too), but some don't. Take the loader's path as an argument and rename the variable used in the ZFS mirror loop so mntpt can be reused below. Also mark nentries as a local variable so it doesn't leak out of the function. PR: 293385 Fixes: 494de51bc0074472d1b01604f085daea0844f240 MFC after: 2 days Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D55469 (cherry picked from commit 0fd91c489134643ac9e38c0f55ba7464fe892c5e)
-rwxr-xr-xusr.sbin/bsdinstall/scripts/bootconfig25
1 files changed, 14 insertions, 11 deletions
diff --git a/usr.sbin/bsdinstall/scripts/bootconfig b/usr.sbin/bsdinstall/scripts/bootconfig
index ba9a4369429c..5bcc49084617 100755
--- a/usr.sbin/bsdinstall/scripts/bootconfig
+++ b/usr.sbin/bsdinstall/scripts/bootconfig
@@ -80,11 +80,13 @@ uefi_copy_loader()
update_uefi_bootentry()
{
- nentries=$(efibootmgr | grep -c "${EFI_LABEL_NAME}$")
+ local nentries=$(efibootmgr | grep -c "${EFI_LABEL_NAME}$")
+ local loader_path=$1
+
# No entries so directly create one and return
if [ ${nentries} -eq 0 ]; then
f_dprintf "Creating UEFI boot entry"
- efibootmgr --create --activate --label "$EFI_LABEL_NAME" --loader "${mntpt}/${FREEBSD_BOOTNAME}" > /dev/null
+ efibootmgr --create --activate --label "$EFI_LABEL_NAME" --loader "${loader_path}" > /dev/null
return
fi
@@ -94,13 +96,13 @@ update_uefi_bootentry()
for entry in $(efibootmgr | awk "\$NF == \"$EFI_LABEL_NAME\" { sub(/.*Boot/,\"\", \$1); sub(/\*/,\"\", \$1); print \$1 }"); do
efibootmgr -B -b ${entry}
done
- efibootmgr --create --activate --label "$EFI_LABEL_NAME" --loader "${mntpt}/${FREEBSD_BOOTNAME}" > /dev/null
+ efibootmgr --create --activate --label "$EFI_LABEL_NAME" --loader "${loader_path}" > /dev/null
return
fi
FREEBSD_BOOTLABEL=$(dialog_uefi_entryname "${EFI_LABEL_NAME}")
[ $? -eq $DIALOG_CANCEL ] && exit 1
- efibootmgr --create --activate --label "$FREEBSD_BOOTLABEL" --loader "${mntpt}/${FREEBSD_BOOTNAME}" > /dev/null
+ efibootmgr --create --activate --label "$FREEBSD_BOOTLABEL" --loader "${loader_path}" > /dev/null
}
f_dialog_title "Boot Configuration"
@@ -148,21 +150,22 @@ if [ -n "$(awk '{if ($2=="/boot/efi") printf("%s\n",$1);}' $PATH_FSTAB)" ]; then
# over gmirror, so we only do this for ZFS.
esps=${TMPDIR:-"/tmp"}/bsdinstall-esps
if [ -f "$esps" ]; then
- mntpt=$(mktemp -d -t bsdinstall-esp)
+ tmpmnt=$(mktemp -d -t bsdinstall-esp)
for dev in $(cat $esps); do
f_dprintf "Installing ${file} onto redundant ESP ${dev}"
- mount -t msdos "$dev" "$mntpt"
+ mount -t msdos "$dev" "$tmpmnt"
uefi_copy_loader "$BSDINSTALL_CHROOT/boot/${file}" \
- "${mntpt}/efi/freebsd" "${mntpt}/efi/boot" \
+ "${tmpmnt}/efi/freebsd" "${tmpmnt}/efi/boot" \
boot${ARCHBOOTNAME}.efi
- umount "$mntpt"
+ umount "$tmpmnt"
done
- rmdir "${mntpt}"
+ rmdir "${tmpmnt}"
fi
- # Try to set the UEFI NV BootXXXX variables to record the boot location
+ # Try to set the UEFI NV BootXXXX variables to record the boot location.
+ # Note that the ESP is mounted at ${mntpt}/efi.
if [ "$BSDINSTALL_CONFIGCURRENT" ] && [ "$ARCHBOOTNAME" != ia32 ]; then
- update_uefi_bootentry
+ update_uefi_bootentry "${mntpt}/efi/freebsd/${file}"
fi
f_dprintf "Finished configuring ESP"