Bosse_B
Posts: 966
Joined: Thu Jan 30, 2014 9:53 am

Problems when using command line script for cloning sd card

Thu Feb 27, 2020 7:12 pm

I need to clone the sd card of an RPi4 to reduce the size of SD card and to serve as a backup.
The Rpi4 is headless and uses Raspbian Buster Lite so there is no gui SD Card Copier available.
After searching a bit I found this thread whic is a bit old but I restarted it not realizing it was located in a corner of the forum with low traffic...
Here is a link to this thread:
Old thread about sd card cloning

I have successfully used a script found on github to copy the content of a 32GB disk to an 8GB one and it seems like all has been copiedf over, but the RPi won't boot off of this copy.
There must be something simple I have missed...

If someone here has experience in cloning a headless RPi SD card from an SSH terminal, then please advice what I should correct.
Bo Berglund
Sweden

Bosse_B
Posts: 966
Joined: Thu Jan 30, 2014 9:53 am

Re: Problems when using command line script for cloning sd card

Thu Feb 27, 2020 9:58 pm

SOLUTION:
Use the rpi-clone script available on github here!
I did so and used the command:

Code: Select all

sudo rpi-clone sda -f
when the target sd-card was inserted in an USB adapter and plugged into the RPi4.
The target card was 8GB and the source on the RPi4 is 32GB but only 2.8GB used.
I used -f because the target card was a used card from 2015 with an old Raspbian, -f commands a full overwrite.

It took 24 minutes in all and I now have a bootable clone, which I presumably can use as a backup via rpi-clone where it will rsync new and changed files.
Bo Berglund
Sweden

Return to “General discussion”