Mac OS X与Linux上的dd性能


18

我试图将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
嗯,我希望linux在没有bs参数的情况下也一样慢。您dd在Linux上是否有用于安装的别名(alias在提示符下键入)?
保罗

Answers:


28

对于OS X,请使用/dev/rdisk3

由于某种原因rdisk比更快disk。我相信这与缓冲区有关。

通常,还可以将bs标志dd与速度一起使用。

dd if=/path/to/image.iso of=/dev/sdc bs=1M

字节大小为1M,传输速度更快。在OS X上,您必须使用1m(小写)而不是1M


谢谢 !我忘记添加了bs=1m,它慢得要命!
LoremIpsum 2014年

4
关于OS X上小写字母m的评论是救生员。非常感谢你!
Jonathan Komar

0

BSD原始磁盘

BSD通常具有2种磁盘设备类型:bufferend和unbuffered(原始)。从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字节...

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.