From 4b2d8cf1485ccdfc5871aec8408848d8db6df116 Mon Sep 17 00:00:00 2001 From: Eric Hameleers Date: Fri, 18 Mar 2016 21:24:37 +0100 Subject: Add support for 32-bit UEFI boot (disabled by default). This requires functionality in grub which is currently not enabled in Slackware's grub package. If you want a 32-bit Live ISO that boots on UEFI computers, you need to recompile Slackware's grub with the patch for grub.SlackBuild which you can find in the ./patches subdirectory. Then you need to set the variable "EFI32" to "YES" in the 'make_slackware_live.sh' script and (re-)generate your 32-bit ISO. The resulting 32-bit Live ISO will be UEFI-bootable. --- EFI/BOOT/make-grub.sh | 19 ++++++--- iso2usb.sh | 3 ++ make_slackware_live.sh | 109 ++++++++++++++++++++++++++++++------------------- 3 files changed, 84 insertions(+), 47 deletions(-) diff --git a/EFI/BOOT/make-grub.sh b/EFI/BOOT/make-grub.sh index d5fcd65..ca5869b 100644 --- a/EFI/BOOT/make-grub.sh +++ b/EFI/BOOT/make-grub.sh @@ -26,11 +26,20 @@ # image (efiboot.img) that goes in the /isolinux directory for booting on # UEFI systems. +# Preparations: +eval $1 # EFIFORM=value1 +eval $2 # EFISUFF=value2 + +# Defaults in case the script was called without parameters: +EFIFORM=${EFIFORM:-"x86_64"} +EFISUFF=${EFISUFF:-"x64"} + echo -echo "Building /EFI/BOOT/bootx64.efi and /boot/syslinux/efiboot.img." +echo "Building /EFI/BOOT/boot${EFISUFF}.efi and /boot/syslinux/efiboot.img." -# First, build bootx64.efi, which will be installed here in /EFI/BOOT: -grub-mkimage --format=x86_64-efi --output=bootx64.efi --config=grub-embedded.cfg --compression=xz --prefix=/EFI/BOOT part_gpt part_msdos fat ext2 hfs hfsplus iso9660 udf ufs1 ufs2 zfs chain linux boot appleldr ahci configfile normal regexp minicmd reboot halt search search_fs_file search_fs_uuid search_label gfxterm gfxmenu efi_gop efi_uga all_video loadbios gzio echo true probe loadenv bitmap_scale font cat help ls png jpeg tga test at_keyboard usb_keyboard +# First, build bootx64.efi/bootia32.efi, +# which will be installed here in /EFI/BOOT: +grub-mkimage --format=${EFIFORM}-efi --output=boot${EFISUFF}.efi --config=grub-embedded.cfg --compression=xz --prefix=/EFI/BOOT part_gpt part_msdos fat ext2 hfs hfsplus iso9660 udf ufs1 ufs2 zfs chain linux boot appleldr ahci configfile normal regexp minicmd reboot halt search search_fs_file search_fs_uuid search_label gfxterm gfxmenu efi_gop efi_uga all_video loadbios gzio echo true probe loadenv bitmap_scale font cat help ls png jpeg tga test at_keyboard usb_keyboard # Then, create a FAT formatted image that contains bootx64.efi in the # /EFI/BOOT directory. This is used to bootstrap GRUB from the ISO image. @@ -43,7 +52,7 @@ MOUNTPOINT=$(mktemp -d) mount -o loop efiboot.img $MOUNTPOINT # Copy the GRUB binary to /EFI/BOOT: mkdir -p $MOUNTPOINT/EFI/BOOT -cp -a bootx64.efi $MOUNTPOINT/EFI/BOOT +cp -a boot${EFISUFF}.efi $MOUNTPOINT/EFI/BOOT # Unmount and clean up: umount $MOUNTPOINT rmdir $MOUNTPOINT @@ -51,5 +60,5 @@ rmdir $MOUNTPOINT mv efiboot.img ../../boot/syslinux/ echo -echo "Done building /EFI/BOOT/bootx64.efi and /boot/syslinux/efiboot.img." +echo "Done building /EFI/BOOT/boot${EFISUFF}.efi and /boot/syslinux/efiboot.img." diff --git a/iso2usb.sh b/iso2usb.sh index 75093db..c519035 100644 --- a/iso2usb.sh +++ b/iso2usb.sh @@ -469,6 +469,9 @@ if [ -n "$EFIOFFSET" ]; then if [ ! -f ${EFIMNT}/EFI/BOOT/bootx64.efi ]; then echo "-- Note: UEFI boot file 'bootx64.efi' not found on ISO." echo "-- UEFI boot will not be supported" + elif [ ! -f ${EFIMNT}/EFI/BOOT/bootia32.efi ]; then + echo "-- Note: UEFI boot file 'bootia32.efi' not found on ISO." + echo "-- 32-bit UEFI boot will not be supported" else EFIBOOT=1 fi diff --git a/make_slackware_live.sh b/make_slackware_live.sh index d14c5a6..bb511fc 100755 --- a/make_slackware_live.sh +++ b/make_slackware_live.sh @@ -49,7 +49,7 @@ if [ -f ${CONFFILE} ]; then fi # Set to "YES" to send error output to the console: -DEBUG=${DEBUG:=NO} +DEBUG=${DEBUG:-"NO"} # Set to "YES" in order to delete everything we have, # and rebuild any pre-existing .sxz modules from scratch: @@ -58,6 +58,13 @@ FORCE=${FORCE:-"NO"} # Set to 32 to be more compatible with the specs. Slackware uses 4 by default: BOOTLOADSIZE=${BOOTLOADSIZE:-4} +# If you want to include an EFI boot image for 32bit Slackware then you +# need a recompiled grub which supports 32bit EFI (Slackware's grub will not). +# A patch for grub.SlackBuild to enable this feature can be found +# in the source directory. Works for both the 32bit and the 64bit grub package. +# Therefore we disable 32bit EFI by default. Enable at your own peril: +EFI32=${EFI32:-"NO"} + # Timestamp: THEDATE=$(date +%Y%m%d) @@ -648,8 +655,12 @@ fi # Directory suffix, arch dependent: if [ "$SL_ARCH" = "x86_64" ]; then DIRSUFFIX="64" + EFIFORM="x86_64" + EFISUFF="x64" else DIRSUFFIX="" + EFIFORM="i386" + EFISUFF="ia32" fi # Package root directory, arch dependent: @@ -1570,31 +1581,34 @@ elif [ ! -f ${LIVE_STAGING}/boot/syslinux/${CONSFONT} ]; then sed -i -e "s/^font .*/#&/" ${LIVE_STAGING}/boot/syslinux/menu/*menu*.cfg fi -# Copy the UEFI boot directory structure: -mkdir -p ${LIVE_STAGING}/EFI/BOOT -cp -a ${LIVE_TOOLDIR}/EFI/BOOT/{grub-embedded.cfg,make-grub.sh,*.txt,theme} ${LIVE_STAGING}/EFI/BOOT/ - -# Create the grub fonts used in the theme: -for FSIZE in 5 10 12; do - grub-mkfont -s ${FSIZE} -av \ - -o ${LIVE_STAGING}/EFI/BOOT/theme/dejavusansmono${FSIZE}.pf2 \ - /usr/share/fonts/TTF/DejaVuSansMono.ttf \ - | grep "^Font name: " -done +# EFI support always for 64bit architecture, but conditional for 32bit. +if [ "$SL_ARCH" = "x86_64" -o "$EFI32" = "YES" ]; then + # Copy the UEFI boot directory structure: + mkdir -p ${LIVE_STAGING}/EFI/BOOT + cp -a ${LIVE_TOOLDIR}/EFI/BOOT/{grub-embedded.cfg,make-grub.sh,*.txt,theme} ${LIVE_STAGING}/EFI/BOOT/ + + # Create the grub fonts used in the theme: + for FSIZE in 5 10 12; do + grub-mkfont -s ${FSIZE} -av \ + -o ${LIVE_STAGING}/EFI/BOOT/theme/dejavusansmono${FSIZE}.pf2 \ + /usr/share/fonts/TTF/DejaVuSansMono.ttf \ + | grep "^Font name: " + done -# The grub-embedded.cfg in the bootx64.efi looks for this file: -touch ${LIVE_STAGING}/EFI/BOOT/${MARKER} + # The grub-embedded.cfg in the bootx64.efi/bootia32.efi looks for this file: + touch ${LIVE_STAGING}/EFI/BOOT/${MARKER} -# Generate the UEFI grub boot image if needed: -if [ ! -f ${LIVE_STAGING}/EFI/BOOT/bootx64.efi -o ! -f ${LIVE_STAGING}/boot/syslinux/efiboot.img ]; then - ( cd ${LIVE_STAGING}/EFI/BOOT - sed -i -e "s/SLACKWARELIVE/${MARKER}/g" grub-embedded.cfg - sh make-grub.sh - ) -fi + # Generate the UEFI grub boot image if needed: + if [ ! -f ${LIVE_STAGING}/EFI/BOOT/boot${EFISUFF}.efi -o ! -f ${LIVE_STAGING}/boot/syslinux/efiboot.img ]; then + ( cd ${LIVE_STAGING}/EFI/BOOT + sed -i -e "s/SLACKWARELIVE/${MARKER}/g" grub-embedded.cfg + sh make-grub.sh EFIFORM=${EFIFORM} EFISUFF=${EFISUFF} + ) + fi -# Generate the grub configuration for UEFI boot: -gen_uefimenu ${LIVE_STAGING}/EFI/BOOT + # Generate the grub configuration for UEFI boot: + gen_uefimenu ${LIVE_STAGING}/EFI/BOOT +fi # End EFI support menu. if [ "$SYSMENU" = "NO" ]; then # Simple isolinux choices, no UEFI support. @@ -1664,6 +1678,14 @@ mkdir -p ${LIVE_STAGING}/rootcopy # Create an ISO file from the directories found below ${LIVE_STAGING}: cd ${LIVE_STAGING} + +# Determine whether we add UEFI boot capabilities to the ISO: +if [ -f boot/syslinux/efiboot.img ]; then + UEFI_OPTS="-eltorito-alt-boot -no-emul-boot -eltorito-platform 0xEF -eltorito-boot boot/syslinux/efiboot.img" +else + UEFI_OPTS="" +fi + mkisofs -o ${OUTPUT}/${DISTRO}${DIRSUFFIX}-live${ISOTAG}-${SL_VERSION}.iso \ -R -J \ -hide-rr-moved \ @@ -1672,8 +1694,7 @@ mkisofs -o ${OUTPUT}/${DISTRO}${DIRSUFFIX}-live${ISOTAG}-${SL_VERSION}.iso \ -sort boot/syslinux/iso.sort \ -b boot/syslinux/isolinux.bin \ -c boot/syslinux/isolinux.boot \ - -eltorito-alt-boot -no-emul-boot -eltorito-platform 0xEF \ - -eltorito-boot boot/syslinux/efiboot.img \ + ${UEFI_OPTS} \ -preparer "$(echo $LIVEDE |sed 's/BASE//') Live built by ${BUILDER}" \ -publisher "The Slackware Linux Project - http://www.slackware.com/" \ -A "${DISTRO^}-${SL_VERSION} for ${SL_ARCH} ($(echo $LIVEDE |sed 's/BASE//') Live $VERSION)" \ @@ -1688,23 +1709,27 @@ rm -rf ./boot cd - 1>/dev/null -SIZEISO=$(stat --printf %s ${OUTPUT}/${DISTRO}${DIRSUFFIX}-live${ISOTAG}-${SL_VERSION}.iso) -# We want no more than 63 sectors, no more than 255 heads, according to -# recommendations from Thomas Schmitt, xoriso developer. -if [ $SIZEISO -gt 1073741824 ]; then - # No more than 63 sectors, no more than 255 heads. We will not try to stick - # to less than 1024 cylinders though: - SECTORS=63 - HEADS=255 -else - # The default values for isohybrid gives us a max size of 1073741824 bytes: - # We want at most 1024 cylinders for old BIOS; also we want no more than - # 63 sectors, no more than 255 heads, which leads to a cut-over size:. - # 64 (heads) *32 (sectors) *1024 (cylinders) *512 (bytes) = 1073741824 bytes. - SECTORS=32 - HEADS=64 -fi -isohybrid -s $SECTORS -h $HEADS -u ${OUTPUT}/${DISTRO}${DIRSUFFIX}-live${ISOTAG}-${SL_VERSION}.iso +if [ "$SL_ARCH" = "x86_64" -o "$EFI32" = "YES" ]; then + # Make this a hybrid ISO with UEFI boot support on x86_64. + # On 32bit, the variable EFI32 must be explicitly enabled. + SIZEISO=$(stat --printf %s ${OUTPUT}/${DISTRO}${DIRSUFFIX}-live${ISOTAG}-${SL_VERSION}.iso) + # We want no more than 63 sectors, no more than 255 heads, according to + # recommendations from Thomas Schmitt, xoriso developer. + if [ $SIZEISO -gt 1073741824 ]; then + # No more than 63 sectors, no more than 255 heads. We will not try to stick + # to less than 1024 cylinders though: + SECTORS=63 + HEADS=255 + else + # The default values for isohybrid gives us a max size of 1073741824 bytes: + # We want at most 1024 cylinders for old BIOS; also we want no more than + # 63 sectors, no more than 255 heads, which leads to a cut-over size:. + # 64 (heads) *32 (sectors) *1024 (cylinders) *512 (bytes) = 1073741824 bytes. + SECTORS=32 + HEADS=64 + fi + isohybrid -s $SECTORS -h $HEADS -u ${OUTPUT}/${DISTRO}${DIRSUFFIX}-live${ISOTAG}-${SL_VERSION}.iso +fi # End UEFI hybrid ISO. cd ${OUTPUT} md5sum ${DISTRO}${DIRSUFFIX}-live${ISOTAG}-${SL_VERSION}.iso \ -- cgit v1.2.3