How to Image a Hard Drive or SD Card from Mac Terminal

Cloning an IMG

Identify the volume to clone to.

diskutil list  

This is what diskutil list returns with no external volumes. Yours could be different but is probably similar. Don't use these or you could accidentally do some damage.

Example Terminal output of diskutil list with no external volumes

After inserting a micro SD card.

Example Terminal output of diskutil list with external volumes

I'm choosing /dev/disk2 as the volume to image.

Unmount the volume

diskutil unmount /dev/disk2  
# or
diskutier unmountDisk /dev/disk2  

Brief Info on dd Command

The dd utility copies the standard input to the standard output. Input data is read and written in 512-byte blocks. If input reads are short, input from multiple reads are aggregated to form the output block. When finished, dd displays the number of complete and partial input and output blocks and truncated input records to the standard error output.

if=/PATH/FROM : Input File or the file you want to copy to.

of=/PATH/TO : Output File or where to image the file to.

bs=1M : Block Size This all kind of depends on what the volume is and how fast read and write can happen. Usually this is safe. It's just saying write 1 MB at a time pause for data write then do another MB.

Begin the clone using dd command.

sudo dd of=~/Downloads/2015-05-05-raspbian-wheezy.img if=/dev/disk2 bs=1m  

Another example when I made an image of CentOS 7 to a SSD.

diskutil list  
diskutil unmount /dev/disk3  
cd ~/Downloads  
sudo dd if=CentOS-7-x86_64-Everything-1503-01.iso of=/dev/disk3 bs=1m