我试图将 Windows 安装程序的 ISO 复制到硬盘上,以避免刻录磁盘。我首先尝试了磁盘实用程序的恢复功能,但是由于某种原因它不喜欢 ISO。然后我尝试使用 dd:
dd if=/path/to/image.iso of=/dev/disk3
我意识到它复制文件的速度非常慢,大约 160 KB/秒。我重新启动进入 Linux 安装并再次运行该命令,几乎一字不差:
dd if=/path/to/image.iso of=/dev/sdc
这次命令执行时间不到一分钟,平均速度为 57 MB/秒。在这两种情况下,源和目标都是相同的物理硬盘。发生了什么?
我正在运行 OSX 10.7.3 和 Linux 2.6.38-13。
答案1
对于 OS X,使用/dev/rdisk3
。
由于某种原因,rdisk
比 更快disk
。我相信这与缓冲区有关。
另外一般来说,使用bs
标志有助于dd
提高速度。
dd if=/path/to/image.iso of=/dev/sdc bs=1M
字节大小为 1M,传输速度更快。在 OS X 上,您必须使用1m
(小写) 而不是1M
。
答案2
BSD 原始磁盘
BSD 通常有 2 种磁盘设备类型:缓冲和非缓冲(原始)。hdutil(1)
手册页中写道:
DEVICE SPECIAL FILES
Since any /dev entry can be treated as a raw disk image, it is worth
noting which devices can be accessed when and how. /dev/rdisk nodes
are character-special devices, but are "raw" in the BSD sense and
force block-aligned I/O. They are closer to the physical disk than
the buffer cache. /dev/disk nodes, on the other hand, are buffered
block-special devices and are used primarily by the kernel's
filesystem code.
It is not possible to read from a /dev/disk node while a filesystem
is mounted from it, ...
由于第二段,磁盘必须卸载能够dd
在“原始模式”下使用它。
dd 块大小
来自dd(1)
手册页:
Where sizes are specified, a decimal, octal, or hexadecimal number of bytes
is expected. If the number ends with a ``b'', ``k'', ``m'', ``g'', or ``w'',
the number is multiplied by 512, 1024 (1K), 1048576 (1M), 1073741824 (1G) or
the number of bytes in an integer, respectively. Two or more numbers may be
separated by an ``x'' to indicate a product.
默认块大小为 512 字节...