Skip to content

SD card: backup and duplication

sethismyfriend edited this page Sep 25, 2014 · 1 revision

####Generating an image from an SD CARD

If you copy in character mode instead of block mode by specifying "/dev/rdisk1" (adding an 'r' for raw) it will copy much faster. See this page for an explanation of block and character devices. Using an 8gb card:

sudo dd if=/dev/rdisk1 of=/Users/sethMIT/Documents/iotdk_raw.img bs=1m
Password:
7600+0 records in
7600+0 records out
7969177600 bytes transferred in 193.974409 secs (41083654 bytes/sec)

Here is a the image this method produces: download raw img zip

####Writing the image back to a fresh SD Card (8GB)

To copy the bytes to a new SD card, put the disk in your computer and use disktutil to list disks and unmount the disk. Be very careful not to specify your hard drive as dd does not ask permission to run.

✘ sethMIT@sethismyfriend  ~  diskutil list
/dev/disk0
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *500.3 GB   disk0
   1:                        EFI EFI                     209.7 MB   disk0s1
   2:                  Apple_HFS Macintosh HD            419.0 GB   disk0s2
   3:                 Apple_Boot Recovery HD             650.0 MB   disk0s3
   4:       Microsoft Basic Data                         80.4 GB    disk0s4
/dev/disk1
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:     FDisk_partition_scheme                        *8.0 GB     disk1
   1:                 DOS_FAT_32 UNTITLED                8.0 GB     disk1s1
 sethMIT@sethismyfriend  ~  diskutil unmountDisk /dev/disk1s1
Unmount of all volumes on disk1 was successful

Copying the raw characters back to the SD card is MUCH faster than in block mode. Note the 'r' before disk1 below as well.

sudo dd if=/Users/sethMIT/Documents/iotdk_raw.img of=/dev/rdisk1 bs=1m
7600+0 records in
7600+0 records out
7969177600 bytes transferred in 704.436771 secs (11312836 bytes/sec)

If you want to monitor the status of the copy, open a new tab, get the PID and send it a temp INFO signal and it will report back how many blocks in the other tab:

pgrep -a '^dd$'
sudo kill -INFO 10660

(replace with your PID above - this allows you to not waste hours wondering if your write process is working)