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:
diskutil unmountDisk /dev/disk2 sudo dd bs=1m if=~/Downloads/2013-10-09.alice.img of=/dev/disk2
It takes much less time when using /dev/rdisk2 instead of /dev/disk2:
diskutil unmountDisk /dev/disk2 sudo dd bs=1m if=~/Downloads/2013-10-09.alice.img of=/dev/rdisk2
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
Incredible! Been banging my head on this for a couple hours now, thanks a bunch!
Nice … always a good thing to know 😉 … and a lot of comments helps more =)
Thx you all !
Life saver!
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?
Instead of pv or any other commands you could simply use ‘CTRL + T’ to get the bytes progress.
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)
818+0 records in
818+0 records out
857735168 bytes transferred in 75.526248 secs (11356782 bytes/sec)
legendary pro tip, much appreciated
Thank you! Four years later, still a useful tip.
Thanks for the tune-up! Much appreciated advice. 20x increase in performance. By prepending an ‘r’. Who knew…
3299514 bytes/sec
vs
15451963 bytes/sec
Thanks a lot! 🙂
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”
[…] Solution: dd too slow on Mac OS X […]
[…] I got bored of the slowness of the process and I cancel it after a while and try to implement this suggestion about raw volumes. So the code would be like this […]
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)
Big hug !
[…] http://daoyuan.li/solution-dd-too-slow-on-mac-os-x/ […]
Thank you!
Wow. That one character makes a HUGE difference. My DD job went from 3 hours to 5 minutes. Thank you!
[…] http://daoyuan.li/solution-dd-too-slow-on-mac-os-x/ /dev/rdisk nodes are character-special devices, but are “raw” in the BSD sense and force […]
[…] 注意到当在 Mac 上操作 dd,使用 /dev/rYOUR_DEVICE 会更明智。使用 /dev/YOUR_DEVICE 的速度很慢,详细解释见这里。 […]
Amazing!! 84MB/S Thank you!!!!!
Thank you very much, it works like a charm!
Nm, I just found out what I did wrong. I realized that my sd card changed to disk6 instead of disk5. Doh
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.
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.
Wohoo!! 45MB/s!!! Thanks!
Whoa! From 0.3 to over 7 Mb/s 😮
Soooo much better – thanks!
谢谢分享!
Holy Crap!
Sustained io writes @ 7mb/s!!
Thank you!!!
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 🙁
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)
[…] Note when using dd on the Mac its advisable to use /dev/rYOUR_DEVICE. Using /dev/YOUR_DEVICE can be painfully slow, as explained here. […]
AWESOME! You just made my day with this.
Xie xie hen hao!!
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.
What a great Tip
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.
Amazing.. I was spending hours and it was killing me
Thanks a lot !!
Here with pv command to see the copy progress 😉
dd bs=1m if=~/Downloads/2013–10–09.alice.img | pv | sudo dd bs=1m of=/dev/rdisk2
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!!!
So I can keep my Mac and don’t throw it away! Thanks a LOT, x16 speed on a USB stick!
This is huge! Thanks!
thanks
Thanks man. You prolonged my life 😉
Thank you very mutch saved me mutch time 🙂
You Sir, just made my day. This clever trick just speed up dd from 1MB/s to almost 7MB/s
I have been looking for a way to do this for ages 😀
I think I love you. Thank you so much for this!
Great tip. Thanks. Amazing speed increase.
Thnx !!
After more then 10 hours writing to a sd cancelled it,
Now done in a couple of minutes
Thank you! 🙂
[…] Solution: dd too slow on Mac OS X […]
Wow, that improved my life 100%
Thanks for sharing
[…] Following the instructions here: DD too slow on mac […]
[…] vía Solution: dd too slow on Mac OS X – Daoyuan Li. […]