I've built a beautifully crafted SD card for my application using a Raspberry Pi Zero. Before shipping it to my customer I've made a backup.

What I did on my Mac BookPro is

  1. Open DiskUtility
  2. Menu `File/New Image.../Image from "APPLE SD Card Reader Media"
  3. Choose "Compress image"

and wait. The original SD card was 16GB.
The resulting DMG file (if mounted) gives /dev/disk3 (disk image): #: TYPE NAME SIZE IDENTIFIER 0: FDisk_partition_scheme +16.1 GB disk3 1: Windows_FAT_32 boot 43.0 MB disk3s1 2: Linux 15.9 GB disk3s2

Then, using Etcher, I usually etch the resulting DMG to a new SD. But this time the resulting size is too big for the SD. Of course the original Card was a 16GB and I'm trying to copy it to another SD. I've tried changing several SD and the result is always the same. I don't know why.

I've done another backup of another SD card (different content) without compressing the image, and it seems to write back correctly.

Any idea on how to recover my data? Thanks Walter

  • Have you looked into simply mounting the card (with an adapter) on a Linux system? Here is a link to another Q&A which explains how to use the dd command to copy to smaller drives: raspberrypi.stackexchange.com/questions/82347/… – SDsolar Apr 16 '18 at 15:44
  • No I haven't. I guess it will work, but that is not the point I fear. I wanted to know how to be sure to have a backup ready. – zontar Apr 17 '18 at 11:20
  • Using the dd technique you can always know that. In fact, it can save to .IMG files (which are essentially .ISO) - However, in order to be use the easier methods it is imperative that you have image (or DMG) files that can match the SD cards you plan to use in the future. The Q&A referenced above was triggered by discovering that even though I was purchasing what I thought were all identical cards, one of the early cards was slightly larger so wouldn't fit. Saving images is more picky. But dd doesn't care. It may well turn out that a similar method may be applicable to Macs. – SDsolar Apr 17 '18 at 16:56

As a rule of thumb, there aren't (m)SD cards of the exact same size. Each individual (m)SD card differs in the amount of storage sectors (blocks) offered, depending on the specific internal controller used as well as the specific memory chips and production yields. Even cards from the same manufacturer of the same model type and from the same batch/lot will show varying block counts, mSD cards of the exactly block count/size are good luck, and thus the exception.

There are basically two ways to deal with this situation:

  1. Create a full 1:1 image on a smaller card, say, an 8GiB card. Later flash this image to larger cards, such as 16GiB cards. This is the fastest method if your image has a good ratio of used blocks/total blocks. For rather sparsely filled images, a plain 1:1 flash might not be the fastest method after all. After flashing, you may run a one-time script to expand the system partition to the full size of the mSD cards in order to make good use of the available storage. This is the way done with Raspbian, and other distros.
  2. Clone your master card/master image logically onto your mSD card copies, with a cloning tool, such as rpi-clone. This can actually be even faster or on-par with plain 1:1 flashing in case your source image/card is only filled to a lesser extend.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.