AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题 / 1146304
Accepted
Michael Prescott
Michael Prescott
Asked: 2023-10-21 22:56:20 +0800 CST2023-10-21 22:56:20 +0800 CST 2023-10-21 22:56:20 +0800 CST

如何重新制作 Ubuntu Live ISO 以修改 grub.cfg 以从本地 cloud-init 用户数据自动安装

  • 772

我正在使用 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 有效:

  1. 提取原始 ISO
  2. 创建用户数据和元数据文件
  3. 修改 grub.cfg 以添加自动安装菜单项
  4. 使用以下内容重新打包 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 中?只是在挖掘更多信息时推测我不太熟悉的事情。

感谢 Thomas Shchmitt 的帮助解决了问题。接下来的步骤是将 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
ubuntu
  • 1 1 个回答
  • 91 Views

1 个回答

  • Voted
  1. Best Answer
    Thomas Schmitt
    2023-10-22T02:21:23+08:002023-10-22T02:21:23+08:00

    感谢您搭乘 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。

    • 1

相关问题

  • 无法通过 Ubuntu VPN 访问外部网络

  • ubuntu apt-get upgrade - 如何在 shell 中单击确定?

  • VirtualBox 上 Ubuntu 的访客优化技巧 [关闭]

  • 外部硬盘上的 virtualbox 虚拟硬盘驱动器(Vista 主机上的 ubuntu 客户机)

  • 如何在 Ubuntu 上挂载 LVM 分区?

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve