6

I have set up my Raspbian and need to clone the SD Card to about 20 other Raspberry Pis now.

I used the following command (on OS X) to clone the SD Card:

sudo dd if=/dev/rdisk3 of=~/Desktop/pi.img bs=1m
gzip -c ~/Desktop/pi.img > ~/Desktop/pi_img.gz

diskutil unmountDisk /dev/disk3
gzip -dc ~/Desktop/pi_img.gz | sudo dd of=/dev/rdisk3 bs=1m

I also tried the same thing with disk (instead of rdisk) and without gzipping it.

sudo dd if=/dev/disk3 of=~/Desktop/pi.dmg
diskutil unmountDisk /dev/disk3
sudo newfs_msdos -F 16 /dev/disk3
sudo dd if=~/Desktop/pi.dmg of=/dev/disk3

results are the same:

kernel panic not syncing: VFS: Unable to mount root fs on unknown-block 179,6

Of cause the main SD Card still works. This error is only on the cloned SD Card

Is there another way to clone the SD Card 1:1? or is there a way to fix the broken cloned SD? If possible this should be an automatable solution because I have to do this to 20+ PIs 2-3 times a year or so.

EDIT I just noticed, that my .dmg image has 4 partitions (boot, RECOVERY, disk4s3, disk4s6) but the cloned SD Card has only 3 (boot, RECOVERY, disk4s6). So.. disk4s3 seems to be the problem..

4

Did you check the exact sizes of both of the cards (eg. using fdisk)?
If the target card is a little bit smaller than the the original card, duplicating using dd can (or even will?) fail.

The same error happened to me and I solved it the following way on Ubuntu running on my Mac (following this tutorial creating an Ubuntu live USB stick using Mac Linux USB Loader). You need to do this under Linux to be able to access the Linux file system on the SD cards:

  1. I manually replicated the partition table to the new card using fdisk.
  2. Formatted the partitions using mkfs.
  3. Copying the files using rsync -av.

The card was perfectly booting afterwards.

  • Can you please elaborate on the method you used, I am kinda stuck here even after trying out several options with the dd command – b-ak Mar 13 '16 at 6:59
  • As suggested, if the target card is smaller than the source card, don't use dd. Follow the above instructions instead using rsync. – Js. Mar 14 '16 at 9:17
  • That is exactly the problem I faced after trying to clone an SD card on a Mac. Doing it on Linux resolved the issue. – IgorGanapolsky Dec 1 '16 at 15:54

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.