I have OnePlus 6T device which has A/B partition system and has a ROM of user type i.e `[ro.build.type]: [user]`. This device is rooted with Magisk. I have a requirement([Want to place customized sepolicy file under system_root directory][1]) to modify `system.img`.

I have tried different tools like:

1. [simg2img][2] :
```
OMEN-by-HP-Laptop-15-dc0xxx:~/WorkArea/img-tools$ ./simg2img system.img sys.raw
Invalid sparse file format at header magi
Failed to read sparse file
OMEN-by-HP-Laptop-15-dc0xxx:~/WorkArea/img-tools$ 
```
2. [imgtools][3]
```
OMEN-by-HP-Laptop-15-dc0xxx:~/WorkArea/imgtool$ sudo ./imgtool system.img extract
[sudo] password for OMEN: 
system.img is not a recognized image. Sorry
OMEN-by-HP-Laptop-15-dc0xxx:~/WorkArea/imgtool$ 
```
3. and more tools even on windows..

but none of them is capable of parsing my `system.img`.

I have copied `system.img` directly from OnePlus6T ROM setup which installs Android 9 on this device without any issue.

Any help on:

1. How to fix the system.img so it will be extracted and repacked fine?
2. Any command that can unpack/repack system.img?
3. Any working tool to accomplish this task?


**Update 1**: I have run `file system.img` and I found that its ext2 image and the tools support ext4.
```
system.img: Linux rev 1.0 ext2 filesystem data, UUID=d09c08e9-628d-590e-a610-3a14de2a8db0 (extents) (large files) (huge files)

```

**Update 2**: Tried to find the magic number and have following result:
```
OMEN-by-HP-Laptop-15-dc0xxx:~/WorkArea/imgtool$ xxd system.img | head
00000000: 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000010: 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000020: 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000030: 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000040: 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000050: 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000060: 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000070: 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000080: 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000090: 0000 0000 0000 0000 0000 0000 0000 0000  ................
OMEN-by-HP-Laptop-15-dc0xxx:~/WorkArea/imgtool$ 
```

  [1]: https://android.stackexchange.com/questions/215800/how-to-disable-dm-verity-on-android-with-user-type-rom?noredirect=1#comment276509_215800
  [2]: https://www.china-devices.com/forum/index.php?threads/how-to-properly-unpack-and-repack-android-system-img-for-sp-flash-tool.18739/
  [3]: http://newandroidbook.com/tools/imgtool.html