Changeset View
Changeset View
Standalone View
Standalone View
usr.sbin/bsdinstall/scripts/bootconfig
Show First 20 Lines • Show All 125 Lines • ▼ Show 20 Lines | if [ "$(uname -m)" = "arm64" ] || [ "$X86_BOOTMETHOD" = "UEFI" ]; then | ||||
case $(uname -m) in | case $(uname -m) in | ||||
arm64) ARCHBOOTNAME=aa64 ;; | arm64) ARCHBOOTNAME=aa64 ;; | ||||
amd64) ARCHBOOTNAME=x64 ;; | amd64) ARCHBOOTNAME=x64 ;; | ||||
# arm) ARCHBOOTNAME=arm ;; # No other support for arm install | # arm) ARCHBOOTNAME=arm ;; # No other support for arm install | ||||
# i386) ARCHBOOTNAME=ia32 ;; # no support for this in i386 kernels, rare machines | # i386) ARCHBOOTNAME=ia32 ;; # no support for this in i386 kernels, rare machines | ||||
*) die "Unsupported arch $(uname -m) for UEFI install" | *) die "Unsupported arch $(uname -m) for UEFI install" | ||||
esac | esac | ||||
BOOTNAME="/EFI/BOOT/BOOT${ARCHBOOTNAME}.EFI" | BOOTDIR="/efi/boot" | ||||
BOOTNAME="${BOOTDIR}/boot${ARCHBOOTNAME}.efi" | |||||
FREEBSD_BOOTDIR="/efi/freebsd" | |||||
FREEBSD_BOOTNAME="${FREEBSD_BOOTDIR}/loader.efi" | |||||
imp: BOOTDIR="/efi/boot"
BOOTNAME="${BOOTDIR}/boot${ARCHBOOTNAME}.efi
FREEBSD_BOOTDIR="/efi/freebsd" | |||||
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}/${FREEBSD_BOOTDIR}" "${mntpt}/${BOOTDIR}" | ||||
Not Done Inline Actionsmkdir -p "${mntpt}/${FREEBSD_BOOTDIR}" "${mntpt}/${BOOTDIR}" imp: mkdir -p "${mntpt}/${FREEBSD_BOOTDIR}" "${mntpt}/${BOOTDIR}"
| |||||
cp "$BSDINSTALL_CHROOT/boot/loader.efi" "${mntpt}/EFI/freebsd/loader.efi" | cp "$BSDINSTALL_CHROOT/boot/loader.efi" "${mntpt}/${FREEBSD_BOOTNAME}" | ||||
Not Done Inline Actions"${mntpt}/${FREEBSD_BOOTDIR}/loader.efi imp: "${mntpt}/${FREEBSD_BOOTDIR}/loader.efi | |||||
# | # | ||||
# The following shouldn't be necessary. UEFI defines a way to | # The following shouldn't be necessary. UEFI defines a way to | ||||
# specifically select what to boot (which we do via | # specifically select what to boot (which we do via | ||||
# efibootmgr). However, virtual environments often times lack | # efibootmgr). However, virtual environments often times lack | ||||
# support for the NV variables efibootmgr sets. In addition, | # support for the NV variables efibootmgr sets. In addition, | ||||
# some UEFI implementations have features that interfere with | # some UEFI implementations have features that interfere with | ||||
# the setting of these variables. To combat that, we install the | # the setting of these variables. To combat that, we install the | ||||
# default removable media boot file as a fallback if it doesn't | # default removable media boot file as a fallback if it doesn't | ||||
# exist. We don't install it all the time since that can | # exist. We don't install it all the time since that can | ||||
# interfere with other installations on the drive (like rEFInd). | # interfere with other installations on the drive (like rEFInd). | ||||
# | # | ||||
if [ ! -f "${mntpt}/${BOOTNAME}" ]; then | if [ ! -f "${mntpt}/${BOOTNAME}" ]; then | ||||
cp "$BSDINSTALL_CHROOT/boot/loader.efi" "${mntpt}/${BOOTNAME}" | cp "$BSDINSTALL_CHROOT/boot/loader.efi" "${mntpt}/${BOOTNAME}" | ||||
Not Done Inline ActionsThis is too late. I'd suggest above. imp: This is too late. I'd suggest above.
| |||||
Done Inline ActionsYep, that is much better. Will update shortly. mhorne: Yep, that is much better. Will update shortly. | |||||
fi | 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" | ||||
efibootmgr --create --activate --label "$bootlabel" --loader "${mntpt}/EFI/freebsd/loader.efi" > /dev/null | efibootmgr --create --activate --label "$bootlabel" --loader "${mntpt}/${FREEBSD_BOOTNAME}" > /dev/null | ||||
f_dprintf "Unmounting ESP" | f_dprintf "Unmounting ESP" | ||||
umount "${mntpt}" | umount "${mntpt}" | ||||
rmdir "${mntpt}" | rmdir "${mntpt}" | ||||
f_dprintf "Finished configuring /dev/${esp} as ESP" | f_dprintf "Finished configuring /dev/${esp} as ESP" | ||||
done | done | ||||
fi | fi | ||||
# Add boot0cfg for MBR BIOS booting? | # Add boot0cfg for MBR BIOS booting? |
BOOTDIR="/efi/boot"
BOOTNAME="${BOOTDIR}/boot${ARCHBOOTNAME}.efi
FREEBSD_BOOTDIR="/efi/freebsd"