Page 1 of 1

Fail to clone SD card

Posted: Mon Feb 24, 2020 5:38 pm
by RPIZW
Hi all,

I fail to clone a SD card that I have from my Mac.

To backup, I use the command:

Code: Select all

sudo dd if=/dev/rdisk2 of=rpi1.dmg
then I want to clone it to another SD card that I have:

Code: Select all

sudo dd if=rpi1.dmg of=/dev/rdisk2
Then I put it in my RPI but it just doesn't work...
is there any tool I can use to ensure the clone is identical to the original SD card?
any idea what could go wrong?

Thanks in advance.

Re: Fail to clone SD card

Posted: Mon Feb 24, 2020 5:43 pm
by fruitoftheloom
RPIZW wrote:
Mon Feb 24, 2020 5:38 pm
Hi all,

I fail to clone a SD card that I have from my Mac.

To backup, I use the command:

Code: Select all

sudo dd if=/dev/rdisk2 of=rpi1.dmg
then I want to clone it to another SD card that I have:
sudo dd if=rpi1.dmg of=/dev/rdisk2

Then I put it in my RPI but it just doesn't work...
is there any tool I can use to ensure the clone is identical to the original SD card?
any idea what could go wrong?

Thanks in advance.

Raspbian Buster with Desktop includes SD Card Copier, so you can clone your booting SD Card to another which has enough capacity in a USB Card Reader.

If you need a CLi version, see:

https://github.com/billw2/rpi-clone



If you are after a MacOS solution, see:

https://www.tweaking4all.com/hardware/r ... -baker-v2/

Re: Fail to clone SD card

Posted: Mon Feb 24, 2020 6:22 pm
by RPIZW
Thanks a lot!! :)
now I understand what is the issue that I couldn't see with "dd" command.

Although both SD card are 8GB they have different capacity. one has 7.96GB while the other has 7.95GB
dd clone the empty space and when I try to restore I must have an exact or bigger SD card capacity... shame there is no other way to do it with dd..

I thought that zerorize empty space with help, but I still think that "dd" will copy the entire SD card with the empty (zero) space.


Is there any other solution? or else I must have equal / bigger SD card?

Re: Fail to clone SD card

Posted: Mon Feb 24, 2020 6:34 pm
by DougieLawson
RPIZW wrote:
Mon Feb 24, 2020 6:22 pm
Although both SD card are 8GB they have different capacity. one has 7.96GB while the other has 7.95GB
dd clone the empty space and when I try to restore I must have an exact or bigger SD card capacity... shame there is no other way to do it with dd..
If you can boot with another SDCard with a copy of GParted you can shrink the 7.96GB partition down to less than 7.95GB (something like 7.5GB) then it will be dd'able to any "8GB" card without a worry. That's using a sector by sector copy including empty sectors.

The SD cloning process is doing a file by file copy, so it only copies allocated space (which is why it runs quicker).

That also explains why the downloadable Raspbian image files are all less than 4GB and automgically activate the "expand the filesystem" process on first boot.