大网数据广告活动
服务器运维问答

How to remaster an Ubuntu Live ISO to revise grub.cfg to autoinstall from local cloud-init user-data

· 52CE 我爱测

I'm working on Intel and M1 Mac's and running Ubuntu Server in VMWare Fusion VMs. I'm currently using the latest ubuntu-23.10-live-server-amd64.iso and ubuntu-23.10-live-server-arm64.iso. I can get everything to work as needed fo…

问题原文

原帖链接 · Michael Prescott · CC BY-SA 4.0

I'm working on Intel and M1 Mac's and running Ubuntu Server in VMWare Fusion VMs. I'm currently using the latest ubuntu-23.10-live-server-amd64.iso and ubuntu-23.10-live-server-arm64.iso. I can get everything to work as needed for Intel-based systems, but when using the arm64.iso, it doesn't contain a /boot.catalog and /boot/grub/i386-pc/eltorito.img. So, I'm unable to recreate a bootable ISO after my revisions to the grub.cfg.

I've pieced together bits of information from various sources, starting here: https://ubuntu.com/server/docs/install/autoinstall-quickstart, but haven't found or understood enough to fill in this last piece of the puzzle for my arm64 platform. Also, I was unable to use livefs-edit because it depends on 'losetup', which isn't available on macOS; however, xorriso solved the problem 100% on Intel and I imagine... mostly solves it on the M1s if I can solve the boot image issue.

For amd64.iso's this works:

  1. Extract the original ISO
  2. Create user-data and meta-data files
  3. Revise the grub.cfg to add an autoinstall menuitem
  4. Repackage the ISO with the following:
    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}

Update Using Thomas Schmitt's advice, I queried for the proposal and revised to use:

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/

The result was:

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.

The only difference I can see upon inspecting the extracted ISOs of both the original, which is bootable, and the new, which is not:

And attempting to boot results in this:

I've also tried:

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/

I'm pulling my hair out and grasping at straws. Much of this I don't fully understand, but I can see that the -c placed the boot catalog. So, to get the new ISO closer to the original, I used `c '/boot.catalog', which now gets me to one difference in an original file, that looks like this:

I suspect there is something NOT visible to me, perhaps in the actual MBR? Just speculating about things I'm not very familiar with while digging for more information.

Solved thanks to Thomas Shchmitt's help. Next steps would be to replace the ORIGINAL_EXTRACTED_ISO_DIR with a revised target, new cloud-init user-data, grub.cfg, etc.

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

已采纳解答

原帖链接 · Thomas Schmitt · CC BY-SA 4.0

thank you for flying xorriso. :)

/boot/grub/i386-pc/eltorito.img is for x86 legacy PC-BIOS. There is no use for it in an ISO for arm64. The same is true for the GRUB2 MBR. The EFI stuff is quite similar for all three architectures.

Asking xorriso for a proposal to recreate the boot equipment of the original 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

Option -G is not really necessary in this case. It is proposed because there is a partition table. Its effect is overridden by the creation of the new partition bable. Option -boot-load-size should be omitted if there is any risk that the size of the EFI partition has changed.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2023-10-21)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。