Page MenuHomeFreeBSD

D19992.diff
No OneTemporary

D19992.diff

Index: head/tools/boot/install-boot.sh
===================================================================
--- head/tools/boot/install-boot.sh
+++ head/tools/boot/install-boot.sh
@@ -134,29 +134,37 @@
echo "Copying loader to /EFI/freebsd on ESP"
cp "${file}" "${mntpt}/EFI/freebsd/loader.efi"
- existingbootentryloaderfile=$(efibootmgr -v | grep "${mntpt}//EFI/freebsd/loader.efi")
+ if [ -n "${updatesystem}" ]; then
+ existingbootentryloaderfile=$(efibootmgr -v | grep "${mntpt}//EFI/freebsd/loader.efi")
- if [ -z "$existingbootentryloaderfile" ]; then
- # Try again without the double forward-slash in the path
- existingbootentryloaderfile=$(efibootmgr -v | grep "${mntpt}/EFI/freebsd/loader.efi")
- fi
-
- if [ -z "$existingbootentryloaderfile" ]; then
- echo "Creating UEFI boot entry for FreeBSD"
- efibootmgr --create --label FreeBSD --loader "${mntpt}/EFI/freebsd/loader.efi" > /dev/null
- if [ $? -ne 0 ]; then
- die "Failed to create new boot entry"
+ if [ -z "$existingbootentryloaderfile" ]; then
+ # Try again without the double forward-slash in the path
+ existingbootentryloaderfile=$(efibootmgr -v | grep "${mntpt}/EFI/freebsd/loader.efi")
fi
- # 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 | head -1)
- bootentry=$(echo "${bootorder}" | cut -w -f 3)$(echo "${bootorder}" | cut -w -f 2)
- echo "Marking UEFI boot entry ${bootentry} active"
- efibootmgr --activate "${bootentry}" > /dev/null
+ if [ -z "$existingbootentryloaderfile" ]; then
+ echo "Creating UEFI boot entry for FreeBSD"
+ efibootmgr --create --label FreeBSD --loader "${mntpt}/EFI/freebsd/loader.efi" > /dev/null
+ if [ $? -ne 0 ]; then
+ die "Failed to create new boot entry"
+ fi
+
+ # 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 | head -1)
+ bootentry=$(echo "${bootorder}" | cut -w -f 3)$(echo "${bootorder}" | cut -w -f 2)
+ echo "Marking UEFI boot entry ${bootentry} active"
+ efibootmgr --activate "${bootentry}" > /dev/null
+ else
+ echo "Existing UEFI FreeBSD boot entry found: not creating a new one"
+ fi
else
- echo "Existing UEFI FreeBSD boot entry found: not creating a new one"
+ # Configure for booting from removable media
+ if [ ! -d "${mntpt}/EFI/BOOT" ]; then
+ mkdir -p "${mntpt}/EFI/BOOT"
+ fi
+ cp "${file}" "${mntpt}/EFI/BOOT/${efibootname}.efi"
fi
umount "${mntpt}"
@@ -362,6 +370,8 @@
printf ' -f fs filesystem type: ufs or zfs\n'
printf ' -g geli yes or no\n'
printf ' -h this help/usage text\n'
+ printf ' -u Run commands such as efibootmgr to update the\n'
+ printf ' currently running system\n'
printf ' -o optargs optional arguments\n'
printf ' -s scheme mbr or gpt\n'
exit 0
@@ -372,7 +382,7 @@
# Note: we really don't support geli boot in this script yet.
geli=nogeli
-while getopts "b:d:f:g:ho:s:" opt; do
+while getopts "b:d:f:g:ho:s:u" opt; do
case "$opt" in
b)
bios=${OPTARG}
@@ -388,6 +398,9 @@
[Yy][Ee][Ss]|geli) geli=geli ;;
*) geli=nogeli ;;
esac
+ ;;
+ u)
+ updatesystem=1
;;
o)
opts=${OPTARG}
Index: head/tools/boot/rootgen.sh
===================================================================
--- head/tools/boot/rootgen.sh
+++ head/tools/boot/rootgen.sh
@@ -27,6 +27,8 @@
# vars should likely be conditionally set to allow better automation.
#
+. $(dirname $0)/install-boot.sh
+
cpsys() {
src=$1
dst=$2
@@ -56,7 +58,7 @@
cat > ${src}/etc/fstab <<EOF
/dev/ada0p2 / ufs rw 1 1
EOF
- make_esp_file ${img}.p1 ${espsize} ${src}
+ make_esp_file ${img}.p1 ${espsize} ${src}/boot/loader.efi
makefs -t ffs -B little -s 200m ${img}.p2 ${src}
mkimg -s gpt \
-p efi:=${img}.p1 \
@@ -71,7 +73,7 @@
cat > ${src}/etc/fstab <<EOF
/dev/ada0p3 / ufs rw 1 1
EOF
- make_esp_file ${img}.p1 ${espsize} ${src}
+ make_esp_file ${img}.p1 ${espsize} ${src}/boot/loader.efi
makefs -t ffs -B little -s 200m ${img}.p3 ${src}
# p1 is boot for uefi, p2 is boot for gpt, p3 is /
mkimg -b ${src}/boot/pmbr -s gpt \
@@ -217,7 +219,7 @@
cat > ${src}/etc/fstab <<EOF
/dev/ada0s2a / ufs rw 1 1
EOF
- make_esp_file ${img}.s1 ${espsize} ${src}
+ make_esp_file ${img}.s1 ${espsize} ${src}/boot/loader.efi
makefs -t ffs -B little -s 200m ${img}.s2a ${src}
mkimg -s bsd -p freebsd-ufs:=${img}.s2a -o ${img}.s2
mkimg -a 1 -s mbr -p efi:=${img}.s1 -p freebsd:=${img}.s2 -o ${img}
@@ -231,7 +233,7 @@
cat > ${src}/etc/fstab <<EOF
/dev/ada0s2a / ufs rw 1 1
EOF
- make_esp_file ${img}.s1 ${espsize} ${src}
+ make_esp_file ${img}.s1 ${espsize} ${src}/boot/loader.efi
makefs -t ffs -B little -s 200m ${img}.s2a ${src}
mkimg -s bsd -b ${src}/boot/boot -p freebsd-ufs:=${img}.s2a -o ${img}.s2
mkimg -a 2 -s mbr -b ${src}/boot/mbr -p efi:=${img}.s1 -p freebsd:=${img}.s2 -o ${img}

File Metadata

Mime Type
text/plain
Expires
Thu, Jul 23, 9:19 AM (2 h, 11 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
35397151
Default Alt Text
D19992.diff (5 KB)

Event Timeline