Archive: Backing up Raspberry Pi SD img using Mac Terminal

Posted By on January 5, 2016

After tweaking the 64GB micro SD card to get a few things set up on the Raspberry Pi,microsdcard it sounded like a good idea to backup an image. The best option sounds like using the Terminal and command line instructions … but be aware, even with rdisk, it take a while.

An example from raspberrypi.stackexchange.com below:

On the Mac you don’t want to be using /dev/diskn. You should use /dev/rdiskn instead, where n is the number the OS uses to identify your SD card. This decreases the time required to copy by a huge amount.

So for the optimal backup process on a Mac, I would recommend doing the following:

Run diskutil list, and find the disk corresponding to your Raspberry Pi’s SD card:

examplelist

Clearly /dev/disk1 is my 8GB SD card, the Linux partition name is also a bit of a clue.

However, instead of using /dev/disk1 with dd, you should use /dev/rdisk1, like so:

sudo dd if=/dev/rdisk1 of=/path/to/backup.img bs=1m

And to restore it, just swap the if (input file), and of (output file) parameters:

sudo dd if=/path/to/backup.img of=/dev/rdisk1 bs=1m

Or, with gzip, to save a substantial amount of space:

sudo dd if=/dev/rdisk1 bs=1m | gzip > /path/to/backup.gz

And, to copy the image back onto the SD:

gzip -dc /path/to/backup.gz | sudo dd of=/dev/rdisk1 bs=1m

For more information, see this wiki page.

Comments

Desultory - des-uhl-tawr-ee, -tohr-ee

  1. lacking in consistency, constancy, or visible order, disconnected; fitful: desultory conversation.
  2. digressing from or unconnected with the main subject; random: a desultory remark.
My Desultory Blog