Generate hybrid ISO images for amd64.

This keeps the existing El Torito entries for BIOS and UEFI boot code and
adds a GPT in the ISO image's System Area containing boot code for BIOS that
will load /boot/loader from the ISO filesystem and execute it. We then use
etdump to find the EFI System Partition image in the El Torito catalog and
add an entry to the GPT that allows EFI to find it.

Reviewed by:	gjb, imp
Sponsored by:	iXsystems, Inc.
Differential Revision:	https://reviews.freebsd.org/D15051
This commit is contained in:
Benno Rice 2018-04-17 22:33:41 +00:00
parent edba22b0fb
commit 0279ac04ed
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=332661

View File

@ -38,7 +38,7 @@ if [ "$1" = "-b" ]; then
umount efi
rmdir efi
mdconfig -d -u $device
bootable="-o bootimage=i386;efiboot.img -o no-emul-boot -o platformid=efi $bootable"
bootable="$bootable -o bootimage=i386;efiboot.img -o no-emul-boot -o platformid=efi"
shift
else
@ -58,3 +58,29 @@ echo "/dev/iso9660/$LABEL / cd9660 ro 0 0" > "$1/etc/fstab"
makefs -t cd9660 $bootable -o rockridge -o label="$LABEL" -o publisher="$publisher" "$NAME" "$@"
rm -f "$1/etc/fstab"
rm -f efiboot.img
if [ "$bootable" != "" ]; then
# Look for the EFI System Partition image we dropped in the ISO image.
for entry in `etdump --format shell $NAME`; do
eval $entry
if [ "$et_platform" = "efi" ]; then
espstart=`expr $et_lba \* 2048`
espsize=`expr $et_sectors \* 512`
espparam="-p efi::$espsize:$espstart"
break
fi
done
# Create a GPT image containing the partitions we need for hybrid boot.
imgsize=`stat -f %z $NAME`
mkimg -s gpt \
--capacity $imgsize \
-b $4/boot/pmbr \
$espparam \
-p freebsd-boot:=$4/boot/isoboot \
-o hybrid.img
# Drop the PMBR, GPT, and boot code into the System Area of the ISO.
dd if=hybrid.img of=$NAME bs=32k count=1 conv=notrunc
rm -f hybrid.img
fi