Changeset View
Changeset View
Standalone View
Standalone View
usr.sbin/bsdinstall/scripts/bootconfig
#!/bin/sh | #!/bin/sh | ||||
#- | #- | ||||
# Copyright (c) 2018 Rebecca Cran | |||||
# Copyright (c) 2017 Nathan Whitehorn | # Copyright (c) 2017 Nathan Whitehorn | ||||
# All rights reserved. | # All rights reserved. | ||||
# | # | ||||
# Redistribution and use in source and binary forms, with or without | # Redistribution and use in source and binary forms, with or without | ||||
# modification, are permitted provided that the following conditions | # modification, are permitted provided that the following conditions | ||||
# are met: | # are met: | ||||
# 1. Redistributions of source code must retain the above copyright | # 1. Redistributions of source code must retain the above copyright | ||||
# notice, this list of conditions and the following disclaimer. | # notice, this list of conditions and the following disclaimer. | ||||
Show All 19 Lines | if [ `uname -m` == powerpc ]; then | ||||
platform=`sysctl -n hw.platform` | platform=`sysctl -n hw.platform` | ||||
if [ "$platform" == ps3 -o "$platform" == powernv ]; then | if [ "$platform" == ps3 -o "$platform" == powernv ]; then | ||||
rootpart=$(awk '{ if($2 == "/") printf("%s:%s\n", $3, $1); }' $PATH_FSTAB) | rootpart=$(awk '{ if($2 == "/") printf("%s:%s\n", $3, $1); }' $PATH_FSTAB) | ||||
mkdir -p $BSDINSTALL_CHROOT/boot/etc/ | mkdir -p $BSDINSTALL_CHROOT/boot/etc/ | ||||
echo FreeBSD=\'/kernel/kernel kernelname=/boot/kernel/kernel vfs.root.mountfrom=${rootpart}\' > $BSDINSTALL_CHROOT/boot/etc/kboot.conf | echo FreeBSD=\'/kernel/kernel kernelname=/boot/kernel/kernel vfs.root.mountfrom=${rootpart}\' > $BSDINSTALL_CHROOT/boot/etc/kboot.conf | ||||
fi | fi | ||||
fi | fi | ||||
# For new-style EFI booting, add code here | # Update the ESP (EFI System Partition) with the new bootloader | ||||
# Add boot0cfg for MBR BIOS booting? | if [ `uname -m` == amd64 -o `uname -m` == i386 ]; then | ||||
X86_BOOTMETHOD=`sysctl -n machdep.bootmethod` | |||||
fi | |||||
if [ `uname -m` == arm64 -o "$X86_BOOTMETHOD" == "UEFI" ]; then | |||||
imp: how can this ever be true? We only ever set X86_BOOTMETHOD foor amd64 and i386. | |||||
Done Inline ActionsI'm checking if the machine is arm64 _or_ the x86 bootmethod is UEFI. bcran: I'm checking if the machine is arm64 _or_ the x86 bootmethod is UEFI.
So it's going to be true… | |||||
mkdir $BSDINSTALL_TMPETC/esp | |||||
UFSBOOT_ESPS=`cat /tmp/bsdinstall-esps` | |||||
if [ "$ZFSBOOT_DISKS" ]; then | |||||
# We're in a ZFS install environment | |||||
for disk in $ZFSBOOT_DISKS; do | |||||
index=`gpart show $disk | cut -w -f 4,5 | grep "efi" | cut -w -f 1` | |||||
ESPS="$ESPS $diskp$index" | |||||
done | |||||
fi | |||||
if [ "$UFSBOOT_ESPS" ]; then | |||||
# We're in a UFS install environment | |||||
for partition in $UFSBOOT_ESPS; do | |||||
ESPS="$ESPS $partition" | |||||
done | |||||
fi | |||||
for esp in $ESPS; do | |||||
newfs_msdos -F 32 -c 1 -L EFISYS /dev/$esp | |||||
mount -t msdosfs /dev/$esp $BSDINSTALL_TMPETC/esp | |||||
mkdir -p $BSDINSTALL_TMPETC/esp/EFI/freebsd | |||||
cp $BSDINSTALL_CHROOT/boot/loader.efi $BSDINSTALL_TMPETC/esp/EFI/freebsd/loader.efi | |||||
efibootmgr --create --label FreeBSD --loader $BSDINSTALL_TMPETC/esp/EFI/freebsd/loader.efi | |||||
Done Inline Actionsif we know the path to the kernel, it would be good to include that here. imp: if we know the path to the kernel, it would be good to include that here.
| |||||
Done Inline ActionsI've taken a note to add the kernel path in a follow-up changeset. bcran: I've taken a note to add the kernel path in a follow-up changeset. | |||||
umount $BSDINSTALL_TMPETC/esp | |||||
rmdir $BSDINSTALL_TMPETC/esp | |||||
# When creating new entries, efibootmgr doesn't mark them active, so we need to | |||||
# do so. It doesn't make it easy to find which entry it just added, so rely on | |||||
# the fact that it places the new entry first in BootOrder. | |||||
bootorder=`efivar --name 8be4df61-93ca-11d2-aa0d-00e098032b8c-BootOrder --print --no-name --hex` | |||||
bootentry=`echo $bootorder | cut -w -f 3``echo $bootorder | cut -w -f 2` | |||||
efibootmgr --activate $bootentry | |||||
done | |||||
fi | |||||
# Add boot0cfg for MBR BIOS booting? |
how can this ever be true? We only ever set X86_BOOTMETHOD foor amd64 and i386.