为什么 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 那么好。

相关推荐
雨中风华5 小时前
Linux, macOS系统实现远程目录访问(等同于windows平台xFsRedir软件的目录重定向)
linux·windows·macos
yuuki2332337 小时前
【C++】继承
开发语言·c++·windows
非凡ghost7 小时前
PowerDirector安卓版(威力导演安卓版)
android·windows·学习·软件需求
疯狂敲代码的老刘9 小时前
JDK 1.6到25 全版本网盘合集 (Windows + Mac + Linux)
java·linux·windows·macos·jdk
love530love10 小时前
Windows 下 GCC 编译器安装与排错实录
人工智能·windows·python·gcc·msys2·gtk·msys2 mingw 64
猫头虎11 小时前
OpenClaw开源汉化发行版:介绍、下载、安装、配置教程
运维·windows·开源·aigc·ai编程·agi·csdn
luffy545911 小时前
windows下通过docker-desktop创建redis实例
windows·redis·docker·容器
程序员敲代码吗11 小时前
Windows组策略限制规避指南:深入解析与实际操作
windows
黄大帅@lz12 小时前
openai提示词学习
windows·学习
MyY_DO12 小时前
十四课 易语言核心逆向
windows·od