
我正在使用 Intel 和 M1 Mac,並在 VMWare Fusion VM 中運行 Ubuntu Server。我目前正在使用最新的 ubuntu-23.10-live-server-amd64.iso 和 ubuntu-23.10-live-server-arm64.iso。我可以讓一切按照基於 Intel 的系統的需求工作,但是當使用 arm64.iso 時,它不包含/boot.catalog
和/boot/grub/i386-pc/eltorito.img
。因此,在修改 grub.cfg 後,我無法重新建立可引導 ISO。
我從各種來源拼湊了一些信息,從這裡開始:https://ubuntu.com/server/docs/install/autoinstall-quickstart,但還沒有找到或理解足夠的內容來填補我的 arm64 平台的最後一塊拼圖。另外,我無法使用 livefs-edit,因為它依賴 'losetup',而 macOS 上不提供該功能;然而,xorriso 在 Intel 上 100% 解決了這個問題,我想…如果我能解決啟動映像問題,那麼在 M1 上基本上可以解決這個問題。
對於 amd64.iso 有效:
- 提取原始 ISO
- 建立用戶資料和元資料文件
- 修改 grub.cfg 以新增自動安裝選單項
- 使用以下內容重新打包 ISO:
xorriso -as mkisofs \
--modification-date='2021101314195100' \
--grub2-mbr \
--interval:local_fs:0s-15s:zero_mbrpt,zero_gpt:"${ORIGINAL_ISO_PATH}" \
--protective-msdos-label \
-partition_cyl_align off \
-partition_offset 16 \
--mbr-force-bootable \
-append_partition 2 28732ac11ff8d211ba4b00a0c93ec93b \
--interval:local_fs:2470124d-2478587d::"${ORIGINAL_ISO_PATH}" \
-part_like_isohybrid \
-iso_mbr_part_type a2a0d0ebe5b9334487c068b6b72699c7 \
-c '/boot.catalog' \
-b '/boot/grub/i386-pc/eltorito.img' \
-no-emul-boot \
-boot-load-size 4 \
-boot-info-table \
--grub2-boot-info \
-eltorito-alt-boot -e \
'--interval:appended_partition_2_start_617531s_size_8464d:all::' \
-no-emul-boot \
-boot-load-size 8464 \
-isohybrid-gpt-basdat \
-o ubuntu-autoinstall.iso \
-V 'Ubuntu autoinstall' ${EXTRACTED_ISO_PATH}
更新 根據托馬斯·施密特的建議,我查詢了該提案並修改為使用:
xorriso -as mkisofs \
--modification-date='2023101104561500' \
-partition_cyl_align off \
-partition_offset 16 \
-append_partition 2 0xef --interval:local_fs:4615776d-4629311d::"${ORIGINAL_ISO_PATH}" \
-G --interval:local_fs:0s-15s:zero_mbrpt:"${ORIGINAL_ISO_PATH}" \
-iso_mbr_part_type 0xcd \
-c '/boot/boot.cat' \
-e '--interval:appended_partition_2_start_1153944s_size_13536d:all::' \
-no-emul-boot \
-boot-load-size 13536 \
-output ubuntu-autoinstall.iso \
extracted-iso/
結果是:
GNU xorriso 1.5.6 : RockRidge filesystem manipulator, libburnia project.
Drive current: -outdev 'stdio:ubuntu-autoinstall.iso'
Media current: stdio file, overwriteable
Media status : is blank
Media summary: 0 sessions, 0 data blocks, 0 data, 1415g free
Added to ISO image: directory '/'='/extracted-iso'
xorriso : UPDATE : 980 files added in 1 seconds
xorriso : UPDATE : 980 files added in 1 seconds
xorriso : NOTE : Copying to System Area: 32768 bytes from file '--interval:local_fs:0s-15s:zero_mbrpt:ubuntu-23.10-live-server-amd64.iso'
libisofs: NOTE : Automatically adjusted MBR geometry to 1020/159/32
xorriso : UPDATE : 3.18% done
xorriso : UPDATE : 54.15% done
xorriso : UPDATE : 87.88% done
ISO image produced: 1300424 sectors
Written to medium : 1300424 sectors at LBA 0
Writing to 'stdio:ubuntu-autoinstall.iso' completed successfully.
在檢查可啟動的原始 ISO 和不可啟動的新 ISO 時,我發現的唯一差異是:
我也嘗試過:
xorriso -as mkisofs \
--modification-date='2023101104561500' \
-partition_cyl_align off \
-partition_offset 16 \
-append_partition 2 0xef --interval:local_fs:4615776d-4629311d::"${ORIGINAL_ISO_PATH}" \
-iso_mbr_part_type 0xcd \
-c '/boot/boot.cat' \
-e '--interval:appended_partition_2_start_1153944s_size_13536d:all::' \
-no-emul-boot \
-output ubuntu-autoinstall.iso \
extracted-iso/
我拉著頭髮,抓住吸管。其中大部分內容我並不完全理解,但我可以看到放置-c
了啟動目錄。因此,為了使新 ISO 更接近原始 ISO,我使用了“c '/boot.catalog”,這讓我發現了原始文件中的一個差異,如下所示:
我懷疑有一些東西對我來說是看不見的,也許在實際的 MBR 中?只是在挖掘更多資訊時推測我不太熟悉的事情。
解決了感謝托馬斯·施密特的幫助。接下來的步驟是將 ORIGINAL_EXTRACTED_ISO_DIR 替換為修訂後的目標、新的 cloud-init 使用者資料、grub.cfg 等。
case "$ARCHITECTURE" in
"m1")
echo "Running on M1 Mac."
xorriso -as mkisofs \
--modification-date='2023081005071100' \
-partition_cyl_align off \
-partition_offset 16 \
-append_partition 2 0xef --interval:local_fs:4030464d-4042271d::"${ORIGINAL_ISO_FILE}" \
-G --interval:local_fs:0s-15s:zero_mbrpt:"${ORIGINAL_ISO_FILE}" \
-iso_mbr_part_type 0xcd \
-c '/boot/boot.cat' \
-e '--interval:appended_partition_2_start_1007616s_size_11808d:all::' \
-no-emul-boot \
-boot-load-size 11808 \
-output ${AUTOINSTALL_ISO_FILE} \
${ORIGINAL_EXTRACTED_ISO_DIR}/
;;
"intel")
echo "Running on Intel Mac."
xorriso -as mkisofs \
--modification-date='2023081005062500' \
--grub2-mbr --interval:local_fs:0s-15s:zero_mbrpt,zero_gpt:"${ORIGINAL_ISO_FILE}" \
--protective-msdos-label \
-partition_cyl_align off \
-partition_offset 16 \
--mbr-force-bootable \
-append_partition 2 28732ac11ff8d211ba4b00a0c93ec93b --interval:local_fs:4156048d-4166115d::"${ORIGINAL_ISO_FILE}" \
-appended_part_as_gpt \
-iso_mbr_part_type a2a0d0ebe5b9334487c068b6b72699c7 \
-c '/boot.catalog' \
-b '/boot/grub/i386-pc/eltorito.img' \
-no-emul-boot \
-boot-load-size 4 \
-boot-info-table \
--grub2-boot-info \
-eltorito-alt-boot \
-e '--interval:appended_partition_2_start_1039012s_size_10068d:all::' \
-no-emul-boot \
-boot-load-size 10068 \
-output ${AUTOINSTALL_ISO_FILE} \
${ORIGINAL_EXTRACTED_ISO_DIR}/
;;
*)
echo "Unsupported architecture: $ARCHITECTURE"
exit 1
;;
esac
答案1
感謝您搭乘 xorriso 航班。 :)
/boot/grub/i386-pc/eltorito.img 適用於 x86 舊版 PC-BIOS。它在arm64 的ISO 中沒有用。 GRUB2 MBR 也是如此。所有三種架構的 EFI 內容都非常相似。
向 xorriso 詢問重新建立原始 ISO 引導裝置的建議:
$ xorriso -indev ubuntu-23.10-live-server-arm64.iso -report_el_torito as_mkisofs
...
-V 'Ubuntu-Server 23.10 arm64'
--modification-date='2023101104561500'
-partition_cyl_align off
-partition_offset 16
-append_partition 2 0xef --interval:local_fs:4615776d-4629311d::'ubuntu-23.10-live-server-arm64.iso'
-G --interval:local_fs:0s-15s:zero_mbrpt:'ubuntu-23.10-live-server-arm64.iso'
-iso_mbr_part_type 0xcd
-c '/boot/boot.cat'
-e '--interval:appended_partition_2_start_1153944s_size_13536d:all::'
-no-emul-boot
-boot-load-size 13536
在這種情況下,選項 -G 並不是真正必要的。之所以提出是因為有分區表。它的效果會被新分區表的建立所覆蓋。如果存在 EFI 分割區大小發生變更的風險,則應省略選項 -boot-load-size。