aboutsummaryrefslogtreecommitdiff
path: root/release
diff options
context:
space:
mode:
authorRebecca Cran <bcran@FreeBSD.org>2018-12-20 19:39:37 +0000
committerRebecca Cran <bcran@FreeBSD.org>2018-12-20 19:39:37 +0000
commitdb8b56134506840832bec2d1ce07b9e00d4d6d71 (patch)
tree242e3d5aea577a1691fc784b6b35da9690e23d5c /release
parentd5cee48f3e65662051e15c85e4fc1841d72977fe (diff)
downloadsrc-db8b56134506840832bec2d1ce07b9e00d4d6d71.tar.gz
src-db8b56134506840832bec2d1ce07b9e00d4d6d71.zip
Rework UEFI ESP generation
Currently, the installer uses pre-created 800KB FAT12 filesystems that it dd's onto the ESP partition. This changeset improves that by having the installer generate a FAT32 filesystem directly onto the ESP using newfs_msdos and then copying loader.efi into /EFI/freebsd. For live installs it then runs efibootmgr to add a FreeBSD boot entry in the BIOS. Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D17947
Notes
Notes: svn path=/head/; revision=342283
Diffstat (limited to 'release')
-rwxr-xr-xrelease/amd64/make-memstick.sh10
-rw-r--r--release/amd64/mkisoimages.sh23
-rwxr-xr-xrelease/arm64/make-memstick.sh10
-rwxr-xr-xrelease/i386/make-memstick.sh9
-rw-r--r--release/tools/vmimage.subr9
5 files changed, 45 insertions, 16 deletions
diff --git a/release/amd64/make-memstick.sh b/release/amd64/make-memstick.sh
index 3de8cb2a0b83..c0e405c3a976 100755
--- a/release/amd64/make-memstick.sh
+++ b/release/amd64/make-memstick.sh
@@ -12,6 +12,9 @@
set -e
+scriptdir=$(dirname $(realpath $0))
+. ${scriptdir}/../../tools/boot/install-boot.sh
+
PATH=/bin:/usr/bin:/sbin:/usr/sbin
export PATH
@@ -36,11 +39,16 @@ makefs -B little -o label=FreeBSD_Install -o version=2 ${2}.part ${1}
rm ${1}/etc/fstab
rm ${1}/etc/rc.conf.local
+# Make an ESP in a file.
+espfilename=$(mktemp /tmp/efiboot.XXXXXX)
+make_esp_file ${espfilename} ${fat32min} ${1}/boot/loader.efi
+
mkimg -s mbr \
-b ${1}/boot/mbr \
- -p efi:=${1}/boot/boot1.efifat \
+ -p efi:=${espfilename} \
-p freebsd:-"mkimg -s bsd -b ${1}/boot/boot -p freebsd-ufs:=${2}.part" \
-a 2 \
-o ${2}
+rm ${espfilename}
rm ${2}.part
diff --git a/release/amd64/mkisoimages.sh b/release/amd64/mkisoimages.sh
index 8a0aceb0eb9f..2893913abc8a 100644
--- a/release/amd64/mkisoimages.sh
+++ b/release/amd64/mkisoimages.sh
@@ -25,6 +25,9 @@
set -e
+scriptdir=$(dirname $(realpath $0))
+. ${scriptdir}/../../tools/boot/install-boot.sh
+
if [ -z $ETDUMP ]; then
ETDUMP=etdump
fi
@@ -43,18 +46,12 @@ if [ "$1" = "-b" ]; then
bootable="-o bootimage=i386;$BASEBITSDIR/boot/cdboot -o no-emul-boot"
# Make EFI system partition (should be done with makefs in the future)
- dd if=/dev/zero of=efiboot.img bs=4k count=200
- device=`mdconfig -a -t vnode -f efiboot.img`
- newfs_msdos -F 12 -m 0xf8 /dev/$device
- mkdir efi
- mount -t msdosfs /dev/$device efi
- mkdir -p efi/efi/boot
- cp "$BASEBITSDIR/boot/loader.efi" efi/efi/boot/bootx64.efi
- umount efi
- rmdir efi
- mdconfig -d -u $device
- bootable="$bootable -o bootimage=i386;efiboot.img -o no-emul-boot -o platformid=efi"
-
+ # The ISO file is a special case, in that it only has a maximum of
+ # 800 KB available for the boot code. So make an 800 KB ESP
+ espfilename=$(mktemp /tmp/efiboot.XXXXXX)
+ make_esp_file ${espfilename} 800 ${BASEBITSDIR}/boot/loader.efi
+ bootable="$bootable -o bootimage=i386;${espfilename} -o no-emul-boot -o platformid=efi"
+
shift
else
BASEBITSDIR="$3"
@@ -73,7 +70,7 @@ publisher="The FreeBSD Project. https://www.FreeBSD.org/"
echo "/dev/iso9660/$LABEL / cd9660 ro 0 0" > "$BASEBITSDIR/etc/fstab"
$MAKEFS -t cd9660 $bootable -o rockridge -o label="$LABEL" -o publisher="$publisher" "$NAME" "$@"
rm -f "$BASEBITSDIR/etc/fstab"
-rm -f efiboot.img
+rm -f ${espfilename}
if [ "$bootable" != "" ]; then
# Look for the EFI System Partition image we dropped in the ISO image.
diff --git a/release/arm64/make-memstick.sh b/release/arm64/make-memstick.sh
index 1225acba44f8..958aa1ff6013 100755
--- a/release/arm64/make-memstick.sh
+++ b/release/arm64/make-memstick.sh
@@ -15,6 +15,9 @@ set -e
PATH=/bin:/usr/bin:/sbin:/usr/sbin
export PATH
+scriptdir=$(dirname $(realpath $0))
+. ${scriptdir}/../../tools/boot/install-boot.sh
+
if [ $# -ne 2 ]; then
echo "make-memstick.sh /path/to/directory /path/to/image/file"
exit 1
@@ -36,9 +39,14 @@ makefs -B little -o label=FreeBSD_Install -o version=2 ${2}.part ${1}
rm ${1}/etc/fstab
rm ${1}/etc/rc.conf.local
+# Make an ESP in a file.
+espfilename=$(mktemp /tmp/efiboot.XXXXXX)
+make_esp_file ${espfilename} ${fat32min} ${1}/boot/loader.efi
+
mkimg -s gpt \
- -p efi:=${1}/boot/boot1.efifat \
+ -p efi:=${espfilename} \
-p freebsd:=${2}.part \
-o ${2}
+rm ${espfilename}
rm ${2}.part
diff --git a/release/i386/make-memstick.sh b/release/i386/make-memstick.sh
index 6774e86ae550..92818ec6e6da 100755
--- a/release/i386/make-memstick.sh
+++ b/release/i386/make-memstick.sh
@@ -12,6 +12,9 @@
set -e
+scriptdir=$(dirname $(realpath $0))
+. ${scriptdir}/../../tools/boot/install-boot.sh
+
PATH=/bin:/usr/bin:/sbin:/usr/sbin
export PATH
@@ -36,9 +39,15 @@ makefs -B little -o label=FreeBSD_Install -o version=2 ${2}.part ${1}
rm ${1}/etc/fstab
rm ${1}/etc/rc.conf.local
+# Make an ESP in a file.
+espfilename=$(mktemp /tmp/efiboot.XXXXXX)
+make_esp_file ${espfilename} ${fat32min} ${1}/boot/loader.efi
+
mkimg -s mbr \
-b ${1}/boot/mbr \
+ -p efi:=${espfilename}
-p freebsd:-"mkimg -s bsd -b ${1}/boot/boot -p freebsd-ufs:=${2}.part" \
-o ${2}
+rm ${espfilename}
rm ${2}.part
diff --git a/release/tools/vmimage.subr b/release/tools/vmimage.subr
index d36b47d86123..287c2741f156 100644
--- a/release/tools/vmimage.subr
+++ b/release/tools/vmimage.subr
@@ -6,6 +6,9 @@
# Common functions for virtual machine image build scripts.
#
+scriptdir=$(dirname $(realpath $0))
+. ${scriptdir}/../../tools/boot/install-boot.sh
+
export PATH="/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin:/usr/local/sbin"
trap "cleanup" INT QUIT TRAP ABRT TERM
@@ -29,10 +32,14 @@ write_partition_layout() {
-o ${VMIMAGE}
;;
arm64:aarch64)
+ # Create an ESP
+ espfilename=$(mktemp /tmp/efiboot.XXXXXX)
+ make_esp_file ${espfilename} ${fat32min} ${BOOTFILES}/efi/loader_lua/loader_lua.efi
mkimg -s mbr -f ${VMFORMAT} \
- -p efi:=${BOOTFILES}/efi/boot1/boot1.efifat \
+ -p efi:=${espfilename} \
-p freebsd:=${VMBASE} \
-o ${VMIMAGE}
+ rm ${espfilename}
;;
powerpc:powerpc*)
mkimg -s apm -f ${VMFORMAT} \