78 lines
3.3 KiB
Bash
78 lines
3.3 KiB
Bash
#!/bin/bash
|
|
# Rebuild Acronis component images (self-contained: source ISO on D:).
|
|
# Result: D:/PF2026/acronis/new/{ADD,ABA}.iso with BIOS + dual-arch EFI.
|
|
set -e
|
|
SRC=/path/to/pf/acronis/Acronis_Boot_Disk_2024.iso
|
|
OUT=/path/to/pf/acronis/new
|
|
W=/root/acrbuild
|
|
rm -rf "$W"; mkdir -p "$W" "$OUT"
|
|
|
|
apt-get install -y grub-pc-bin grub-efi-amd64-bin grub-efi-ia32-bin mtools xorriso >/tmp/apt3.log 2>&1 || true
|
|
|
|
build_one() {
|
|
local name="$1" srcdir="$2" kernel="$3" initrds="$4"
|
|
local tree="$W/$name"
|
|
mkdir -p "$tree/$srcdir"
|
|
|
|
echo "=== $name : ACR/$srcdir"
|
|
7z e -y -o"$tree/$srcdir" "$SRC" "ACR/$srcdir/$kernel" $(for i in $initrds; do echo "ACR/$srcdir/$i"; done) >/dev/null
|
|
ls -l "$tree/$srcdir" | tail -4
|
|
|
|
mkdir -p "$tree/boot/grub"
|
|
cat > "$tree/boot/grub/grub.cfg" <<EOF
|
|
set timeout=0
|
|
set default=0
|
|
menuentry "Acronis" {
|
|
linux /$srcdir/$kernel force_modules=usbhid quiet lang=RU_ru
|
|
initrd $(for i in $initrds; do echo -n "/$srcdir/$i "; done)
|
|
}
|
|
EOF
|
|
|
|
# 1. base image: BIOS boot (grub-pc) + x64 EFI, from grub-mkrescue
|
|
grub-mkrescue -o "$W/$name.base.iso" "$tree" >/tmp/mk_$name.log 2>&1
|
|
xorriso -osirrox on -indev "$W/$name.base.iso" \
|
|
-extract /boot/grub/i386-pc/eltorito.img "$tree/boot/grub/i386-pc/eltorito.img" >/dev/null 2>&1
|
|
|
|
# 2. our own EFI boot image with BOTH loaders
|
|
cat > "$W/$name.cfg" <<EOF
|
|
search --no-floppy --set=root --file /$srcdir/$kernel
|
|
linux /$srcdir/$kernel force_modules=usbhid quiet lang=RU_ru
|
|
initrd $(for i in $initrds; do echo -n "/$srcdir/$i "; done)
|
|
boot
|
|
EOF
|
|
grub-mkimage -O x86_64-efi -o "$W/BOOTX64.EFI" -p /boot/grub \
|
|
-d /usr/lib/grub/x86_64-efi -c "$W/$name.cfg" \
|
|
linux normal iso9660 search search_label search_fs_file part_msdos echo test
|
|
grub-mkimage -O i386-efi -o "$W/BOOTIA32.EFI" -p /boot/grub \
|
|
-d /usr/lib/grub/i386-efi -c "$W/$name.cfg" \
|
|
linux normal iso9660 search search_label search_fs_file part_msdos echo test
|
|
|
|
# xorboot may look for the loader in the ISO tree too
|
|
mkdir -p "$tree/EFI/BOOT"
|
|
# xorboot (ia32) looks for the hardcoded name "bootx64.efi" - give it the 32-bit loader
|
|
cp -f "$W/BOOTIA32.EFI" "$tree/EFI/BOOT/BOOTIA32.EFI"
|
|
cp -f "$W/BOOTIA32.EFI" "$tree/EFI/BOOT/BOOTX64.EFI"
|
|
|
|
dd if=/dev/zero of="$tree/efi.img" bs=1k count=1440 status=none
|
|
mkfs.vfat -F 12 -n EFI "$tree/efi.img" >/dev/null
|
|
mmd -i "$tree/efi.img" ::/EFI ::/EFI/BOOT
|
|
mcopy -i "$tree/efi.img" "$W/BOOTIA32.EFI" ::/EFI/BOOT/BOOTIA32.EFI
|
|
mcopy -i "$tree/efi.img" "$W/BOOTIA32.EFI" ::/EFI/BOOT/BOOTX64.EFI
|
|
|
|
# 3. final ISO: BIOS from grub-pc + our dual EFI image
|
|
xorriso -as mkisofs -o "$OUT/$name.iso" \
|
|
-b boot/grub/i386-pc/eltorito.img -no-emul-boot -boot-load-size 4 -boot-info-table \
|
|
-eltorito-alt-boot -e efi.img -no-emul-boot \
|
|
"$tree" >/tmp/xor_$name.log 2>&1
|
|
|
|
printf " -> %s.iso %s bytes\n" "$name" "$(stat -c %s "$OUT/$name.iso")"
|
|
xorriso -indev "$OUT/$name.iso" -report_el_torito plain 2>&1 | grep -E 'El Torito boot img' | sed 's/^/ /'
|
|
rm -f /tmp/e.img
|
|
xorriso -osirrox on -indev "$OUT/$name.iso" -extract /efi.img /tmp/e.img >/dev/null 2>&1
|
|
printf " efi.img: "; mdir -i /tmp/e.img ::/EFI/BOOT | grep -oE 'BOOT(IA32|X64) +EFI' | tr '\n' ' '; echo
|
|
}
|
|
|
|
build_one ADD ATI2025 dat10.dat "dat11.dat dat12.dat"
|
|
build_one ABA ADDH12 dat14.dat "dat15.dat dat16.dat"
|
|
ls -l "$OUT"
|