我从上网本中取出一个 250 GB SATA 磁盘,用 dd 填充零,然后通过 USB 适配器将其连接到我的笔记本电脑。它被 fdisk 正确检测到:
Disk /dev/sdb: 250.1 GB, 250059350016 bytes
255 heads, 63 sectors/track, 30401 cylinders, total 488397168 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
Disk identifier: 0x475fa272
Device Boot Start End Blocks Id System
Run Code Online (Sandbox Code Playgroud)
我创建了一个主分区并使用以下命令创建了一个 ext4 文件系统:
mkfs.ext4 /dev/sdb1
Run Code Online (Sandbox Code Playgroud)
现在 fidsk 显示:
Disk /dev/sdb: 250.1 GB, 250059350016 bytes
81 heads, 63 sectors/track, 95707 cylinders, total 488397168 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
Disk identifier: 0x475fa272
Device Boot Start End Blocks Id System
/dev/sdb1 2048 488397167 244197560 83 Linux
Run Code Online (Sandbox Code Playgroud)
好的,到目前为止并不奇怪。接下来,我想使用以下命令提取 Ubuntu ISO 映像:
dd if=~/ubuntu-12.10-desktop-i386.iso of=/dev/sdb
Run Code Online (Sandbox Code Playgroud)
令我惊讶的是,文件系统更改为“隐藏的 HPFS/NTFS”:
Disk /dev/sdb: 250.1 GB, 250059350016 bytes
19 heads, 24 sectors/track, 1071046 cylinders, total 488397168 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
Disk identifier: 0x475fa272
Device Boot Start End Blocks Id System
/dev/sdb1 * 64 1542743 771340 17 Hidden HPFS/NTFS
Run Code Online (Sandbox Code Playgroud)
使用 dd 将 ISO 映像提取到外部驱动器并保留当前文件系统的正确方法是什么?
您写入磁盘 ( /dev/sdb),而不是写入您创建的文件系统 ( /dev/sdb1)。
由于 ISO 映像已经包含一个文件系统(您不需要),您可以简单地挂载 ISO(使用选项-o loop)并将数据复制到/dev/sdb1. 这样就保留了文件系统。