How is system-as-root mounted in Android 9? In Android 9, system.img consist of system and ramdisk. So kernel will mount system.img directly and implement init program. Next, init will parse init.rc file and mount remaining partitions based on fstab file. But, there is some thing in fstab file that I don't understand :

/dev/block/by-name/system      /      ext4    ro,barrier=1


Here, system is mounted as root in fstab file. I thought that system.img is mount before to execute init program but here, system.img is mouted again. Can someone explain this for me?
init will parse init.rc file and mount remaining partitions based on fstab file.


Not all partitions in fstab are mounted by init on boot. Exemptions include partitions managed by vold and those only meant for recovery mode, raw partitions (not mountable) and root partition.


  There is some thing in fstab file that I don't understand :

/dev/block/by-name/system      /      ext4    ro,barrier=1



That fstab entry is incomplete because it doesn't include fs_mgr flags as per standard format. Complete entry should be like:

/dev/block/by-name/system    /    ext4    ro,barrier=1    wait,recoveryonly


On Treble devices (Android 8 and 9) “devices can specify fstab entries for early mounted partitions using device tree overlays”. An simple explanation can be found here. However “In Android 10 and higher, devices must specify fstab entries for early mounted partitions using an fstab file” and “must place the fstab file in the ramdisk and in the vendor partition”.

DTB is usually appended as blob to kernel binary and fstab entries are exposed in procfs:

~# cat /proc/device-tree/firmware/android/fstab/*/name
system
vendor


So on devices where fstab entries for partitions system, vendor and odm are in Device Tree Blob, init takes no action for these partitions on mount_all because fs_mgr flags include recoveryonly. You can comment out or remove the entry and the device should boot normally.