I try to edit an Android 11 system.img
file that was extracted from super.img
. Now I have an issue that is very confusing to me. First, I extracted system.img
by this command (The file system is erofs
, which is used on HUAWEI android devices):
sudo fsck.erofs --extract=./extracted --no-preserve --force --overwrite system_a.img
And I got a directory tree that contains files like this:
.
└── extracted
├── 3rdmodem
├── 3rdmodemnvm
├── 3rdmodemnvmbkp
├── acct
├── apex
├── cache
├── config
├── cust
├── d -> /sys/kernel/debug
├── data
├── data_mirror
├── debug_ramdisk
├── dev
├── eng
├── hw_product
├── linkerconfig
├── log
├── metadata
├── mnt
├── modem_log
├── odm
├── oem
├── patch_hw
├── preas
├── preavs
├── preload
├── prets
├── pretvs
├── proc
├── res
├── sec_storage
├── splash2
├── storage
├── sys
├── system
├── system_ext
├── vendor
└── version
Then, I did some modifications and tried to pack it into a system.img
using this command:
sudo mkfs.erofs -zlz4 -Enosbcrc -U00000000-0000-0000-0000-000000000000 --ignore-mtime lz4.system.img ./extracted/
Everything was perfect, no errors or warnings were shown with this command, and lz4.system.img
was generated successfully.
I compared two files by using file
command after finishing the re-packing:
@localhost:~/Desktop/extracted_super> file lz4.system.img system_a.img
lz4.system.img: EROFS filesystem, blocksize=12, exslots=0, uuid=00000000-0000-0000-0000-000000000000, incompat: LZ4_0PADDING
system_a.img: EROFS filesystem, blocksize=12, exslots=0, uuid=00000000-0000-0000-0000-000000000000, incompat: LZ4_0PADDING
But I found something different between the one I generated and the original one.
- File size wasn't the same (later I realized that it is normal because it wasn't signed)
- There are contents that differ from each other, I am enclosing the screenshot to make it clear to distinguish them:
As you can see on the right side of the picture, that's the original system.img
, it contains some of the strings that seem to have something to do with selinux
, in turn, the new one doesn't have it.
My questions are:
- What are the strings?
- What should I do to fix this? Is it because the new one hasn't been signed, so they are not the same?