为什么 Windows 的镜像通常不能 dd 烧录

为什么光盘需要使用 ISO 9660 文件系统,而不使用硬盘已有的文件系统?

因为光盘只能写入一次,不能擦除,所以需要为光盘定制专用的文件系统 ISO 9660;

ISO 9660 规定,文件系统从第 16 个扇区开始,前 16 个扇区保留,通常每个扇区为 2048 字节;

系统启动方式

如果是从光驱启动:

  1. BIOS/UEFI 固件会忽略前 16 个扇区;
  2. 识别 ISO 9660 文件系统的头,找到 El Torito Boot Catalog,这里记录了引导程序所在的扇区起点、大小、程序类型;

而现代传统的光驱已经消失,取而代之的是 USB 启动,这是一个类似于硬盘的设备,通常使用传统的硬盘启动方式。

如果是通过 Legacy BIOS 启动:

  1. BIOS 固件识别 MBR 扇区的启动代码,加载 GRUB

如果是通过 UEFI 启动:

  1. UEFI 固件识别 GPT 分区表
  2. 寻找 EFI 分区,从分区中加载 GRUB

以 Ubuntu 的 ISO 为例验证 Hybrid ISO 的数据分布

Ubuntu 的 ISO 正是集成了上述三种启动方式,合成了 Hybrid ISO:

  1. 在第 1 个扇区写入 MBR 启动脚本
  2. 在第 2-64 个扇区写入 GPT 分区,并格式化一个 FAT32 格式的 EFI 分区,用于 UEFI 固件识别加载 GRUB
  3. 在第 64 个扇区开始,是一个 ISO 9660 格式的文件系统,并在元数据中记录了 El Torito:这是一个 EFI 镜像,起始扇区与大小;UEFI 固件可以通过加载这个 EFI 镜像,达到类似第 2 点的效果。

通过 fdisk 查看 Ubuntu ISO 的分区,可以看到其使用 GPT 分区别,有三个分区:

复制代码
$ fdisk ubuntu-25.04-desktop-amd64.iso
Command (m for help): p

Disk ubuntu-25.04-desktop-amd64.iso: 5.85 GiB, 6278520832 bytes, 12262736 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: D18ABFB2-FF4D-49E5-9075-9C1556AA882C

Device                             Start      End  Sectors  Size Type
ubuntu-25.04-desktop-amd64.iso1       64 12251911 12251848  5.8G Microsoft basic data
ubuntu-25.04-desktop-amd64.iso2 12251912 12262071    10160    5M EFI System
ubuntu-25.04-desktop-amd64.iso3 12262072 12262671      600  300K Microsoft basic data

解析第一个分区,是一个 ISO 9660 文件系统:

shell 复制代码
$ dd if=ubuntu-25.04-desktop-amd64.iso bs=512 skip=64 | file -
/dev/stdin: ISO 9660 CD-ROM filesystem data 'Ubuntu 25.04 amd64'

解析第二个分区,是一个 FAT32 文件系统:

shell 复制代码
$ dd if=ubuntu-25.04-desktop-amd64.iso bs=512 skip=12251912 | file -
/dev/stdin: DOS/MBR boot sector, code offset 0x3c+2, OEM-ID "mkfs.fat", sectors/cluster 4, reserved sectors 4, root entries 512, sectors 10144 (volumes <=32 MB), Media descriptor 0xf8, sectors/FAT 8, sectors/track 32, serial number 0x8f891bfd, label: "ESP        ", FAT (12 bit)

解析第二个分区,只是一个数据分区:

shell 复制代码
$ dd if=ubuntu-25.04-desktop-amd64.iso bs=512 skip=12262072 | file -
/dev/stdin: data

对于以光驱模式启动,查询 El Torito:

shell 复制代码
$ xorriso -indev ubuntu-25.04-desktop-amd64.iso
xorriso 1.5.6 : RockRidge filesystem manipulator, libburnia project.

xorriso : NOTE : Loading ISO image tree from LBA 0
xorriso : UPDATE :    1082 nodes read in 1 seconds
libisofs: NOTE : Found hidden El-Torito image for EFI.
libisofs: NOTE : EFI image start and size: 3062978 * 2048 , 10160 * 512
xorriso : NOTE : Detected El-Torito boot information which currently is set to be discarded
Drive current: -indev 'ubuntu-25.04-desktop-amd64.iso'
Media current: stdio file, overwriteable
Media status : is written , is appendable
Boot record  : El Torito , MBR protective-msdos-label grub2-mbr cyl-align-off GPT
Media summary: 1 session, 3065684 data blocks, 5988m data,  416g free
Volume id    : 'Ubuntu 25.04 amd64'

