I have a linux distribution that I installed on an SD card. After the lengthy installation was finished I created a DMG backup of all the partitions using the Mac's built in disk utility. The recovery image is currently 865.5MB large and seems to contain the correct information.

I am currently attempting to restore this image onto another SD card to ensure the recovery process will work appropriately. To perform this action I went into disk utility under the restore tab and entering the appropriate fields. I selected the DMG recovery file as source while selecting the SD card bay as the destination. All seemed to be working since disk manager prompted me if it was alright to fully erase the SD card as well as my root password for permissions. However, my victory was short lived as it promptly showed me this error: Recovery Error: Could not validate source - Invalid argument. I guessed that the source was incorrect, so I tried opening the DMG and providing the virtual drive as the source. However the same error persists.

Since this card contains three partitions with one being a blessed bootable partition, I would like to see if there are any ways to get my Mac to generate these for me. Since disk-utility archived the full SD card with partitions, I would assume is has a way to recover it going the other way.

Full logs from Disk Utility:

2013-01-23 19:02:27 -0500: Restore Disk
2013-01-23 19:02:27 -0500:  Source: “Raspbian.dmg”
2013-01-23 19:02:27 -0500:  Destination: “APPLE SD Card Reader Media”
2013-01-23 19:02:27 -0500:  Erase Destination: Yes
2013-01-23 19:02:27 -0500:  Erase “APPLE SD Card Reader Media” and copy the contents of “Raspbian.dmg” to it.
2013-01-23 19:02:27 -0500: 
2013-01-23 19:02:27 -0500: Starting Restore…
2013-01-23 19:02:27 -0500: Validating target...
2013-01-23 19:02:27 -0500: done
2013-01-23 19:02:27 -0500: Validating source...
2013-01-23 19:02:27 -0500: Could not detect format of volume on device ""
2013-01-23 19:02:27 -0500: Could not validate source - Invalid argument
2013-01-23 19:02:27 -0500: Could not validate source - Invalid argument
2013-01-23 19:02:27 -0500: 
  • What is the format of the DMG you created? HFS+? – Thorgrim Feb 6 '13 at 22:14
  • @Thorgrim Disk Description : Apple UDIF read-only compressed (zlib) The partition map scheme is master boot record. This dmg also contains 3 partitions. FAT32, linux-swap, and linux partition type which I forgot the name of (and apple doesn't recognize). Hope this helps, post another comment if it doesn't or you need more info. Thanks for the reply. – jakebird451 Feb 6 '13 at 22:25

Use the dd command-line tool.

  • Mount the SD
  • Use "Disk Utility": Select the top level of the SD card and "Get Info". Note the "Disk Identifier" (example disk13)
  • Unmount all of the volume on the SD, if they are mounted, but do NOT removed the SD card. This is important because the dd will fail if it detects any mounted volumes.

In the Terminal:

  • If you are not in an Admin account, use "su (admin account name)" to gain admin authority
  • sudo dd if=/path/to/DMG/file of=/dev/(disk identifier from above) bs=16k

Then wait a long time for the operation to complete. In a 4 GB copy I performed recently to a CF card, it took 21 minutes to finish.

You will eventually get 3 lines stating records in & out and bytes copied. Example:

243528+1 records in
243528+1 records out
3989970432 bytes transferred in 1278.252950 secs (3121425 bytes/sec)

In my case I have been copying .img files to CF cards, hopefully it works just as well for DMG's

  • 5
    Pro tip: press Ctrl+T at any time while the dd command is running to get a quick status report, among the lines of load: 1.82 cmd: gdd 17747 uninterruptible 0.05u 3.81s 15730+0 records in 15730+0 records out 257720320 bytes (258 MB) copied, 179.779 s, 1.4 MB/s. – Mathias Bynens Dec 27 '13 at 16:44
  • I can't seem to get the bs=?? right. What number is supposed to be there (what data do i use to calculate the bs number?) – user66808 Jan 8 '14 at 16:25
  • 3
    you can write the image much faster using this command: sudo dd if=path_of_your_image.dmg of=/dev/rdiskn bs=1m (keep in mind the "r" before the diskn, and bs=1m) – Andrei Radulescu Oct 15 '15 at 16:20
  • so the dd supports .dmg images, really? – Display Name Oct 23 '15 at 14:35
  • @Sarge dd doesn't care what it is copying, but it being successful doesn't mean the other end reading the data will know what to do with it. – J.Money Nov 10 '16 at 20:47

Just found a solution that worked for me:

  • First you need to convert the .dmg image to a raw image:

    hdiutil convert foo.dmg -format UDTO -o bar.img
  • This creates a file with .cdr extension but it is a raw image. So you can change the file extension to .img:

    mv bar.img.cdr bar.img
  • finally you can copy the image to your SD card using dd:

    sudo dd bs=2048 if=bar.img  of=/dev/rdiskX

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .