When using Linux (Debian), I often use dd to copy a disk image to an SD card. I have written a script that throws an error if the device file specified in the of option is too large. This keeps me from accidentally blowing away one of my hard disks.SD_SIZE=$(sudo sfdisk -s ${SD_DEV}) if [ $SD_SIZE -gt 33554432 ]; then  echo might not be and SD card, exiting  exit 1fiHowever, if I insert the SD card and forget to unmount it, results are sketchy. Sometimes the copy succeeds and sometimes it fails.I can amend my script with the answer here:How to check if a filesystem is mounted with a scriptHowever, is there an option in dd with this functionality? (on OS X dd will not write to a mounted disk by default)Also of interest, why will dd (on OS X) error when trying to copy to a mounted disk? Perhaps some differences in the kernel or dd? Here is the error you get if you try to dd to a drive that is mounted in OS X (10.9):dd: /dev/diskN: Resource busy, make sure the disk is not in useI can write to the disk using cp, so perhaps the system calls that dd is making are not as simple as OPEN then WRITE.
Differences between dd in Mac OS X and Linux
linux;mount;osx;dd;sd card
Sometimes the copy succeeds and sometimes it fails.Probably it fail because some process in the while wrote to the mounted filesystem, guess that's why is a good practice to umount before :-)dd should really be just open and write, I guess the MacOSX version add some control and I think is easy to understand why with their device names, compared to Linux I triple-check before dd'ing.