This page https://source.android.com/docs/core/ota/apex
apex_payload.img is an ext4 file system image backed by dm-verity. The image is mounted at runtime via a loopback device.
I have installed a debug image on my android device and have used adb root;adb shell to get root access on the android device. When I look at the mounts I see a lot of /dev/block/loop* entries:
/dev/block/loop20 on /apex/com.android.apex.cts.shim@1 type ext4 (ro,dirsync,seclabel,nodev,noatime)
/dev/block/loop21 on /apex/com.android.vndk.v34@1 type ext4 (ro,dirsync,seclabel,nodev,noatime)
If I look at
# cat /sys/devices/virtual/block/loop20/loop/backing_file
/system/apex/com.android.apex.cts.shim.apex
If I look that apex file seems to be a zip file as the document above mentions:
# file /system/apex/com.android.apex.cts.shim.apex
/system/apex/com.android.apex.cts.shim.apex: Zip archive data, requires at least v1.0 to extract
# unzip -l /system/apex/com.android.apex.cts.shim.apex
Archive: /system/apex/com.android.apex.cts.shim.apex
Length Date Time Name
--------- ---------- ----- ----
644 2009-01-01 00:00 META-INF/MANIFEST.MF
1124 2009-01-01 00:00 AndroidManifest.xml
40 2009-01-01 00:00 resources.arsc
1032 2009-01-01 00:00 apex_pubkey
779 2009-01-01 00:00 META-INF/CERT.SF
1722 2009-01-01 00:00 META-INF/CERT.RSA
274432 2009-01-01 00:00 apex_payload.img
57875 2009-01-01 00:00 assets/NOTICE.html.gz
29 2009-01-01 00:00 apex_manifest.pb
884 2009-01-01 00:00 apex_build_info.pb
--------- -------
338561 10 files
I can understand that the apex_payload.img file is an ext4 file image. But the loop20 backing store is the whole zip file ?
I guess I was expecting that the apex_payload.img file would be extracted from the apex zip file somewhere and then that image file would be the backing_file store for the loop20 device. But that doesn’t seem to be the case.
Any insight on how the loop device can mount a zip file and be able to access the apex_payload.img file ?
Thanks
Chris