Date: Mon, 31 Dec 2018 00:20:58 +0000 (UTC) From: Rebecca Cran <bcran@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r342637 - head/usr.sbin/bsdinstall/scripts Message-ID: <201812310020.wBV0Kwbo024308@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: bcran Date: Mon Dec 31 00:20:58 2018 New Revision: 342637 URL: https://svnweb.freebsd.org/changeset/base/342637 Log: Fix ESP generation when using a gmirror, and when booting from RO medium When using a gmirror, entries in /dev can be removed. So instead of using kern.disks, get the list of disks from "gpart status -sg" instead. We assume that any 'efi' partition that can't be mounted as msdosfs should be used as an ESP. However, the ESP on the CD/DVD can't be mounted read-write and so was being treated as if unformatted. Try the mount as read-only instead, to catch cases like this. Relnotes: yes Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D18645 Modified: head/usr.sbin/bsdinstall/scripts/bootconfig Modified: head/usr.sbin/bsdinstall/scripts/bootconfig ============================================================================== --- head/usr.sbin/bsdinstall/scripts/bootconfig Mon Dec 31 00:15:05 2018 (r342636) +++ head/usr.sbin/bsdinstall/scripts/bootconfig Mon Dec 31 00:20:58 2018 (r342637) @@ -84,10 +84,11 @@ if [ "$(uname -m)" = "arm64" ] || [ "$X86_BOOTMETHOD" # The installer hasn't given us any ESPs to use. # Try and figure out which to use by looking for an # unformatted efi partition - for disk in $(sysctl -n kern.disks); do - hasfreebsd=$(gpart show "$disk" | cut -w -f 4,5 | grep "freebsd") + + for geom in $(gpart status -sg | awk '{print $1}'); do + hasfreebsd=$(gpart show "${geom}" | cut -w -f 4,5 | grep "freebsd") if [ -n "$hasfreebsd" ]; then - index=$(gpart show "$disk" | cut -w -f 4,5 | grep "efi" | cut -w -f 1) + index=$(gpart show "${geom}" | cut -w -f 4,5 | grep "efi" | cut -w -f 1) # Check that $index is a valid integer [ -n "$index" ] && [ "$index" -eq "$index" ] && [ "$index" -ge 0 ] 2> /dev/null if [ $? -ne 0 ]; then @@ -95,17 +96,17 @@ if [ "$(uname -m)" = "arm64" ] || [ "$X86_BOOTMETHOD" fi mntpt=$(mktemp -d /tmp/stand-test.XXXXXX) - if [ -e "/dev/${disk}p${index}" ]; then - dev=${disk}p${index} - elif [ -e "/dev/${disk}s${index}" ]; then - dev=/${disk}s${index} + if [ -e "/dev/${geom}p${index}" ]; then + dev=${geom}p${index} + elif [ -e "/dev/${geom}s${index}" ]; then + dev=/${geom}s${index} else continue fi # Try and mount it. If it fails, assume it's # unformatted and should be used. - mount -t msdosfs "/dev/${dev}" "${mntpt}" + mount -t msdosfs -o ro "/dev/${dev}" "${mntpt}" if [ $? -ne 0 ]; then ESPS="$ESPS ${dev}" num_esps=$((num_esps + 1)) @@ -118,17 +119,20 @@ if [ "$(uname -m)" = "arm64" ] || [ "$X86_BOOTMETHOD" fi for esp in $ESPS; do + echo "Formatting /dev/${esp} as FAT32" newfs_msdos -F 32 -c 1 -L EFISYS "/dev/$esp" > /dev/null 2>&1 if [ $? -ne 0 ]; then die "Failed to format ESP $esp as FAT32" fi mntpt=$(mktemp -d /tmp/stand-test.XXXXXX) + echo "Mounting ESP /dev/${esp}" mount -t msdosfs "/dev/${esp}" "${mntpt}" if [ $? -ne 0 ]; then die "Failed to mount ESP ${dev} on ${mntpt}" fi + echo "Installing loader.efi onto ESP" mkdir -p "$mntpt/EFI/freebsd" cp "$BSDINSTALL_CHROOT/boot/loader.efi" "${mntpt}/EFI/freebsd/loader.efi" @@ -138,8 +142,10 @@ if [ "$(uname -m)" = "arm64" ] || [ "$X86_BOOTMETHOD" bootlabel="FreeBSD" fi + echo "Creating UEFI boot entry" efibootmgr --create --label "$bootlabel" --loader "${mntpt}/EFI/freebsd/loader.efi" > /dev/null + echo "Unmounting ESP" umount "${mntpt}" rmdir "${mntpt}" @@ -149,6 +155,7 @@ if [ "$(uname -m)" = "arm64" ] || [ "$X86_BOOTMETHOD" bootorder=$(efivar --name 8be4df61-93ca-11d2-aa0d-00e098032b8c-BootOrder --print --no-name --hex | head -1) bootentry=$(echo "$bootorder" | cut -w -f 3)$(echo "$bootorder" | cut -w -f 2) efibootmgr --activate "$bootentry" > /dev/null + echo "Finished configuring /dev/${esp} as ESP" done fi
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201812310020.wBV0Kwbo024308>