Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 9 Oct 2020 00:16:26 +0000 (UTC)
From:      Warner Losh <imp@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r366554 - head/usr.sbin/bsdinstall/scripts
Message-ID:  <202010090016.0990GQq2080874@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: imp
Date: Fri Oct  9 00:16:26 2020
New Revision: 366554
URL: https://svnweb.freebsd.org/changeset/base/366554

Log:
  Initial support for implementing the bootXXX.efi workaround
  
  Too many version of UEFI firmware (so far only confirmed on amd64)
  don't really support efibootmgr selection of boot. That's the most
  reliable, when it works, since there's no guesswork. However, many do
  not save, unmolested, the variables that efibootmgr sets, so as a
  fallback we also install loader.efi as bootXXX.efi (where XXX is
  either aa64 or x64) if it doesn't already exist in /efi/boot on the
  ESP. The standard only defines this for removable devices, but it's
  almost ubiquitously used as a fallback. Many BIOSes implement a drive
  selection feature that takes over the efibootmgr protocol, rendinering
  it useless (either generally, or for those vendors not on the short
  list). bootxxx.efi works around this. However, we don't install it
  unconditionally there, as that breaks some popular multi-boot setups.
  
  MFC After: 1 week
  Differential Revision: https://reviews.freebsd.org/D26428

Modified:
  head/usr.sbin/bsdinstall/scripts/bootconfig

Modified: head/usr.sbin/bsdinstall/scripts/bootconfig
==============================================================================
--- head/usr.sbin/bsdinstall/scripts/bootconfig	Thu Oct  8 23:59:58 2020	(r366553)
+++ head/usr.sbin/bsdinstall/scripts/bootconfig	Fri Oct  9 00:16:26 2020	(r366554)
@@ -124,6 +124,15 @@ if [ "$(uname -m)" = "arm64" ] || [ "$X86_BOOTMETHOD" 
 		done
 	fi
 
+	case $(uname -m) in
+	    arm64)	ARCHBOOTNAME=aa64 ;;
+	    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"
+
 	for esp in $ESPS; do
 		f_dprintf "Formatting /dev/${esp} as FAT32"
 		newfs_msdos -F 32 -c 1 -L EFISYS "/dev/$esp" > /dev/null 2>&1
@@ -141,6 +150,21 @@ if [ "$(uname -m)" = "arm64" ] || [ "$X86_BOOTMETHOD" 
 		f_dprintf "Installing loader.efi onto ESP"
 		mkdir -p "$mntpt/EFI/freebsd"
 		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
+		# support for the NV variables efibootmgr sets. In addition,
+		# some UEFI implementations 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}"
+		fi
 
 		if [ "$num_esps" -gt 1 ]; then
 			bootlabel="FreeBSD (${esp})"



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202010090016.0990GQq2080874>