I was trying to copy an iso of the windows installer onto a hard drive to avoid burning a disk. I first tried Disk Utility’s restore function, however it didn’t like the ISO for some reason. Then I tried using dd:
dd if=/path/to/image.iso of=/dev/disk3
I realized it was copying the file at a snail’s pace, about 160 KB/sec. I rebooted into my linux installation and ran the command again, almost verbatim:
dd if=/path/to/image.iso of=/dev/sdc
This time the command executed in under a minute, with an average speed of 57 MB/sec. In both cases the source and destination were the same physical hard drives. What’s going on?
I am running OSX 10.7.3 and Linux 2.6.38-13.
For OS X, use
For some reason
rdisk is faster than
disk. I believe it has to do with buffers.
Also in general using the
bs flag with
dd helps with speed.
dd if=/path/to/image.iso of=/dev/sdc bs=1M
The bytesize is 1M which transfers faster. On OS X you have to use
1m (lowercase) instead of
BSD raw disks
BSDs in general have 2 disk device types: bufferend and unbuffered (raw). From the
hdutil(1) man page:
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, ...
Because of the 2nd paragraph, the disk must unmounted to be able to use
dd on it in “raw mode”.
dd(1) man page:
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.
The default blocksize is 512 bytes…