×

INDI Library v2.0.7 is Released (01 Apr 2024)

Bi-monthly release with minor bug fixes and improvements

SD Card cloning software for Mac

  • Posts: 225
  • Thank you received: 16
Is there a Mac application that will let you clone an RPi SD Card to another SD Card?  BalenaEtcher is supposed to be able to do this... but I can make it work for SD to SD cloning on my Mac.

Thanks,

Ron
2 years 11 months ago #71121

Please Log in or Create an account to join the conversation.

  • Posts: 300
  • Thank you received: 57
I use ApplePiBaker for the mac. Works great for backup, cloning, archival, etc.
2 years 11 months ago #71127

Please Log in or Create an account to join the conversation.

  • Posts: 225
  • Thank you received: 16
Thanks... I tried ApplePiBaker... but it doesn't work for boot drives.

Ron
2 years 11 months ago #71130

Please Log in or Create an account to join the conversation.

  • Posts: 1957
  • Thank you received: 420
I use dd from a terminal. This I wrote earlier today on the ZWO forum for cloning ASIAir SD cards. The instructions for Raspbian or Ubuntu may be slightly different, especially the mounted partition names on MacOS, but if you follow the guidelines you should get it to work.

For dd, follow these following steps. But before you do so, I need to write this:

DISCLAIMER These instructions contain examples of device names that are specific to my situation. Do not copy and paste and command and execute them without making sure that your Mac is using the same device names. Failing to do so may overwrite the contents of a disk unintentionally and it will be impossible to revert. Proceed with caution and make sure to follow all steps and replace any device in the command examples with the ones used on your Mac!!!

First thing to do is to see what OS device the BOOT partition is on. This can be done with

diskutil list

In my case it shows that the SD card is the /dev/disk2 device. When the SD card gets connected to the Mac, the BOOT partition gets mounted automatically and this needs to be unmounted for dd to work properly. You can see all mounted devices with

mount

In my case I see

/dev/disk2s1 on /Volumes/BOOT (msdos, local, nodev, nosuid, noowners)

so I need to unmount that. This is how to do that

diskutil umount /Volumes/BOOT

Issuing the mount command again, you can see that the partition was unmounted. Now you can create a backup. The dd command requires root privileges and the general command structure is

dd if=<source> of=<target> bs=<bs>

Source is where you want to copy the data from and target where to. bs is the block size. If you want to back up the SD card then source is the SD card device and target a file. If you want to restore the SD card then source is the file and target the SD card device. The block size specifies how many bytes get read from source and written to target at the same time. for MacOS and SD cards a sensible block size is 4 megabytes which is specified as 4m.

Now here's a little trick. MacOS has two layers of devices. The first layer we just saw when we checked what OS device was assigned to the SD card. However, MacOS also knows about raw devices and using dd with the raw device is MUCH faster. The raw device corresponding to an OS device has exactly the same name prepended with an r. So in my case the SD card was assigned to /dev/disk2 and therefore the raw device is /dev/rdisk2. Knowing this it is easy to backup the SD card. The command (in my case) is

sudo dd if=/dev/rdisk2 of=2021-05-09_asiar-backup.img bs=4m

This will back up the full contents of the SD card to a file called 2021-05-09_asiar-backup.img which gets created in the directory where the dd command gets issued. You are of course free to choose whatever filename you wish.

Once done, do not simply pull the SD card out of the Mac. The SD card partitions still are known to MacOS and need to be ejected first. So first issue

diskutil eject /dev/disk2

and you should be good. If you want to make sure that the partitions indeed have been ejected, you can issue

diskutil list

again.

If you want to restore a backup, you can follow exactly the same steps but you need to swap the source and target. So the dd command then becomes

sudo dd if=2021-05-09_asiar-backup.img of=/dev/rdisk2 bs=4m

Note that after restoring the SD card, MacOS will mount the BOOT partition again. It is not necessary to first unmount the BOOT partition and you can eject the device because that will take care of unmounting as well.

Please let me know if you have any questions regarding the use of dd.
Last edit: 2 years 11 months ago by Wouter van Reeven.
2 years 11 months ago #71131

Please Log in or Create an account to join the conversation.

  • Posts: 300
  • Thank you received: 57
I don't understand. I use it all the time for the SD cards I use to boot my pi's. It absolutely does work for this.
2 years 11 months ago #71132

Please Log in or Create an account to join the conversation.

  • Posts: 225
  • Thank you received: 16
wvreeven,

Thanks for this!  It looks a little beyond my talents, but may give it a try.

Ron
2 years 11 months ago #71133

Please Log in or Create an account to join the conversation.

  • Posts: 225
  • Thank you received: 16
Yeah, I tried it... backed up my boot SD to my Mac, then restored it to another SD... it wouldn't boot.  In the documentation, it says that you can't use it for boot discs.

If you got it to work, let me know your process.

Thanks!

Ron
2 years 11 months ago #71134

Please Log in or Create an account to join the conversation.

  • Posts: 300
  • Thank you received: 57
Hmmm. Nothing special really. It's the core functionality of the software, which is actually just a wrapper to dd as explained by Wouter.

Here's my process:
1) Remove SD card from pi
2) Place SD card in mac (I use a USB adapter)
3) Fire up ApplePiBaker
4) Choose "Disk to File" and select the SD card
5) Wait while SD card is cloned. I use both the partition shrink and compression options to save disk space
6) When it's done, remove the SD card from the Mac

I keep about a dozen clones of bootable RPi SD cards on my mac, both for backups and for swapping out different OSs.

To restore to a different SD card:
1) Put SD card in Mac
2) Start ApplePiBaker
3) Choose "File to Disk"
4) Wait while compressed image is expanded and written to SD card
5) Remove SD card from Mac
6) Place SD card in Pi and boot normally

I've been doing this for years and very rarely have problems.

Maybe you had a bad SD card or there was some kind of file corruption?

Scott
2 years 11 months ago #71135

Please Log in or Create an account to join the conversation.

  • Posts: 460
  • Thank you received: 69
This is the approach I use with ApplePiBaker as well. Works well for me.
2 years 11 months ago #71136

Please Log in or Create an account to join the conversation.

  • Posts: 225
  • Thank you received: 16
Hmmm... no, the SD is fine, as I've already used it for another image write.

What format do you save it to?  I used zip format.

Thanks,

Ron
2 years 11 months ago #71137

Please Log in or Create an account to join the conversation.

  • Posts: 300
  • Thank you received: 57
Yep, I use zip too. I’ve done hundreds of them.
2 years 11 months ago #71138

Please Log in or Create an account to join the conversation.

  • Posts: 225
  • Thank you received: 16
Okay... will give it another try.

Thanks,

Ron
2 years 11 months ago #71139

Please Log in or Create an account to join the conversation.

Time to create page: 0.266 seconds