Skip to content

Instantly share code, notes, and snippets.

@engincancan
Forked from telmofcosta/backup-restore sdcard
Created November 25, 2020 10:02
Show Gist options
  • Save engincancan/4186b3b9428fab15418aad65f369d88a to your computer and use it in GitHub Desktop.
Save engincancan/4186b3b9428fab15418aad65f369d88a 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