19

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.

  • 1
    Hmm, I would expect the linux one to go just as slow without a bs parameter. Do you have an alias for dd setup on linux (type alias at a prompt)? – Paul May 8 '12 at 1:30
29

For OS X, use /dev/rdisk3.

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 1M.

| improve this answer | |
  • Thank you ! I had forgotten to add bs=1m and it was slow as hell ! – LoremIpsum Oct 17 '14 at 6:35
  • 4
    The comment about the lowercase m on OS X was a lifesaver. Thank you very much! – Jonathan Komar Feb 28 '15 at 8:52
0

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 blocksize

From 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...

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.