I have made several images/clones of my SD disk from my Raspberry Pi. I have used the dd method via the Mac terminal, I've used the disk utility via the desktop. I found directions from other postings. I've copied the syntax correctly and the creating of the image shows bytes transferred and completes without failures. All looks good. Then when I go to restore the clone to a newly reformatted SD disk (using the SDformatter app.) then either via terminal or the Mac disk utility I try to restore the image I run into problems. From Mac disk utility I get an error "Could not validate source - Invalid argument". Using the terminal (sudo dd if=~/Desktop/raspberrypi.dmg of=/dev/disk2) verified the location of the sd disk by diskutil list. It takes about 3.4 hrs to copy over (32GB SD). When I unmount the disk, then put it back in the card reader I get the message ~ Cannot verify or recognize the format...

What would cause the image to be unusable for restore?


First - unless you you use raw disk mode backup and restore will be glacially slow. I doubt the copy or restore would complete in 3.4hrs, so you probably had an incomplete image. The following are the scripts I use on my Mac. (And before @goldilocks adds his comment, I usually use rsync to make copies.)

# 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

And this is the script I use to restore:-

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

# script to restore backup to Pi SD card
# 2017-05-26


# 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 Uncompressing $IMG.img.gz
echo Ctl+T to show progress!
time  gunzip -k $IMG.img.gz

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

  • When I run diskutil list here is what I see. /dev/disk1 #: TYPE NAME SIZE IDENTIFIER 1: Windows_FAT_16 RECOVERY 856.8 MB disk1s1 2: Linux 33.6 MB disk1s3 3: Windows_FAT_32 boot 62.9 MB disk1s5 4: Linux 30.9 GB disk1s6 I have a boot and recovery partition. Is this causing my problem? Should i be cloning one partition only? – Bewildered PiMan Apr 28 '15 at 17:40
  • @BewilderedPiMan This is getting away from the Pi, and you should ask on a Mac site. AFAIK diskutil will let you operate on partitions, but it will not let you copy whole disks including the MBR. The Pi NEEDS a whole disk image with MBR, and has its own special requirements for alignment (due to SD card issues). You should use dd which does treat the disk as a whole image. You can operate on individual partitions, but this was not your question. – Milliways Apr 28 '15 at 21:15

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.