Fix ISO build: extract EFI partition from original ISO with dd
This commit is contained in:
parent
401bb1bbf8
commit
0b06f600e8
@ -68,10 +68,28 @@ sed -i "s/set timeout_style=.*/set timeout_style=countdown/" "$GRUB_CFG"
|
|||||||
sed -i "/^\s*linux.*vmlinuz/s/$/ autoinstall quiet ds=nocloud;s=\/cdrom\/nocloud\//" "$GRUB_CFG"
|
sed -i "/^\s*linux.*vmlinuz/s/$/ autoinstall quiet ds=nocloud;s=\/cdrom\/nocloud\//" "$GRUB_CFG"
|
||||||
echo "✓ GRUB patched"
|
echo "✓ GRUB patched"
|
||||||
|
|
||||||
# ── Get MBR template from original ISO ─────────
|
# ── Extract MBR and EFI partition from original ISO ────
|
||||||
|
echo "→ Extracting boot data from original ISO..."
|
||||||
MBR_TEMPLATE=$(mktemp)
|
MBR_TEMPLATE=$(mktemp)
|
||||||
|
EFI_IMG=$(mktemp)
|
||||||
dd if="$ORIGINAL_ISO" bs=1 count=432 of="$MBR_TEMPLATE" 2>/dev/null
|
dd if="$ORIGINAL_ISO" bs=1 count=432 of="$MBR_TEMPLATE" 2>/dev/null
|
||||||
|
|
||||||
|
# Find EFI partition (partition 2) start and size in 512-byte sectors
|
||||||
|
EFI_LINE=$(fdisk -l "$ORIGINAL_ISO" 2>/dev/null | grep "EFI")
|
||||||
|
echo " EFI partition info: $EFI_LINE"
|
||||||
|
EFI_START=$(echo "$EFI_LINE" | awk '{print $2}')
|
||||||
|
EFI_SIZE=$(echo "$EFI_LINE" | awk '{print $4}')
|
||||||
|
|
||||||
|
if [ -z "$EFI_START" ] || [ -z "$EFI_SIZE" ]; then
|
||||||
|
echo "ERROR: Could not detect EFI partition in ISO."
|
||||||
|
echo "Run: fdisk -l $ORIGINAL_ISO"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
dd if="$ORIGINAL_ISO" bs=512 skip="$EFI_START" count="$EFI_SIZE" \
|
||||||
|
of="$EFI_IMG" 2>/dev/null
|
||||||
|
echo "✓ EFI partition extracted (start=$EFI_START, size=$EFI_SIZE)"
|
||||||
|
|
||||||
# ── Repack ISO ─────────────────────────────────
|
# ── Repack ISO ─────────────────────────────────
|
||||||
echo "→ Repacking ISO (this takes ~2 minutes)..."
|
echo "→ Repacking ISO (this takes ~2 minutes)..."
|
||||||
xorriso -as mkisofs \
|
xorriso -as mkisofs \
|
||||||
@ -81,8 +99,7 @@ xorriso -as mkisofs \
|
|||||||
--grub2-mbr "$MBR_TEMPLATE" \
|
--grub2-mbr "$MBR_TEMPLATE" \
|
||||||
-partition_offset 16 \
|
-partition_offset 16 \
|
||||||
--mbr-force-bootable \
|
--mbr-force-bootable \
|
||||||
-append_partition 2 28732ac11ff8d211ba4b00a0c93ec93b \
|
-append_partition 2 28732ac11ff8d211ba4b00a0c93ec93b "$EFI_IMG" \
|
||||||
"$WORK_DIR/boot/grub/efi.img" \
|
|
||||||
-appended_part_as_gpt \
|
-appended_part_as_gpt \
|
||||||
-iso_mbr_part_type a2a0d0ebe5b9334487c068b6b72699c7 \
|
-iso_mbr_part_type a2a0d0ebe5b9334487c068b6b72699c7 \
|
||||||
-c "/boot.catalog" \
|
-c "/boot.catalog" \
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user