Page MenuHomeFreeBSD

D52780.diff
No OneTemporary

D52780.diff

diff --git a/usr.sbin/bsdinstall/scripts/auto b/usr.sbin/bsdinstall/scripts/auto
--- a/usr.sbin/bsdinstall/scripts/auto
+++ b/usr.sbin/bsdinstall/scripts/auto
@@ -178,6 +178,9 @@
rm -rf $BSDINSTALL_TMPETC
mkdir $BSDINSTALL_TMPETC
+# Reset the ESP list
+: > ${TMPDIR:-"/tmp"}/bsdinstall-esps
+
# With pkgbase, pkg OOM has been observed with QEMU-default 128 MiB memory size.
# Ensure we have at least about 256 MiB (with an allowance for rounding etc.).
physmem=$(($(sysctl -n hw.physmem) / 1048576))
diff --git a/usr.sbin/bsdinstall/scripts/bootconfig b/usr.sbin/bsdinstall/scripts/bootconfig
--- a/usr.sbin/bsdinstall/scripts/bootconfig
+++ b/usr.sbin/bsdinstall/scripts/bootconfig
@@ -63,6 +63,24 @@
2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
}
+# Copy to the normal FreeBSD location. Also copy to the default location if it
+# doesn't exist. This covers setups where UEFI NV variables can't be set and
+# some buggy firmware, while preserving complex UEFI setups for multiple booting
+# (rEFInd, etc).
+uefi_copy_loader()
+{
+ local ldr=$1
+ local freebsd_dir=$2
+ local default_dir=$3
+ local dest=$4
+
+ mkdir -p "${freebsd_dir}" "${default_dir}"
+ cp "${ldr}" "${freebsd_dir}"
+ if [ ! -f "${default_dir}/${dest}" ]; then
+ cp "${ldr}" "${default_dir}/${dest}"
+ fi
+}
+
update_uefi_bootentry()
{
nentries=$(efibootmgr | grep -c "${EFI_LABEL_NAME}$")
@@ -113,6 +131,7 @@
*) die "Unsupported arch $(uname -m) for UEFI install"
esac
+ # Support the weird 32-bit firmware loading 64-bit kernels
if [ `sysctl -n machdep.efi_arch` == i386 ]; then
ARCHBOOTNAME=ia32
file=loader_ia32.efi
@@ -120,31 +139,31 @@
file=loader.efi
fi
- BOOTDIR="/efi/boot"
- BOOTNAME="${BOOTDIR}/boot${ARCHBOOTNAME}.efi"
- FREEBSD_BOOTDIR="/efi/freebsd"
- FREEBSD_BOOTNAME="${FREEBSD_BOOTDIR}/${file}"
+ # Copy the boot loader
mntpt="$BSDINSTALL_CHROOT/boot/efi"
-
f_dprintf "Installing ${file} onto ESP"
- mkdir -p "${mntpt}/${FREEBSD_BOOTDIR}" "${mntpt}/${BOOTDIR}"
- cp "$BSDINSTALL_CHROOT/boot/${file}" "${mntpt}/${FREEBSD_BOOTNAME}"
-
- #
- # UEFI defines a way to specifically select what to boot
- # (which we do via efibootmgr). However, if we booted from an ia32
- # UEFI environment, we wouldn't have access to efirt. In addition,
- # virtual environments often times lack support for the NV variables
- # efibootmgr sets, and some UEFI implementations have features that
- # interfere with the setting of these variables. To combat that, we
- # install the default removable media boot file 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/${file}" "${mntpt}/${BOOTNAME}"
+ uefi_copy_loader "$BSDINSTALL_CHROOT/boot/${file}" \
+ "${mntpt}/efi/freebsd" "${mntpt}/efi/boot" \
+ boot${ARCHBOOTNAME}.efi
+
+ # zfsboot records the extra esp partitions it creates to -esps. These
+ # are newfs'd at the time of creation. We don't support installing ufs
+ # over gmirror, so we only do this for ZFS.
+ esps=${TMPDIR:-"/tmp"}/bsdinstall-esps
+ if [ -f "$esps" ]; then
+ mntpt=$(mktemp -d -t bsdinstall-esp)
+ for dev in $(cat $esps); do
+ f_dprintf "Installing ${file} onto redundant ESP ${dev}"
+ mount -t msdos "$dev" "$mntpt"
+ uefi_copy_loader "$BSDINSTALL_CHROOT/boot/${file}" \
+ "${mntpt}/efi/freebsd" "${mntpt}/efi/boot" \
+ boot${ARCHBOOTNAME}.efi
+ umount "$mntpt"
+ done
+ rmdir "${mntpt}"
fi
+ # Try to set the UEFI NV BootXXXX variables to recod the boot location
if [ "$BSDINSTALL_CONFIGCURRENT" ] && [ "$ARCHBOOTNAME" != ia32 ]; then
update_uefi_bootentry
fi
diff --git a/usr.sbin/bsdinstall/scripts/zfsboot b/usr.sbin/bsdinstall/scripts/zfsboot
--- a/usr.sbin/bsdinstall/scripts/zfsboot
+++ b/usr.sbin/bsdinstall/scripts/zfsboot
@@ -760,6 +760,7 @@
{
local funcname=zfs_create_diskpart
local disk="$1" index="$2"
+ local efibootpart
# Check arguments
if [ ! "$disk" ]; then
@@ -867,18 +868,22 @@
$disk || return $FAILURE
# We'll configure the ESP in bootconfig
- if [ -z "$efibootpart" ]; then
- efibootpart="/dev/gpt/efiboot$index"
- f_dprintf "$funcname: configuring ESP at [%s]" \
- "${efibootpart}"
-
- f_eval_catch $funcname newfs_msdos "$NEWFS_ESP"\
- "$efibootpart" \
- || return $FAILURE
+ # Note: This will always be p1
+ efibootpart="/dev/gpt/efiboot$index"
+ f_dprintf "$funcname: configuring ESP at [%s]" \
+ "${efibootpart}"
+
+ f_eval_catch $funcname newfs_msdos "$NEWFS_ESP"\
+ "$efibootpart" \
+ || return $FAILURE
+ if [ $index -eq 0 ]; then
f_eval_catch $funcname printf "$PRINTF_FSTAB" \
- $efibootpart /boot/efi msdosfs \
- rw 2 2 "$BSDINSTALL_TMPETC/fstab" \
- || return $FAILURE
+ $efibootpart /boot/efi msdosfs \
+ rw 2 2 "$BSDINSTALL_TMPETC/fstab" \
+ || return $FAILURE
+ else
+ # Record the extra ones
+ echo "${efibootpart}" >> ${TMPDIR:-"/tmp"}/bsdinstall-esps
fi
fi
@@ -1021,7 +1026,6 @@
local isswapmirror
local bootpart targetpart swappart # Set by zfs_create_diskpart() below
local create_options
- local efibootpart
#
# Pedantic checks; should never be seen

File Metadata

Mime Type
text/plain
Expires
Thu, Jul 16, 6:46 AM (16 h, 34 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
35127004
Default Alt Text
D52780.diff (5 KB)

Event Timeline