android_img_repack_tools is a kit utilites for unpack/repack android ext4 and boot images
for download choose any brunch
$ simg2img system.img system.raw.img
$ simg2img system.img* system.raw.img
$ mkdir system_mnt $ mount -t ext4 -o loop system.raw.img system_mnt
$ mkuserimg.sh -s system_mnt system_new.img ext4 ./system [size partition MB for example 1024M]
$ make_ext4fs -s -l 1024M system_new.img system_mnt
more
$ mkuserimg.sh -s system system.img ext4 /system [size partition MB for example 1024M] file_contexts
$ ext2simg -v system.raw.img system_new.img
$ sgs4ext4fs --bloat system_new.img system_32bit.img
$ mv system.raw.img system.moto.img $ dd if=system.moto.img of=system.raw.img ibs=131072 skip=1