I have a raw image of my Android phone's /system partition, captured with dd from TWRP recovery:
dd if=/dev/block/platform/soc/624000.ufshc/by-name/system of=/external_sd/system.img
This was captured after doing a restore of stock firmware from ZTE's website, so it is 100% official and unmodified.
I would like to get a high compression rate on this image to obtain a smaller file size (it's about 5GB now), but without corruption. The resulting file will also be written back to the partition with dd, after it is zeroed out.
The big issue is that Android OTA updates are done on a block/sector level, and the system partition is checked before an update is applied. If anything is different than what it expects to see (i.e. user modifications with root access or TWRP or whatever), the update will fail. Android also performs dm-verity checks (by default, which can be disabled with hackery) on this partition at bootup, via hash checking, again if anything is amiss then the device wont boot. So I need it to be an exact match to what is expected.