Raspberry Pi SDCard backup - Only used space...

Meractik

Golden Member
Jul 8, 2003
1,752
0
0
Ive got a very large 32gb SD card for my Raspberry Pi and I wish to copy it as a backup and also have the ability to mirror the card to another *smaller* SDCard, I use less then 700MB on the 32GB card because it simply houses my Raspberry Pi bootable stuff and is used exclusively with the Raspberry Pi only. I have all the settings perfected and would find it difficult to try & replicate them to a smaller card all over (Hence the reason I wish to mirror)


I was totally new to the whole Raspberry Pi stuff when I started fiddling with it and had no idea how impractical it would be to have such a large SDCard, therefore I wish to make a backup of the card and restore it to a much smaller card and use that to boot the Pi, and recycle the large 32GB card for something more suitable.


Any help you can provide is greatly appreciated, I am hoping their are some linux commands I could utilize to make this happen that would take a nice bit-by-bit backup and allow the use of switches to only extract/compress the used space? I am just unaware of them... If I had too I would also be okay with using some windows software if it can accomplish my needs.

Any help you can provide is greatly appreciated.
 

Red Squirrel

No Lifer
May 24, 2003
70,198
13,582
126
www.anyf.ca
You can probably use something like Acronis.

Or, a more crude way, dd it to an existing 32GB card, use gparted to shrink down the partition, then dd the partition itself to a file. I have not tried this myself but I would imagine it should work.

I'm thinking something like acronis would be the easiest though. There's a free imaging program called clonezilla, it might work (never used it myself).
 

Cerb

Elite Member
Aug 26, 2000
17,484
33
86
Use Clonezilla for a one-off. Just have it plugged in to a PC with an SD reader, and voila!

Partclone will copy only used data on FSes it supports (and is what Clonezilla uses, if it can).
https://wiki.archlinux.org/index.php/Partclone
With 700MB, I wouldn't bother compressing it in-flight.

Thing is, you want to have it not be mounted writable, so it's easiest/safest to use another computer to do it, even if it will work on the RPi itself (I don't know that it will, but that wouldn't surprise me).
 

Meractik

Golden Member
Jul 8, 2003
1,752
0
0
Red Squirrel, I just tried Acronis since I have a bootable CD-Rom handy and it does see the SDCard as removable media and allow me to perform a backup (into a *.tib) file when I restore that backup to the smaller SDCard and place it in the Raspberry Pi it fails to boot from it. Going to give Clonezilla a try now...