Translate

Saturday, May 4, 2019

MacOS - duplicate an SD card

Very few notes about how to duplicate an SD card or micro SD card using a Mac.
All these operations are done via terminal.

Shopping list


It is needed :

  • an SD card reader
  • the utility dd
  • the utility ddrescue
  • the utility diskutil
  • the app SD Card formatter
dd and diskutil should already be installed on the mac.
For the ddrescue, you can install for example using brew : brew install ddrescue

Copy from SD card


This procedure is creating an image of the SD card.
Be careful !
16 Gbyte of SD card will generate 16 Gbyte image !
  • insert SD card reader with card to read
  • use diskutil to locate the card : diskutil list
  • use ddrescue to create the image : sudo ddrescue /dev/<sd card disk> ~/image_name.raw
    (of course sd card disk need to be the SD card name returned with diskutil list, something like /dev/disk2 for example. image_name.raw is just a file name, can be anything)
    • it can take some time depending of the dimension of the SD card.
      8 Gbyte can take about 20 minutes
Done. When ddrescue ends the image will be in the user home directory.

Burn an SD card

Having an image is possible to burn it on an SD card.
Is not necessary to have an identical SD card but of course the SD card must be equal or bigger than the image size !
So is OK to burn a 16 Gbyte SD card with an 8 Gbyte image.
Not the opposite !


  • insert SD card reader with card to write - if possible the card should be formatted in FAT32 - single partition
  • use diskutil to locate the card : diskutil list
    Here an example of a formatted 16 Gbyte SD card in FAT32 - empty

    /dev/disk2 (external, physical):
       #:                       TYPE NAME                    SIZE       IDENTIFIER
       0:     FDisk_partition_scheme                        *15.9 GB    disk2
       1:             Windows_FAT_32 NO NAME                 15.9 GB    disk2s1
  • umount the partition of the card with diskutil : diskutil umount <partition name>
    In the example above we need to umount the Fat32 partition, thus :
    diskutil umount disk2s1
  • use dd to burn the SD card : sudo dd if=~/image.raw of=/dev/r<name disk> bs=1m
    Using the example above will be something like :
    sudo dd if=~/Desktop/strech.raw of=/dev/rdisk2 bs=1m
    • note the "r" in front at the disk2. It force the raw writing improving the speed
    • it can take some time depending of the dimension of the SD card.
      8 Gbyte can take about 20 minutes



No comments:

Post a Comment