I'm using Ubuntu 18.04 LTS, but haven't been able to spend much time on figuring out how to mount or access EROFS file systems yet. Has anyone gotten this figured out already? Any help will be great, thanks!
It started with that question, leading to finding the solution to mount the system.img, building mkfs.erofs and trying out a system.img etc.
I do not intend to work much on this, at least for quite a while owing to RL situations. In case anyone wants to build on this, please go ahead - everything I've used has a git that is linked appropriately
For building mkfs.erofs, here's what you need to do (mine is a Ubuntu 19.04 machine)In case anyone's looking to mount the erofs images from the stock firmware, here's what you have to do -
(The "-t erofs" is optional - will work just fine with sudo mount -o loop system.ext4.img /home/test/mnt/try2)
- Download and extract UPDATE.APP from the firmware zip, and use splitupdate binary/ perl script or Huawei Update Extractor. (I have linked to the tools I have tried or used in the past)
- Use simg2img to convert the system.img (or product.img or vendor.img) to raw format. simg2img is a part of android fsutils
Code:sudo apt install android-tools-fsutils- You will need a linux box or VM with Kernel 5.x running (erofs support is added from 4.20, but I am running 5.x) - mount the raw image using
Code:sudo mount -t erofs -o loop system.ext4.img /home/test/mnt/try2
You will get the erofs image mounted in the folder you've specified, and you can browse through it
Note that erofs images are not meant to be editable. If you want to modify the system.img, extract it's content and create a new system.img using the mkfs.erofs binary (I had linked to the source code). You'll of course need an unlocked bootloader to flash (or boot) the modified image![]()
Code:
git clone https://kernel.googlesource.com/pub/scm/linux/kernel/git/xiang/erofs-utils.git -b dev
./autogen.sh
./configure
make
More details from this post -
@oslo83 I have attached the mkfs.erofs binary using this git source to the first post.
Please go through the README for this - I built this binary for the x64 architecture, and for lz4-1.9.0
The command options are -
Note that the system.img that comes within UPDATE.APP is a root file system - here is a structure.Code:mkfs.erofs 0.1 usage: [options] FILE DIRECTORY Generate erofs image from DIRECTORY to FILE, and [options] are: -zX[,Y] X=compressor (Y=compression level, optional) -d# set output message level to # (maximum 9)
It would be good if you spend time with the system.img, vendor.img, product.img and understand how the structures are inter-linked. Happy hunting!Code:drwxr-xr-x. 2 root root 0 Aug 7 2018 3rdmodem drwxr-xr-x. 2 root root 0 Aug 7 2018 3rdmodemnvm drwxr-xr-x. 2 root root 0 Aug 7 2018 3rdmodemnvmbkp drwxr-xr-x. 2 root root 0 Aug 7 2018 acct lrw-r--r--. 1 root root 11 Aug 7 2018 bin -> /system/bin lrw-r--r--. 1 root root 50 Aug 7 2018 bugreports -> /data/user_de/0/com.android.shell/files/bugreports drwxrwx---. 2 ph03n1x 2001 0 Aug 7 2018 cache lrw-r--r--. 1 root root 13 Aug 7 2018 charger -> /sbin/charger dr-xr-xr-x. 2 root root 0 Aug 7 2018 config drwxr-xr-x. 2 root root 0 Aug 7 2018 cust lrw-r--r--. 1 root root 17 Aug 7 2018 d -> /sys/kernel/debug drwxrwx--x. 2 ph03n1x ph03n1x 0 Aug 7 2018 data drwxrwx--x. 2 ph03n1x ph03n1x 0 Aug 7 2018 data_old lrw-------. 1 root root 23 Aug 7 2018 default.prop -> system/etc/prop.default drwxr-xr-x. 2 root root 0 Aug 7 2018 dev drwxr-xr-x. 2 root root 35 Aug 7 2018 dload drwxr-xr-x. 2 root root 0 Aug 7 2018 eng lrw-r--r--. 1 root root 11 Aug 7 2018 etc -> /system/etc -rw-r-----. 1 root 2000 423 Aug 7 2018 fstab.zram1024m -rw-r-----. 1 root 2000 423 Aug 7 2018 fstab.zram1280m -rw-r-----. 1 root 2000 423 Aug 7 2018 fstab.zram1536m -rw-r-----. 1 root 2000 422 Aug 7 2018 fstab.zram2240m -rw-r-----. 1 root 2000 422 Aug 7 2018 fstab.zram256m -rw-r-----. 1 root 2000 422 Aug 7 2018 fstab.zram4096m -rw-r-----. 1 root 2000 422 Aug 7 2018 fstab.zram512m -rw-r-----. 1 root 2000 422 Aug 7 2018 fstab.zram768m -?????????? ? ? ? ? ? init -rwxr-x---. 1 root 2000 1717 Aug 7 2018 init.environ.rc -?????????? ? ? ? ? ? init.rc -?????????? ? ? ? ? ? init.usb.configfs.rc -?????????? ? ? ? ? ? init.usb.rc -rwxr-x---. 1 root 2000 580 Aug 7 2018 init.zygote32.rc -rwxr-x---. 1 root 2000 1042 Aug 7 2018 init.zygote64_32.rc lrw-r--r--. 1 root root 8 Aug 7 2018 log -> /splash2 drwxr-xr-x. 2 root ph03n1x 0 Aug 7 2018 mnt drwxr-xr-x. 2 root root 0 Aug 7 2018 modem_log drwxr-xr-x. 2 root root 0 Aug 7 2018 odm drwxr-xr-x. 2 root root 0 Aug 7 2018 oem drwxr-xr-x. 6 root root 71 Aug 7 2018 patch drwxr-xr-x. 2 root root 0 Aug 7 2018 patch_hw drwxr-xr-x. 2 root root 0 Aug 7 2018 preload drwxr-xr-x. 2 root root 0 Aug 7 2018 proc drwxr-xr-x. 2 root root 0 Aug 7 2018 product drwxr-xr-x. 2 root root 47 Aug 7 2018 res -rw-r--r--. 1 root root 32 Aug 7 2018 resetFactory.cfg drwxr-xr-x. 2 root root 0 Aug 7 2018 root drwxr-x---. 2 root 2000 183 Aug 7 2018 sbin lrw-r--r--. 1 root root 21 Aug 7 2018 sdcard -> /storage/self/primary drwxr-xr-x. 2 root root 0 Aug 7 2018 sec_storage drwxr-xr-x. 2 root root 0 Aug 7 2018 splash2 drwxr-x--x. 2 root 1028 0 Aug 7 2018 storage drwxr-xr-x. 2 root root 0 Aug 7 2018 sys drwxr-xr-x. 23 root root 478 Aug 7 2018 system -?????????? ? ? ? ? ? ueventd.rc drwxr-xr-x. 2 root 2000 0 Aug 7 2018 vendor -rw-r--r--. 1 root root 524 Aug 7 2018 verity_key drwxr-xr-x. 2 root root 0 Aug 7 2018 version
Attachments
-
55.8 KB Views: 144
Last edited: