How to unpack, modify, pack and flash `system.img.ext4` file using Odin?

↘锁芯ラ 提交于 2019-12-23 23:19:49

问题


I have a system.img.ext4.lz4 file that is compatible with my Samsung S10 5G(Qualcomm) device. I have extracted system.img.ext4 file from the system.img.ext4.lz4 using unlz4 system.img.ext4.lz4 command.

I want to play with its content. So I have decided it in two steps:

  1. Flash system.img.ext4 without modification:

    • Using tar -cvf AP.tar system.img.ext4 command, I have created a AP.tar file.
    • Flashed AP.tar file using Odin3 v3.13.
    • It flashed successfully.
  2. Flash system.img.ext4 with modification:

a) Modifying

  • With simg2img system.img.ext4 system.img, you will get a raw image file named system.img
  • With mkdir system, create directory to mount system.img
  • With sudo mount -t ext4 -o loop system.img system/ you will get all files of system.img in system folder
  • With ls -l system/init.rc note permissions: 750
  • With sudo chmod 777 system/init.rc give write permissions
  • With sudo echo "#MODIFICATION " >> system/init.rc done some modification in init.rc
  • With sudo chmod 750 init.rc reset init.rc to the noted permissions

b) Calculate system sector size

  • With tune2fs -l system.img | grep "Block size\|Block count" you will get block size and count
  • With echo $((1553064 * 4096)) multiply both results. I got 6361350144

c) Packing

  • With sudo make_ext4fs -s -l 6361350144 -a system system_new.img sys/ you will get system_new.img “Android Sparse Image” that has all changes
  • With sudo umount system unmount the system directory
  • With rm -fr system delete the system directory

d) Tar Compression

  • With rm system.img.ext4 remove original system.img.ext4, Don’t worry you should have a backup of it in lz4 file
  • With mv system_new.img system.img.ext4 rename system_new.img to system.img.ext4 for flashing with Odin3 v3.13
  • With tar -cvf AP.tar system.img.ext4 you will get AP.tar that you can flash with Odin3 v3.13.
  • It failed to flash with FAIL! (Auth) error.

Please suggest how can I resolve this issue? I will be very thankful to you for any little to big suggestion.

来源:https://stackoverflow.com/questions/58541074/how-to-unpack-modify-pack-and-flash-system-img-ext4-file-using-odin

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!