I've been having trouble cloning an SD card so that it boots on the Pi. I'm wondering if having a recovery partition on the source card is an issue or not. The cloning process seems to work fine, but my pi won't boot on the cloned card.

I've tried it more than a few times.

I successfully clone it on my mac using the standard commands like:

sudo dd if=/dev/disk2 of=~/Desktop/raspberrypi.dmg

Then I stick a new card in (same size as cloned card).

I unmount it:

diskutil unmountDisk /dev/disk2

Then format it:

sudo newfs_msdos -F 16 /dev/disk2

Then restore my image to that card

sudo dd if=~/Desktop/raspberrypi.dmg of=/dev/disk2

All of that works fine. But if I stick the new card in the Pi (new Raspberry Pi 2), and turn it on I just get 2 solid lights (red and green) and nothing happens.

However, I can successfully download a Raspbian image and put that on a card and boot the Pi with it, but I can't get my cloned card to boot. So the Pi is not the issue. It's definitely the cloned card.

  • 1
    I think the step of formatting the sdcard is unnecessary because with dd you are overwriting the contents in a raw fashion (ie. Is not a file system operation, is lower than that). Moreover, are you sure you are ejecting the sdcard in a safe way after cloning it? Mar 27 '15 at 22:44
  • Ditto jotadepicas -- the format here is just superstitious. Have you tried checking the image with fdisk (OSX should have that)? See last few paragraphs here.
    – goldilocks
    Mar 28 '15 at 12:34
  • Thanks, I think the issue may be that I'm trying to boot the cloned SD card on a Raspberry Pi 2, and the source SD card was not from a Pi2, but from a Pi model B. However I've had trouble cloning before so the Pi2 issue wasn't my first instinct. I'm doing this now on the source pi: apt-get update apt-get upgrade apt-get dist-upgrade apt-get install raspberrypi-ui-mods as recommended by raspberrypi.org/forums/viewtopic.php?f=28&t=58151
    – Fraggle
    Mar 28 '15 at 15:43

You don't say if the card is NOOBS. This has a "Recovery" partition, which OS X won't mount (as it conflicts with the OS X Recovery partition. (I wish NOOBS has chosen a different name.)

There are a few other problems with your backup. You need to make sure the card is unmounted, also unless you use rdisk it will be glacially slow, and you should specify a block size.

My OS X script, below, finds the correct dev and includes the above.

PS I suggest you DON'T use .dmg for the extension. EDIT 2017-02-10 Updated to latest script

# script to backup Pi SD card
# 2017-02-10
# DSK='disk4'   # manual set disk
# Find disk with Linux partition (works for Raspbian)
# Modified for PINN/NOOBS
export DSK=`diskutil list | grep "Linux" | sed 's/.*\(disk[0-9]\).*/\1/' | uniq`
if [ $DSK ]; then
    echo $DSK
    echo $OUTDIR
    echo "Disk not found"

diskutil unmountDisk /dev/$DSK
echo please wait - This takes some time
echo Ctl+T to show progress!

time sudo dd if=/dev/r$DSK bs=4m | gzip -9 > $OUTDIR/Piback.img.gz
#rename to current date
echo compressing completed - now renaming
mv -n $OUTDIR/Piback.img.gz $OUTDIR/Piback`date +%Y%m%d`.img.gz

The following is my restore script (you need to set dev)

NOTE These days I just use Etcher which is easier (and safer)

# script to restore backup to Pi SD card
# 2018-06-21


# Image name (no ext)

# Check for sensible disk
export PTYPE=$(diskutil list  /dev/$DSK | awk '/GUID_partition_scheme/ {print $2}; /Apple/ {print $2}; /Windows_NTFS/ {print $2}' )
if [ "$PTYPE" ]; then
    echo "Disk not a SD Card - Contains "$PTYPE
elif [ ! /dev/$DSK ]; then
    echo "/dev/$DSK not found"

echo Ensure SD partitions are unmounted!
diskutil unmountDisk /dev/$DSK

# Check if image exists - else try to uncompress
if [ -s $IMG.img ]; then
    echo $IMG.img exists
elif [ -s $IMG.img.gz ]; then
    echo Copying $IMG.img.gz
    echo Ctl+T to show progress!
    #time  gunzip -k $IMG.img.gz
    time gunzip -kc $IMG.img.gz | sudo dd conv=sync of=/dev/r$DSK bs=4m
elif [ -s $IMG.zip ]; then
    echo Copying $IMG.zip
    echo Ctl+T to show progress!
    time unzip -p $IMG.zip | sudo dd conv=sync of=/dev/r$DSK bs=4m

echo please wait - This takes some time
echo Ctl+T to show progress!
time sudo dd conv=sync if=$IMG.img of=/dev/r$DSK bs=4m


I have modified my script to support NOOBS (which has multiple Linux partitions) by changing the line which detects the dev.

export DSK=`diskutil list | awk '/Linux/ {print $5}' | cut -c 1-5 | uniq`
  • thanks for the rdisk advise. Yes the card probably was a Noobs card. OSX does seem to mount the recovery partition though, and why mounting is an issue or not I don't get, since we unmount anyway before copying.
    – Fraggle
    Mar 28 '15 at 15:45
  • My issue may be due to that I'm trying to boot to a Pi2 when the source sd card is from a Pi B.
    – Fraggle
    Mar 28 '15 at 15:46
  • Combine that with this https://askubuntu.com/a/893504 and bam! (get pv first) Mar 9 '18 at 16:03

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.