Background: I need to clone ext4 partitions from an eMMC using uboot (and if neccessary custom bare metal code). I copied the whole thing using
mmc read and found that most of the partition is empty, but there are some blocks of data like inode tables spread across the partition. This would mean I need to copy the whole partition (which is too slow, I need to do this a lot) or identify what parts of the partition are relevant.
Most similar Q&A to this problem suggest to use
dd creating a sparse image or piping to
gzip, but I have no operating system running, so I need to understand the file system layout. Can I use those bitmap blocks to identify what is used and what is free? Documentation of ext4 seems to refer the linux kernel code as soon as it comes to details.
Preferably I'd do it with uboot code, but I could as well write some bare metal code I can execute from uboot.
One more border condition: The targets to where the partition gets clone are not empty, so if there are blocks of only zeros on the origin, which are required to be zero, I need to overwrite those blocks with zeros on the target.