Menu Close

How to backup and restore a SD card by macOS command line

Put the SD card in your Mac.

Backup

Start a terminal window and type the following command:

diskutil list

Search for your SD card and write down the disk number. Let’s assume we need disk2.

sudo dd if=/dev/disk2 of=~/Desktop/BackupDisk2.img bs=1M

Wait until the SD card has been completely read. The command does not show any feedback, so wait for the command prompt to reappear in the terminal window once it is complete.

Restore

Before we can restore a image to a SD card, first we need to unmount it:

diskutil unmountDisk /dev/disk2

Now type the command to restore the image file to the SD card:

sudo dd bs=1m if=~/Desktop/BackupDisk2.img of=/dev/disk2 conv=sync

After restoring, eject the disk2:

sudo diskutil eject /dev/disk2

Related Posts

Leave a Reply

Your email address will not be published.