I was trying to install OpenBSD on the arm64 MacBook Air with softraid crypto (that's the "Encrypt the root disk?" question in the installer). Right now that does not work out of the box.
In a regular install, md_prep_fdisk is careful and leaves the EFI Sys partition alone with the "if disk_has $_disk gpt apfsisc" check. However, in the "encrypt the root disk" case, the installer goes through md_prep_fdisk twice. The second time, it's called on the softraid crypto disk, which does not have the special EFI Sys partition. So there we don't hit the special "if disk_has $_disk gpt apfsisc" case. Instead, we go to a more regular case where we end up running "installboot -p". Because it's a softraid disk, installboot also looks at the "chunks" that the softraid volume resides on. I.e., it also looks at sd0 and there "installboot -p" will newfs the EFI Sys partition, which is something we don't want on the Mac. This diff addresses this problem. The first time we go through md_prep_fdisk, we keep track of whether we're in this special Mac case by setting KEEP_EFI_SYS. Then when we go through md_prep_fdisk for the second time to prepare the softraid disk, we can check this variable to see if we should avoid running "installboot -p". Debugged with help from and came up with a fix with kn@, thanks! Comments or OKs? Caspar --- arm64 install.md: fix softraid crypto installation on Mac Make sure we don't newfs the EFI Sys partition on systems that have an "apfsisc" partition in the case we're installing with softraid crypto. Debugged with help from and came up with a fix with kn@ Index: install.md =================================================================== RCS file: /cvs/src/distrib/arm64/ramdisk/install.md,v retrieving revision 1.46 diff -u -p -r1.46 install.md --- install.md 27 Apr 2023 10:03:49 -0000 1.46 +++ install.md 27 Apr 2023 11:26:56 -0000 @@ -36,6 +36,7 @@ MDBOOTSR=y NCPU=$(sysctl -n hw.ncpufound) COMPATIBLE=$(sysctl -n machdep.compatible) MOUNT_ARGS_msdos="-o-l" +KEEP_EFI_SYS=false md_installboot() { local _disk=$1 _chunks _bootdisk _mdec _plat @@ -109,6 +110,11 @@ md_prep_fdisk() { [wW]*) echo -n "Creating a ${bootfstype} partition and an OpenBSD partition for rest of $_disk..." if disk_has $_disk gpt apfsisc; then + # On Apple hardware, the existing EFI Sys + # partition contains boot firmware and MUST NOT + # be recreated. + KEEP_EFI_SYS=true + # Is this a boot disk? if [[ $_disk == @($ROOTDISK|$CRYPTOCHUNK) ]]; then fdisk -Ay -b "${bootsectorsize}" ${_disk} >/dev/null @@ -119,13 +125,20 @@ md_prep_fdisk() { # Is this a boot disk? if [[ $_disk == @($ROOTDISK|$CRYPTOCHUNK) ]]; then fdisk -gy -b "${bootsectorsize}" ${_disk} >/dev/null - installboot -p $_disk + + # With root on softraid, + # 'installboot -p' on the root disk + # nukes EFI Sys on the chunks. + $KEEP_EFI_SYS || installboot -p $_disk else fdisk -gy ${_disk} >/dev/null fi else fdisk -iy -b "${bootsectorsize}@${bootsectorstart}:${bootparttype}" ${_disk} >/dev/null - installboot -p $_disk + + # With root on softraid, 'installboot -p' on + # the root disk nukes EFI Sys on the chunks. + $KEEP_EFI_SYS || installboot -p $_disk fi echo "done." return ;;