From 1868029f7b9c276f26b5b39389915f7ded85ae2d Mon Sep 17 00:00:00 2001 From: cvoges12 Date: Thu, 7 Oct 2021 22:47:00 +0000 Subject: [PATCH] uefi and bios style boot images with mkisofs --- src/iso.sh | 55 ++++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 47 insertions(+), 8 deletions(-) diff --git a/src/iso.sh b/src/iso.sh index f691379..8ae1aca 100755 --- a/src/iso.sh +++ b/src/iso.sh @@ -4,29 +4,68 @@ printf '%b\n' "\n\033[1m"WINDOWS_INIT:"\033[0m"" Executing extract_iso.sh" src/extract_iso.sh EXTRACT="win/" -printf '%b\n' "\n\033[1m"WINDOWS_INIT:"\033[0m"" Executing bootsect.sh" -src/bootsect.sh +#printf '%b\n' "\n\033[1m"WINDOWS_INIT:"\033[0m"" Executing bootsect.sh" +#./src/bootsect.sh +#BOOT="bootsect.bin" # add answerfile cp data/autounattend.xml ${EXTRACT} -BOOT="bootsect.bin" + +# data for mkisofs +BOOT="boot/etfsboot.com" +EFI="efi/boot/bootx64.efi" +LOAD_SEG="$(dumpet -i Win*.iso \ + | grep "Media load segment: " \ + | cut -d ':' -f2 \ + | cut -d ' ' -f2)" +LOAD_SIZE="$(dumpet -i Win*.iso \ + | grep "Load Sectors: " \ + | grep -o "[^:]*$" \ + | cut -d ' ' -f2 \ + | head -1)" +LDA="$(dumpet -i Win*.iso \ + | grep "LDA" \ + | tail -n 1 \ + | awk '{printf $3}')" +CDROM_SECTOR_SIZE=2048 +FLOPPY_SECTOR_SIZE=512 + +# number of floppy disk sectors +dd if=Win*.iso bs=${CDROM_SECTOR_SIZE} skip=${LDA} count=1 > win.dmp +FLOPPY_SECTORS="$(file win.dmp \ + | sed -e "s/.*sectors\ //" \ + | awk '{printf $1}')" +rm win.dmp + +CDROM_SECTORS=`expr $FLOPPY_SECTOR_SIZE \ + \* $FLOPPY_SECTORS \ + / $CDROM_SECTOR_SIZE` +dd if=Win*.iso bs=${CDROM_SECTOR_SIZE} skip=${LDA} count=${CDROM_SECTORS} of=win_efi_boot.img # install mkisofs # recreate iso cd ${EXTRACT} mkisofs \ -allow-limited-size \ - -b ${BOOT} \ -no-emul-boot \ - -boot-load-seg 1984 \ - -boot-load-size 4 \ + -b ${BOOT} \ + -boot-load-seg ${LOAD_SEG} \ + -boot-load-size ${LOAD_SIZE} \ + -eltorito-alt-boot \ + -b ${EFI} \ + -eltorito-platform efi \ -iso-level 2 \ - -J -l -D -N -joliet-long -relaxed-filenames \ + -boot-info-table + -udf + -J -l -joliet-long \ + -D \ + -N \ + -relaxed-filenames \ -V "WINSP" \ -o winsp.iso \ . -cp winsp.iso ../ +mv winsp.iso ../ # clean up bootsect and iso extract cd ..