Backup/restore SD drive on Mac

Migrating your data to another SD disk drive.

This shows how you can backup and restore an SD card, handy if you are transferring images or data or an OS from one card to another.

Using the Terminal just type the following to find out where your disk is.

diskutil list And you end up with something like the following.

$> diskutil list
/dev/disk0
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *1.0 TB     disk0
   1:                        EFI EFI                     209.7 MB   disk0s1
   2:                  Apple_HFS Macintosh HD            999.3 GB   disk0s2
   3:                 Apple_Boot Recovery HD             650.0 MB   disk0s3
/dev/disk2
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:     FDisk_partition_scheme                        *7.9 GB     disk2
   1:             Windows_FAT_16 RECOVERY                1.3 GB     disk2s1
   2:             Windows_FAT_32 boot                    58.7 MB    disk2s5
   3:                      Linux                         6.5 GB     disk2s6

You can see the flash drive inserted into the Mac as disk2.

To backup, I’m doing this with a Raspberry Pi OS SD card, so I can migrate from 8GB to 16GB to fit more camera photos on it and to negate resetting up everything when tinkering goes wrong. This will take several minutes to process, so be patient, also make sure you have the correct disks named, otherwise you can corrupt your main disk drive here using sudo, YOU ARE WARNED, THIS IS YOUR RESPONSIBILITY!

$> sudo dd if=/dev/rdisk2 bs=1m | gzip > ~/Desktop/RaspberryPi/bu_flash/pi.gz

Format your shiny new disk by using (Mac only described here) the Diskutility to Erase the disk with the MS-DOS (FAT) format.

Then, unmount the disk otherwise you will get a Resource Busy notice…

$> diskutil unmountdisk /dev/disk2

Then, start the flash process for the new card, this may take a while, if nothing is happening this is a good sign so let it run it’s course…

$> gzip -dc ~/Desktop/RaspberryPi/bu_flash/pi.gz | sudo dd of=/dev/rdisk2 bs=1m

Hope this helps someone out there :)