From 33a176bc3ebc7fb39f63b4114fc150f3815f0d81 Mon Sep 17 00:00:00 2001 From: 28allday Date: Wed, 29 Apr 2026 18:35:23 +0100 Subject: [PATCH] Use boot-image replay to rebuild ISO faithfully MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replaces the bespoke xorriso -as mkisofs invocation (and its EFI partition dd extraction) with a single -boot_image any replay -map call that preserves the source ISO's MBR, GPT, El Torito and archiso layout flags byte-for-byte. The previous approach dropped --mbr-force-bootable, -partition_offset 16, -iso_mbr_part_type 0x00 and -partition_cyl_align off, which Omarchy 3.6's stricter mkarchiso layout requires — without them the rebuilt ISO hung at the boot splash on Acer Insyde, Lenovo and MSI firmware. Also recompute airootfs.sha512 in case a future archiso ever enables verify=y on the kernel cmdline. Works for any Omarchy version (3.4, 3.5, 3.6, future) without per-version tweaks. --- patch-omarchy-dualboot.sh | 134 +++++++------------------------------- 1 file changed, 25 insertions(+), 109 deletions(-) diff --git a/patch-omarchy-dualboot.sh b/patch-omarchy-dualboot.sh index b5d823b..ea13a12 100755 --- a/patch-omarchy-dualboot.sh +++ b/patch-omarchy-dualboot.sh @@ -895,122 +895,38 @@ fi log "New squashfs created: $(du -h "$SQUASHFS" | cut -f1)" #=============================================================================== -# UPDATE BOOT CONFIGS +# UPDATE AIROOTFS CHECKSUM #=============================================================================== -log "Creating new ISO..." - -ISO_LABEL=$(isoinfo -d -i "$SOURCE_ISO" 2>/dev/null | grep "Volume id:" | cut -d: -f2 | tr -d ' ' || echo "OMARCHY") -log "ISO label: $ISO_LABEL" - -# Update boot configs to use label instead of UUID -log "Updating boot configurations..." -for cfg in "$WORK_DIR/newiso/boot/syslinux/"*.cfg \ - "$WORK_DIR/newiso/loader/entries/"*.conf \ - "$WORK_DIR/newiso/boot/grub/grub.cfg" \ - "$WORK_DIR/newiso/EFI/BOOT/grub.cfg"; do - if [[ -f "$cfg" ]]; then - sed -i "s/archisosearchuuid=[^ ]*/archisolabel=$ISO_LABEL/g" "$cfg" - fi -done +# Recompute the airootfs.sha512 to match the new squashfs. archiso checks +# this only when the kernel cmdline includes verify=y (3.6 doesn't), but +# keeping it in sync is cheap insurance against future versions enabling it. +log "Updating airootfs.sha512..." +NEW_HASH=$(sha512sum "$SQUASHFS" | awk '{print $1}') +echo "$NEW_HASH airootfs.sfs" > "$WORK_DIR/newiso/arch/x86_64/airootfs.sha512" #=============================================================================== -# EXTRACT EFI BOOT IMAGE FROM ORIGINAL ISO +# CREATE ISO (faithful boot-layout replay) #=============================================================================== +# Replay the original ISO's boot setup byte-for-byte and overlay only the +# files we changed (patched squashfs + its checksum). This preserves MBR, +# GPT, El Torito, the appended EFI partition, archisosearchuuid, and the +# archiso layout flags (--mbr-force-bootable, -partition_offset 16, +# -iso_mbr_part_type 0x00, -partition_cyl_align off) that mkarchiso emits. +# Recreating from scratch via -as mkisofs tends to drop those and breaks +# boot on stricter UEFI firmware (Acer Insyde, Lenovo, MSI). Works for any +# Omarchy/archiso version (3.4, 3.5, 3.6, future) without per-version tweaks. -log "Extracting EFI boot image from original ISO..." +log "Building new ISO via boot-image replay..." +rm -f "$OUTPUT_ISO" -# Get the xorriso parameters from the original ISO to replicate its boot setup -XORRISO_PARAMS=$(xorriso -indev "$SOURCE_ISO" -report_el_torito as_mkisofs 2>/dev/null) - -# Extract the appended EFI partition from the original ISO -# Format: -append_partition 2 0xef --interval:local_fs:STARTd-ENDd:: -EFI_LINE=$(echo "$XORRISO_PARAMS" | grep "append_partition 2 0xef") -if [[ -n "$EFI_LINE" ]]; then - log "Found EFI partition in original ISO" - # Extract start and end from the interval (format: NUMBERd-NUMBERd) - EFI_RANGE=$(echo "$EFI_LINE" | grep -oE '[0-9]+d-[0-9]+d') - EFI_START=$(echo "$EFI_RANGE" | cut -d'-' -f1 | tr -d 'd') - EFI_END=$(echo "$EFI_RANGE" | cut -d'-' -f2 | tr -d 'd') - - if [[ -n "$EFI_START" && -n "$EFI_END" ]]; then - EFI_SIZE=$((EFI_END - EFI_START + 1)) - log "Extracting EFI partition: start=$EFI_START end=$EFI_END size=$EFI_SIZE sectors" - # The 'd' values from xorriso are in 512-byte sectors - dd if="$SOURCE_ISO" of="$WORK_DIR/efi.img" bs=512 skip="$EFI_START" count="$EFI_SIZE" status=progress - - if [[ -f "$WORK_DIR/efi.img" ]]; then - EFI_IMG_SIZE=$(stat -c%s "$WORK_DIR/efi.img") - log "EFI image created: $((EFI_IMG_SIZE / 1024 / 1024))MB" - else - warn "Failed to extract EFI image" - fi - else - warn "Could not parse EFI partition range" - fi -else - warn "No EFI partition found in original ISO" -fi - -#=============================================================================== -# CREATE ISO -#=============================================================================== - -if [[ -f "$WORK_DIR/newiso/boot/syslinux/isolinux.bin" ]]; then - log "Creating hybrid BIOS/UEFI ISO..." - - if [[ -f "$WORK_DIR/efi.img" ]]; then - # Use extracted EFI image for proper UEFI boot - xorriso -as mkisofs \ - -iso-level 3 \ - -full-iso9660-filenames \ - -rational-rock \ - -volid "$ISO_LABEL" \ - -eltorito-boot boot/syslinux/isolinux.bin \ - -eltorito-catalog boot/syslinux/boot.cat \ - -no-emul-boot \ - -boot-load-size 4 \ - -boot-info-table \ - -isohybrid-mbr "$WORK_DIR/newiso/boot/syslinux/isohdpfx.bin" \ - -eltorito-alt-boot \ - -e --interval:appended_partition_2:all:: \ - -no-emul-boot \ - -append_partition 2 0xef "$WORK_DIR/efi.img" \ - -isohybrid-gpt-basdat \ - -o "$OUTPUT_ISO" \ - "$WORK_DIR/newiso" - else - warn "EFI image not found, using fallback method..." - xorriso -as mkisofs \ - -iso-level 3 \ - -full-iso9660-filenames \ - -rational-rock \ - -volid "$ISO_LABEL" \ - -eltorito-boot boot/syslinux/isolinux.bin \ - -eltorito-catalog boot/syslinux/boot.cat \ - -no-emul-boot \ - -boot-load-size 4 \ - -boot-info-table \ - -isohybrid-mbr "$WORK_DIR/newiso/boot/syslinux/isohdpfx.bin" \ - -eltorito-alt-boot \ - -e EFI/BOOT/BOOTX64.EFI \ - -no-emul-boot \ - -isohybrid-gpt-basdat \ - -o "$OUTPUT_ISO" \ - "$WORK_DIR/newiso" - fi -else - log "Creating UEFI-only ISO..." - xorriso -as mkisofs \ - -iso-level 3 \ - -full-iso9660-filenames \ - -volid "$ISO_LABEL" \ - -e EFI/BOOT/BOOTX64.EFI \ - -no-emul-boot \ - -isohybrid-gpt-basdat \ - -o "$OUTPUT_ISO" \ - "$WORK_DIR/newiso" -fi +xorriso \ + -indev "$SOURCE_ISO" \ + -outdev "$OUTPUT_ISO" \ + -boot_image any replay \ + -map "$SQUASHFS" /arch/x86_64/airootfs.sfs \ + -map "$WORK_DIR/newiso/arch/x86_64/airootfs.sha512" /arch/x86_64/airootfs.sha512 \ + -commit #=============================================================================== # DONE