Skip to content

Instantly share code, notes, and snippets.

@telmofcosta
Created February 8, 2015 12:16
Show Gist options
  • Save telmofcosta/47df922afdf3a7ddf583 to your computer and use it in GitHub Desktop.
Save telmofcosta/47df922afdf3a7ddf583 to your computer and use it in GitHub Desktop.
Backup and restore an SD card on Mac OS x (perfect for Raspberry Pi)
# insert SD and find out where it is mounted
diskutil list
# /dev/disk0
# #: TYPE NAME SIZE IDENTIFIER
# 0: GUID_partition_scheme *250.1 GB disk0
# ...
# /dev/disk1
# #: TYPE NAME SIZE IDENTIFIER
# 0: FDisk_partition_scheme *15.7 GB disk1
# ...
sudo dd if=/dev/rdisk1 bs=1m | gzip > ~/Desktop/sdcard.img.gz
# or if you don't want to compress it:
# sudo dd if=/dev/rdisk1 of=~/Desktop/sdcard.img bs=1m
# to restore it, firn unmout the SD
diskutil unmountDisk /dev/disk1
gzip -dc ~/Desktop/sdcard.img.gz | sudo dd of=/dev/rdisk1 bs=1m
# or if it is not compress:
# sudo dd if=~/Desktop/sdcard.img of=/dev/rdisk1 bs=1m
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment