Index | Thread | Search

From:
Klemens Nanni <kn@openbsd.org>
Subject:
installer: defer installboot to pick up apple-boot firmware
To:
tech@openbsd.org
Date:
Sat, 6 Apr 2024 23:45:28 +0000

Download raw body.

Thread
Fresh installs on Apple silicon may fetch firmware, but won't use it until
another sysupgrade(8), manual upgrade or installboot(8) which does puts it
in place on the EFI system partition.

During install and upgrade, installboot is run before fw_update, but I don't
see a reason for this ordering, so flip it to have arm64 MacBooks boot
straight into our firmware upon first boot.

I did not hoist the fw_update all to in spirit of
	date: 2022/06/27 11:01:41;  author: sthen;  state: Exp;  lines: +19 -19;
	Move rc.firsttime additions before some slower jobs run from install.sub.
	Reduces the risk of post-upgrade steps (sysmerge -b etc) being missed if
	there was some issue with those jobs e.g. fw_update or reorder_kernel
	triggering watchdog or an impatient admin to reboot the system. ok florian@

Only tested on an M2 Pro so far.
Feedback?

Index: install.sub
===================================================================
RCS file: /cvs/src/distrib/miniroot/install.sub,v
diff -u -p -r1.1263 install.sub
--- install.sub	15 Mar 2024 17:31:21 -0000	1.1263
+++ install.sub	6 Apr 2024 22:54:40 -0000
@@ -2967,11 +2967,6 @@ finish_up() {
 		)
 	fi
 
-	# In case root is on a softraid volume, make sure all underlying
-	# device nodes exist before installing boot-blocks on disk.
-	make_dev $(get_softraid_chunks $ROOTDISK)
-	md_installboot $ROOTDISK
-
 	chmod og-rwx /mnt/bsd{,.mp,.rd} 2>/dev/null
 	if [[ -f /mnt/bsd.mp ]] && ((NCPU > 1)); then
 		_kernel=$_kernel.MP
@@ -3011,7 +3006,15 @@ if ((${#_KERNV[*]} == 1)); then
 fi
 __EOT
 
+	# Fetch boot firmware before installbot(8) so it can be placed into ESP
+	# prior to first boot, e.g. apple-boot on Apple silicon.
 	[ -x /mnt/usr/sbin/fw_update ] && DESTDIR=/mnt /mnt/usr/sbin/fw_update
+
+	# In case root is on a softraid volume, make sure all underlying
+	# device nodes exist before installing boot-blocks on disk.
+	make_dev $(get_softraid_chunks $ROOTDISK)
+
+	md_installboot $ROOTDISK
 
 	if [[ -f $_kernel_dir.tgz ]]; then
 		echo -n "Relinking to create unique kernel..."