topjohnwu / Magisk

The Magic Mask for Android
GNU General Public License v3.0
47.77k stars 12.11k forks source link

Problems if system is mounted on /system_root #2104

Closed mauronofrio closed 4 years ago

mauronofrio commented 4 years ago

So, actually on a device with system-as-root and a-only, if you try to flash magisk using a twrp and the system is mounted on /system_root, magisk is not able to unmount it or use it so the flash will end with an error 1 (device or resource busy). So actually the main problem is that magisk for a-only devices is not able to manage system mounted on /system_root . Recovery should use /system_root as main destination of the system mount and then the recovery (twrp in this case) should create a symlink to link /system to /system_root/system, this is needed to allow people to use old script. This is also something driven by google: https://android.googlesource.com/platform/bootable/recovery/+/refs/tags/android-9.0.0_r50/recovery.cpp#1209

This happen on all a-only device that has system as root and the system mountpoint setted to /system_root . Usually this happen when you try to flash multiple zip at the same time and you include a rom and immediately after it magisk, because the rom will leave the system mounted on /system_root so magisk can't be flashed. I will link some devices i'm supporting that has this problem: https://github.com/mauronofrio/android_device_xiaomi_raphael https://github.com/mauronofrio/android_device_realme_RMX1901 https://github.com/mauronofrio/android_device_xiaomi_cepheus https://github.com/mauronofrio/android_device_xiaomi_davinci https://github.com/mauronofrio/android_device_xiaomi_ginkgo https://github.com/mauronofrio/android_device_xiaomi_perseus https://github.com/mauronofrio/android_device_xiaomi_andromeda https://github.com/mauronofrio/android_device_realme_RMX1931 https://github.com/mauronofrio/android_device_realme_RMX1951

Usually this doesn't happen on the a/b devices because the mountpoint is on /system.

Recovery.log: https://pastebin.com/XR7MWkQa

Probable Solution: I think the easiest solution is that before trying to mount system, magisk should unmount system wherever it is mounted and at the end of the script it should unmount system again, in this way it will not have problems if executed after others things and will not create problems for what will be flashed afterwards.

topjohnwu commented 4 years ago

Magisk have very complicate scripts to handle this and works well. It has nothing to do with A only, A/B or anything else, the scripts can already handle all cases without an issue. It is using very custom logic to handle partition mounting as no custom recovery can be trusted.

The issue however in fact lies in the ROM zips as they do not clean up their own stuff after finishing up. Why don't the script unmount stuffs after it is finished?

I will more aggressively unmount stuffs in the scripts. Issue closed as this is not an issue with Magisk itself, but still thanks for letting me know this mess.

mauronofrio commented 4 years ago

Thanks for the answer, usually the stock roms didn't do that and others i really don't know why.