它记录有一个 EFI 镜像,位于 3062978 * 2048,大小为 10160 * 512;可以尝试提取出来:

shell 复制代码
$ dd if=ubuntu-25.04-desktop-amd64.iso of=efi.img bs=2048 skip=3062978 count=5201920
$ mkdir efi
$ sudo mount efi.img efi
$ tree efi/
efi
└── EFI
    └── boot
        ├── bootx64.efi
        ├── grubx64.efi
        └── mmx64.efi

其实这个 EFI 镜像就是 Ubuntu ISO 的第 2 个 FAT32 的 EFI 分区。

以 Windows 的 ISO 为例验证 Hybrid ISO 的数据分布

查看分区,这是一个 DOS/MBR 分区,并且没有创建分区:

shell 复制代码
$ fdisk Win11_25H2_Chinese_Simplified_x64.iso 
Command (m for help): p
Disk Win11_25H2_Chinese_Simplified_x64.iso: 7.24 GiB, 7774558208 bytes, 15184684 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: dos
Disk identifier: 0xfc048f24

查看 ISO 9660 文件系统元数据:

shell 复制代码
$ xorriso -indev Win11_25H2_Chinese_Simplified_x64.iso 
xorriso 1.5.6 : RockRidge filesystem manipulator, libburnia project.

xorriso : NOTE : Loading ISO image tree from LBA 0
xorriso : UPDATE :       1 nodes read in 1 seconds
libisofs: WARNING : Found hidden El-Torito image. Its size could not be figured out, so image modify or boot image patching may lead to bad results.
libisofs: NOTE : Found hidden El-Torito image for EFI.
libisofs: NOTE : EFI image start and size: 555 * 2048 , 1 * 512
xorriso : NOTE : Detected El-Torito boot information which currently is set to be discarded
Drive current: -indev 'Win11_25H2_Chinese_Simplified_x64.iso'
Media current: stdio file, overwriteable
Media status : is written , is appendable
Boot record  : El Torito
Media summary: 1 session, 3796171 data blocks, 7414m data,  416g free
Volume id    : 'CCCOMA_X64FRE_ZH-CN_DV9'

它记录有一个 EFI 镜像,位于 555 * 2048,大小为 1 * 512;可以尝试提取出来:

shell 复制代码
$ dd if=Win11_25H2_Chinese_Simplified_x64.iso of=efi.img bs=2048 skip=555 count=512
$ mkdir efi
$ sudo mount efi.img efi
$ tree efi
efi
└── EFI
    └── BOOT
        └── BOOTX64.EFI

由于 Windows 的 ISO 没有专门的 FAT32 分区,所以需要 UEFI 固件能支持识别 ISO 9660 的头,并根据头加载 EFI image。或者只能使用 Legacy BIOS 模式启动。所以不是 Windows ISO 不能 dd,只是 dd 后的 USB 启动盘兼容性没有 Ubuntu 那么好。

相关推荐
寒水馨13 分钟前
Windows下载、安装ollama-v0.32.1(附安装包OllamaSetup.exe)
windows·llm·大语言模型·llama·本地部署·ollama·模型运行
王维同学2 小时前
[原创][Windows C++]Explorer Shell 扩展、图标覆盖与 COM 服务器定位
c++·windows·注册表
广州灵眸科技有限公司12 小时前
xfce桌面触摸校准:基于灵眸科技EASY-EAl-Orin-Nano
数据库·windows·科技
Ctrl+Z侠17 小时前
.NET WebApi Windows / Linux Docker 全链路压测与瓶颈定位 0 到 1 教程
linux·windows·.net
王维同学18 小时前
[原创][Windows C++]LSA 认证、安全与通知包的注册表枚举
c++·windows·安全
YCOSA202519 小时前
雨晨 Windows 11 IOT 企业版 LTSC 24H2 轻装 2合1 26100.8968
windows·物联网
汤姆yu19 小时前
CodeGeeX 4完整安装与实操使用全指南
人工智能·windows·ai·智能体·视频模型
吐了啊取名字太难21 小时前
美颜系统AI修图本地跑并支持Mac、win、安卓、iOS不卡顿
android·人工智能·windows·数码相机·mac·ai编程
筱羽_筱羽1 天前
VS2022 编译SOEM
windows·visualstudio·soem
love530love1 天前
【排障实录】GPT Desktop (Codex) 开启 WSL 智能体模式后无法启动?手把手教你修复
人工智能·windows·gpt·agent