Skip to content →

Solution: dd too slow on Mac OS X

When I was cloning SD cards on Mac OS X using dd', it takes ages to get things done. I was using the following command:

It takes much less time when using /dev/rdisk2 instead of /dev/disk2:

The reason is that rdisks are "raw" thus resulting in a higher R/W speed, according to man hdiutil` [1]:

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

[1] http://superuser.com/questions/631592/mac-osx-why-is-dev-rdisk-20-times-faster-than-dev-disk

Published in OS

58 Comments

  1. Greg Spenipp

    Incredible! Been banging my head on this for a couple hours now, thanks a bunch!

  2. Darkcaster

    Nice … always a good thing to know 😉 … and a lot of comments helps more =)

     

    Thx you all !

  3. Tim

    I’m dying from the slowness as well, but using the r trick isn’t working for me. I get the following error:

    dd: /dev/rdisk4: Invalid argument

    Any idea how to fix that?

  4. Mario

    Instead of pv or any other commands you could simply use ‘CTRL + T’ to get the bytes progress.

  5. Mikhail

    Thanks a lot!

    Another tip for OSX (High Sierra) to check status during the process (pv not installed).

    In another Terminal window:

    sudo kill -INFO $(pgrep ^dd)

     

  6. thank you

    818+0 records in
    818+0 records out
    857735168 bytes transferred in 75.526248 secs (11356782 bytes/sec)

     

  7. Dixon Dick

    Thank you! Four years later, still a useful tip.

  8. Thanks for the tune-up! Much appreciated advice. 20x increase in performance. By prepending an ‘r’. Who knew…

  9. bail(){
    echo “Usage: $0 source destination”
    exit 1
    }

    nofile(){
    echo “Usage: $0 source destination – path invalid”
    exit 1
    }

    [[ -z “$1” || -z “$2” ]] && bail
    [[ ! -e “$1” || ! -e “$2” ]] && nofile

    read -p “Are you sure? Y/[N] ” -n 1 -r
    echo # (optional) move to a new line
    [[ ! $REPLY =~ ^[Yy]$ ]] && exit 1

    BLKSZ=1048576
    FSZE=$(stat -f “%z” $1)
    su root -c “dd bs=$BLKSZ if=$1 | pv -s $FSZE | sudo dd of=$2 bs=$BLKSZ”

  10. Apple:~ apple$ sudo dd if=/Users/apple/Desktop/2017-07-05-raspbian-jessie-lite.img of=/dev/rdisk1 bs=1048576
    Password:
    load: 0.59 cmd: dd 1621 uninterruptible 0.00u 0.92s
    1130+0 records in
    1129+0 records out
    1183842304 bytes transferred in 2143.597669 secs (552269 bytes/sec)

    size of jessie -> 1,72,56,29,563 bytes (1.73 GB on disk)

  11. Wow. That one character makes a HUGE difference. My DD job went from 3 hours to 5 minutes. Thank you!

  12. Salvatore Restuccia

    Amazing!! 84MB/S Thank you!!!!!

     

  13. Anonymous

    Thank you very much, it works like a charm!

  14. Ken H.

    Nm, I just found out what I did wrong.  I realized that my sd card changed to disk6 instead of disk5.  Doh

  15. Ken H.

    Sorry for the newbie question, but I keep getting a “dd: /dev/rdisk5: Operation not permitted”  when I enter “sudo dd bs=1m if=/Users/me/Desktop/file.img of=/dev/rdisk5”  Not sure what I’m doing wrong.

  16. Rainer S.

    Bonus: for those who use pv for getting a progress meter:
    Use dd from gnu coreutils (both macports and homebrew should have it) and then append

    to your command.

  17. Jon

    Holy Crap!

    Sustained io writes @ 7mb/s!!

    Thank you!!!

  18. darkfader

    Same for databases (like 50%+ faster running off raw devices) but rarely used there because there’s too high chance junior sysadmins / devs will confuse your database storage for empty disks 🙁

  19. John Doe

    Damn I read this too late, now I won’t kill the process because the whole image is “only” 3,3 GB:

    sudo killall -INFO dd

    2459+0 records in
    2458+0 records out
    2577399808 bytes transferred in 5596.141697 secs (460567 bytes/sec)

     

  20. Shane

    AWESOME! You just made my day with this.

  21. jdoubleu

    Thanks a lot !!
    Here with pv command to see the copy progress ?
    dd bs=1m if=~/Downloads/20131009.alice.img | pv | sudo dd bs=1m of=/dev/rdisk2

    I’d use:
    sudo -s — “dd bs=1m if=imagefile.img | pv | dd bs=1m of=/dev/rdisk2”
    Because you have to run dd with root privileges.

  22. Mark

    WOW, this made all the difference it the world!! add the pv command (not needed as much now due to how fast it is) and I can get back to work.

  23. Anonymous

    Amazing.. I was spending hours and it was killing me

  24. Anonymous

    Thanks a lot !!
    Here with pv command to see the copy progress 😉
    dd bs=1m if=~/Downloads/20131009.alice.img | pv | sudo dd bs=1m of=/dev/rdisk2

  25. Anonymous

    Thanks a lot man!!! You saved my life!!!!

    I have a fast external disk that I want to backup to the local MAC disk and an USB 3.0 SATA adapter and got only 30 Mbytes/s.

    Now is 300Mbytes/s!!!!!

     

    Thanks!!!!

    Thanks!!!!

    Thanks!!!

  26. Christophe Nouvel

    So I can keep my Mac and don’t throw it away! Thanks a LOT, x16 speed on a USB stick!

     

  27. Jeffrey

    Thank you very mutch saved me mutch time 🙂

  28. Paul

    You Sir, just made my day. This clever trick just speed up dd from 1MB/s to almost 7MB/s

  29. Stuart

    I think I love you. Thank you so much for this!

  30. fred

    Thnx !!

    After more then 10 hours writing to a sd cancelled it,

    Now done in a couple of minutes

  31. Joern

    3284139520 bytes transferred in 19705.137328 secs (166664 bytes/sec)

    vs

    3284139520 bytes transferred in 255.784407 secs (12839483 bytes/sec)

     

    Thanx! 🙂

  32. Gonzo Fialho

    Wow, that improved my life 100%
    Thanks for sharing

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.