Ubuntu 22.04 构建 ISO(MBR 和 EFI)

Ubuntu 22.04 构建 ISO(MBR 和 EFI)

在我们公司,我们使用修改后的 Ubuntu 安装 ISO 映像。由于 Ubuntu 22.04 改变了安装映像的结构(ISOLINUX 已被删除,取而代之的是 GRUB2),我需要有关如何构建新 ISO 的建议,该 ISO 可同时支持 MBR 和 EFI(在同一映像上),就像 Ubuntu 22.04 一样。

在 Ubuntu 20.04 中,我使用以下命令构建了 ISO 映像。

所以问题是:如何为 Ubuntu 22.04 构建 ISO 映像?谢谢。


使用 Ubuntu 20.04 LTS 创建 ISO 映像的命令

从图片中提取内容:
dd if="/opt/ubnt/ubuntu-20.04.4-desktop-amd64.iso" bs=1 count=432 of="/opt/ubnt/isohdpfx.bin"
xorriso -osirrox on -indev /opt/ubnt/ubuntu-20.04.4-desktop-amd64.iso -extract / /opt/ubnt/ubuntu-MODIF

... 这里有一些定制...

构建 Ubuntu 20.04 LTS
xorriso -as mkisofs -r  
  -V 'Ubuntu 20.04 LTS MODIF (EFIBIOS)' 
  -o /opt/ubnt/ubuntu-modif.iso 
  -isohybrid-mbr /opt/ubnt/isohdpfx.bin 
  -J -joliet-long -b isolinux/isolinux.bin 
  -c isolinux/boot.cat 
  -boot-load-size 4 
  -boot-info-table -no-emul-boot -eltorito-alt-boot 
  -e boot/grub/efi.img 
  -no-emul-boot 
  -isohybrid-gpt-basdat /opt/ubnt/ubuntu-MODIF

答案1

Ubuntu 22.04 构建 ISO(MBR 和 EFI)

xorriso 的最新版本(1.5.4)可以说明:


$ xorriso -indev ubuntu-22.04-desktop-amd64.iso -report_el_torito as_mkisofs
-V 'Ubuntu 22.04 LTS amd64'
--modification-date='2022041910231900'
--grub2-mbr --interval:local_fs:0s-15s:zero_mbrpt,zero_gpt:'ubuntu-22.04-desktop-amd64.iso'
--protective-msdos-label
-partition_cyl_align off
-partition_offset 16
--mbr-force-bootable
-append_partition 2 28732ac11ff8d211ba4b00a0c93ec93b --interval:local_fs:7129428d-7137923d::'ubuntu-22.04-desktop-amd64.iso'
-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_1782357s_size_8496d:all::'
-no-emul-boot
-boot-load-size 8496

旧版本猜错了。新布局让他们有些吃惊。但他们可以创建它。原始版本由 xorriso-1.5.2 制作。

显示的选项用于尽可能准确地重现 ISO。对于修改后的 ISO,可能需要省略其中一些以获取默认设置,并使用稍后不需要原始 ISO 映像的操作替换其他操作。


# Extract the MBR template for --grub2-mbr
# We only need the x86 code. All partition stuff will be newly created.
dd if=ubuntu-22.04-desktop-amd64.iso bs=1 count=432 of=/opt/ubnt/boot_hybrid.img

# The EFI partition is not a data file inside the ISO any more.
# So extract the EFI partition image image for -append_partition
# 7129428d-7137923d : 7137923 - 7129428 + 1 = 8496
dd if=ubuntu-22.04-desktop-amd64.iso bs=512 skip=7129428 count=8496 of=/opt/ubnt/efi.img

# Extract file tree as usual ...

# Finally pack up an ISO the new way
xorriso -as mkisofs -r \
  -V 'Ubuntu 22.04 LTS MODIF (EFIBIOS)' \
  -o /opt/ubnt/ubuntu-modif.iso \
  --grub2-mbr /opt/ubnt/boot_hybrid.img \
  -partition_offset 16 \
  --mbr-force-bootable \
  -append_partition 2 28732ac11ff8d211ba4b00a0c93ec93b /opt/ubnt/efi.img \
  -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:::' \
    -no-emul-boot \
  /opt/ubnt/ubuntu-MODIF

其优点是 USB 上的 ISO 将被识别为 GPT 分区,且分区整齐。


$ /sbin/fdisk -l ubuntu-22.04-desktop-amd64.iso

Disk ubuntu-22.04-desktop-amd64.iso: 3.4 GiB, 3654957056 bytes, 7138588 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: A09DB2B8-B5F6-43AE-AFB3-91E0A90189A1

Device                            Start     End Sectors  Size Type
ubuntu-22.04-desktop-amd64.iso1      64 7129427 7129364  3.4G Microsoft basic da
ubuntu-22.04-desktop-amd64.iso2 7129428 7137923    8496  4.2M EFI System
ubuntu-22.04-desktop-amd64.iso3 7137924 7138523     600  300K Microsoft basic da

(分区 3 覆盖了 300 KiB 的传统末端填充,实际上只有在以 Track-At-Once 写入类型写入的 CD 介质上才需要。选项 -no-pad 可以阻止它。)

相关内容