Changeset View
Changeset View
Standalone View
Standalone View
usr.sbin/bsdinstall/scripts/bootconfig
| Show First 20 Lines • Show All 57 Lines • ▼ Show 20 Lines | $DIALOG \ | ||||
| --hline "$hline" \ | --hline "$hline" \ | ||||
| --ok-label "Ok" \ | --ok-label "Ok" \ | ||||
| --no-cancel \ | --no-cancel \ | ||||
| --inputbox "$prompt" \ | --inputbox "$prompt" \ | ||||
| $height $width "$value" \ | $height $width "$value" \ | ||||
| 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD | 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() | update_uefi_bootentry() | ||||
| { | { | ||||
| nentries=$(efibootmgr | grep -c "${EFI_LABEL_NAME}$") | nentries=$(efibootmgr | grep -c "${EFI_LABEL_NAME}$") | ||||
| # No entries so directly create one and return | # No entries so directly create one and return | ||||
| if [ ${nentries} -eq 0 ]; then | if [ ${nentries} -eq 0 ]; then | ||||
| f_dprintf "Creating UEFI boot entry" | f_dprintf "Creating UEFI boot entry" | ||||
| efibootmgr --create --activate --label "$EFI_LABEL_NAME" --loader "${mntpt}/${FREEBSD_BOOTNAME}" > /dev/null | efibootmgr --create --activate --label "$EFI_LABEL_NAME" --loader "${mntpt}/${FREEBSD_BOOTNAME}" > /dev/null | ||||
| return | return | ||||
| Show All 34 Lines | case $(uname -m) in | ||||
| arm64) ARCHBOOTNAME=aa64 ;; | arm64) ARCHBOOTNAME=aa64 ;; | ||||
| amd64) ARCHBOOTNAME=x64 ;; | amd64) ARCHBOOTNAME=x64 ;; | ||||
| riscv) ARCHBOOTNAME=riscv64 ;; | riscv) ARCHBOOTNAME=riscv64 ;; | ||||
| # arm) ARCHBOOTNAME=arm ;; # No other support for arm install | # arm) ARCHBOOTNAME=arm ;; # No other support for arm install | ||||
| # i386) ARCHBOOTNAME=ia32 ;; # no support for this in i386 kernels, rare machines | # i386) ARCHBOOTNAME=ia32 ;; # no support for this in i386 kernels, rare machines | ||||
| *) die "Unsupported arch $(uname -m) for UEFI install" | *) die "Unsupported arch $(uname -m) for UEFI install" | ||||
| esac | esac | ||||
| # Support the weird 32-bit firmware loading 64-bit kernels | |||||
| if [ `sysctl -n machdep.efi_arch` == i386 ]; then | if [ `sysctl -n machdep.efi_arch` == i386 ]; then | ||||
| ARCHBOOTNAME=ia32 | ARCHBOOTNAME=ia32 | ||||
| file=loader_ia32.efi | file=loader_ia32.efi | ||||
| else | else | ||||
| file=loader.efi | file=loader.efi | ||||
| fi | fi | ||||
| BOOTDIR="/efi/boot" | # Copy the boot loader | ||||
| BOOTNAME="${BOOTDIR}/boot${ARCHBOOTNAME}.efi" | |||||
| FREEBSD_BOOTDIR="/efi/freebsd" | |||||
| FREEBSD_BOOTNAME="${FREEBSD_BOOTDIR}/${file}" | |||||
| mntpt="$BSDINSTALL_CHROOT/boot/efi" | mntpt="$BSDINSTALL_CHROOT/boot/efi" | ||||
| f_dprintf "Installing ${file} onto ESP" | f_dprintf "Installing ${file} onto ESP" | ||||
| mkdir -p "${mntpt}/${FREEBSD_BOOTDIR}" "${mntpt}/${BOOTDIR}" | uefi_copy_loader "$BSDINSTALL_CHROOT/boot/${file}" \ | ||||
| cp "$BSDINSTALL_CHROOT/boot/${file}" "${mntpt}/${FREEBSD_BOOTNAME}" | "${mntpt}/efi/freebsd" "${mntpt}/efi/boot" \ | ||||
| boot${ARCHBOOTNAME}.efi | |||||
| # | # zfsboot records the extra esp partitions it creates to -esps. These | ||||
cperciva: `appends` ? | |||||
Done Inline ActionsYea, writes the extras to. It appends each one. I'll fix. imp: Yea, writes the extras to. It appends each one. I'll fix. | |||||
| # UEFI defines a way to specifically select what to boot | # are newfs'd at the time of creation. We don't support installing ufs | ||||
Not Done Inline Actionsdon't support installing ? cperciva: `don't support installing` ? | |||||
Done Inline Actionsok. imp: ok. | |||||
| # (which we do via efibootmgr). However, if we booted from an ia32 | # over gmirror, so we only do this for ZFS. | ||||
| # UEFI environment, we wouldn't have access to efirt. In addition, | esps=${TMPDIR:-"/tmp"}/bsdinstall-esps | ||||
| # virtual environments often times lack support for the NV variables | if [ -f "$esps" ]; then | ||||
Not Done Inline ActionsThis could just be mktemp -d -t bsdinstall-esp since the use of TMPDIR (if set) or /tmp (otherwise) is implied. cperciva: This could just be `mktemp -d -t bsdinstall-esp` since the use of TMPDIR (if set) or `/tmp`… | |||||
Done Inline ActionsHmmm, lemme check. Yes. Will update. imp: Hmmm, lemme check. Yes. Will update. | |||||
| # efibootmgr sets, and some UEFI implementations have features that | mntpt=$(mktemp -d -t bsdinstall-esp) | ||||
| # interfere with the setting of these variables. To combat that, we | for dev in $(cat $esps); do | ||||
| # install the default removable media boot file if it doesn't exist. | f_dprintf "Installing ${file} onto redundant ESP ${dev}" | ||||
| # We don't install it all the time since that can interfere with other | mount -t msdos "$dev" "$mntpt" | ||||
| # installations on the drive (like rEFInd). | uefi_copy_loader "$BSDINSTALL_CHROOT/boot/${file}" \ | ||||
| # | "${mntpt}/efi/freebsd" "${mntpt}/efi/boot" \ | ||||
| if [ ! -f "${mntpt}/${BOOTNAME}" ]; then | boot${ARCHBOOTNAME}.efi | ||||
| cp "$BSDINSTALL_CHROOT/boot/${file}" "${mntpt}/${BOOTNAME}" | umount "$mntpt" | ||||
| done | |||||
| rmdir "${mntpt}" | |||||
| fi | fi | ||||
| # Try to set the UEFI NV BootXXXX variables to recod the boot location | |||||
| if [ "$BSDINSTALL_CONFIGCURRENT" ] && [ "$ARCHBOOTNAME" != ia32 ]; then | if [ "$BSDINSTALL_CONFIGCURRENT" ] && [ "$ARCHBOOTNAME" != ia32 ]; then | ||||
| update_uefi_bootentry | update_uefi_bootentry | ||||
| fi | fi | ||||
| f_dprintf "Finished configuring ESP" | f_dprintf "Finished configuring ESP" | ||||
| fi | fi | ||||
| # Add boot0cfg for MBR BIOS booting? | # Add boot0cfg for MBR BIOS booting? | ||||
appends ?