[Miscellaneous Android Development] munjeni:
For example you have extracted system_a partition with superunpack:

Do not pass 1 at the end since it somehow make partition with errors! Simple without 1 at the end like this:

../superunpack super_X-FLASH-ALL-2389.bin

partition_1_name = system_a
attributes = 0x1
first_extent_index = 0x0
num_extents = 0x1
group_index = 0x1
partition_group = somc_dynamic_partitions_a
extent num_sectors = 0x3c7998 (0x78f33000 bytes total)
extent target_type = 0x0
extent target_data = 0x800 (dumping offset = 0x100000)
extent target_source = 0x0
Filetype EXT4. EXT4 size = 0x77094000
Dumping system_a.ext4 ...
....................................................
....................................................
....................................................
....................................................
..............................

Its extracted as a true RO dynamic partition. Next step is to resize it to the enought size that e2fsck have enought resource for clone blocks during unshare blocks:

resize2fs system_a.ext4 2G

Now you have resized it to 2 Gb. Next step is unshare blocks. By that way e2fsck converts dynamic partition to normal partition making them rw too:

e2fsck -y -E unshare_blocks system_a.ext4

If everything right you will not see any error code. To be sure you can do it again:

e2fsck -y -E unshare_blocks system_a.ext4

If you see errors do everything from begining, surepunpack...etc and resize partition to a longer size than 2G. If no error you are ready for next step:

e2fsck -fy system_a.ext4

This step checks for errors and fix them. if you se no errors at the end you are ok. In the sime time your partition is RW! You should now mont them and modify:

root@dm920 /media/hdd/sony/rom # mount -t ext4 -o,rw system_a.ext4 rr
root@dm920 /media/hdd/sony/rom # ls rr
acct bin cache d data_mirror default.prop etc init.environ.rc lost+found mnt oem proc res storage system vendor
apex bugreports config data debug_ramdisk dev init linkerconfig metadata odm postinstall product sdcard sys system_ext

As you can see its mounted rw without problem. Now when you modify everything you need to resize partition back to the needed size, look at this from the top:

extent num_sectors = 0x3c7998 (0x78f33000 bytes total)

As you see partition need to be this size: (0x78f33000 / 4096) = 0x78F33 . Now convert HEX to DEC trought this site -> https://www.binaryhexconverter.com/hex-to-decimal-converter . Put 78F33 and convert to dec you will get something like 495411 , now you are ready resize partition back to the desired size:

Don't forget to unmont partition first!

umount rr
e2fsck -fy system_a.ext4
resize2fs system_a.ext4 495411

And if everything right it will be resized. In my case since I didn't deleted anything in mounted partition I have no enought space to resize to the desired size and getting error:

error: New size smaller than minimum (506087)

In case of error its clear that you need to delete much more files in partition in order to resize them back to desired size!!! That explain why superrepack tool is not working on almost half of the devices today! But if you done them sucesfully you can write back modified partition to the super partition this way:

see this log from the top:

extent target_data = 0x800 (dumping offset = 0x100000)

extent num_sectors = 0x3c7998 (0x78f33000 bytes total)

Convert 0x100000 from hex to dec = 1048576

Convert 0x78f33000 from hex to dec = 2029203456

Now command to write them back to super partition is:

dd if=system_a.ext4 of=super.img bs=1 seek=1048576 count=2029203456 conv=notrunc
sync

Easy and clear now? Thats it! In your case you will need img2simg because if I am not wrong it was compressed sparse image in your case? Hope this help! :)