[chbot] SD Copier

Volker Kuhlmann list57 at top.geek.nz
Mon Apr 12 06:09:32 BST 2021


On Sun 11 Apr 2021 22:55:15 NZST +1200, Marshland Engineering wrote:

> Must be looking in the wrong place but I can't find an SD card copier that
> does not create a copy of the full card. Ie if I need to copy a 32GB card that
> only has a few MB of data, it clones the full 32GB.

Yes, they're general purpose and ALWAYS work.

If you want to only copy the used space, you must make assumptions on
what is used. That requires you to know about the file system on the
card. You want any doze tool to get that right for the ext4 filesystem
the pi is likely to have? Good luck.

Other options:

If only a few MB are used, why do you have a 32GB card? If that's all
you can buy these days, make a 4GB partition at the start of the card
and only back that up. You can restore that to any card 4G or larger
(note a 4GB card has less than 4GB so remember that when downsizing the
32GB card partition).

If you need lots of data space, if that doesn't need backing up, put it
on a separate card partition, after the first, and only back up the
first.

I believe SD cards now support the TRIM command, and ext4 ought to be
using it (also required for SSD disks). With some luck, those sectors
read back as zeroes, or 0xFF. Otherwise, fill up the filesystem with a
file containing only 0s every so often. Then back up all 32GB to a file,
and compress the file - effective because most of the data is 0 or 0xFF.

Option 3: Back up the whole card (zero things out first), compress the
file and store. This will back up the boot loader parts. After that,
just back up the files on the card. To restore, restore the 32GB image
first, then extract the last set of backup files over it.

None of that requires special tools. I trust you have a doze tool that
copies disk blocks to file and reverse. For option 3 you need a doze
tool writing ext4 - good luck, or any Linux system.

Volker

-- 
Volker Kuhlmann
http://volker.top.geek.nz/	Please do not CC list postings to me.



More information about the Chchrobotics mailing list