Micro SD Card Imaging

I’ve been cloning micro SD cards to create backups and writing images to them during setup of Raspberry Pis a lot lately. My tool of choice has been the command line tool dd on the Mac (man page). Every tutorial referencing imaging for Raspberry Pis I’ve seen tells you to clone a drive with:

sudo dd if=/dev/disk2 of=~/Downloads/filename.img

Write an image to a drive with:

sudo dd if=~/Downloads/filename.img of=/dev/disk2

Those commands work, but are painfully slow. After firing off an image process, I came back over 3.5 hours later and it wasn’t finished! The write speed was about 0.25 MB/second.

I found a thread on the Raspberry Pi Forums discussing this. While none of the suggestions worked exactly for me, they did lead me to the solution. Here is what worked to clone a drive:

sudo dd bs=1m if=/dev/rdisk2 of=~/Downloads/filename.img

And then the opposite to write an image back to a drive:

sudo dd bs=1m if=~/Downloads/filename.img of=/dev/rdisk2

Now I got about 10 MB/second writing that image to disk and it completed in less than 7 minutes! The read speeds I’m getting are over 15 MB/second when cloning a disk. For specifics read why /dev/rdisk is so much faster than /dev/disk.

** Note: all of my examples use disk2 because that’s what I usually get on my machine. Your setup may vary. Run diskutil list to see a list of your drives and determine the correct number. You do still need to diskutil unmountDisk /dev/disk like the other tutorials mention.

I’ve actually stopped directly using dd since I started writing this post. Now I’m using ApplePi Baker, an app built on top of dd with a simple to use GUI.

I have experienced an issue using different brands of micro SD cards. Even though a couple were both 16 GB, they were slightly different sizes. Write an image file too large to a disk and no boot for you. I found rpi-clone to handle this. The next time I’m not using a headless Raspbian-lite I’ll try the built-in SD card copier, which ships with the OS.

Another app, PiBakery, looks like a neat way to automate and customize image creation, but I haven’t tried it yet.

2 thoughts on “Micro SD Card Imaging

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s