Magisk: Support Creating Boot Images with Safe Mode Enabled

Created on 6 Dec 2019  路  6Comments  路  Source: topjohnwu/Magisk

As currently there is no easy way to let users wipe out incompatible Magisk Modules that causes bootloop, and more and more devices no longer have a functional custom recovery that decrypts /data, a mechanism to create a rooted but no-modules-loaded Magisk installation is necessary for a smooth user experience to get out of the bootloop situation.

This feature is currently planned to roll out along with @diareuse's Magisk Manager redesign, so it will be a joint collab effort to make this happen. Please stay tuned for more updates in the future.

P.S. Core Only mode will be rebranded as Safe Mode in the future as the old name is actually pretty confusing.

confirmed enhancement

Most helpful comment

a5d7c41d209527fe7b45a2ef7d031add9b6fad24

All 6 comments

Since the option to create an image with safe mode / core only mode enabled has not yet been implemented, what would be the easiest way to create such an image now?

Since I already have a setup to build Magisk from source and can patch a boot image with it, am I right that just changing bootstages.cpp to replace the checks for DISABLEFILE with hard-coded conditions would be enough?

@alvinhochun That is my impression based on a guide from xda https://forum.xda-developers.com/pixel-3a-xl/themes/magisk-modules-disabler-booting-magisk-t3976625

This was a bit prettier though https://forum.xda-developers.com/showpost.php?p=80991013&postcount=15

I adopted it to create the disable_magisk file:

unpackimg.bat --local .\magisk_patched.img

ramdiskoverlay.dinit.resetmagisk.rc

on post-fs-data
    exec u:r:magisk:s0 root root -- /sbin/init.resetmagisk.sh

ramdiskoverlay.dsbininit.resetmagisk.sh

#!/system/bin/sh
touch /cache/.disable_magisk && reboot
repackimg.bat --local

As currently there is no easy way to let users wipe out incompatible Magisk Modules that causes bootloop, and more and more devices no longer have a functional custom recovery that decrypts /data, a mechanism to create a rooted but no-modules-loaded Magisk installation is necessary for a smooth user experience to get out of the bootloop situation.

This feature is currently planned to roll out along with @diareuse's Magisk Manager redesign, so it will be a joint collab effort to make this happen. Please stay tuned for more updates in the future.

P.S. Core Only mode will be rebranded as Safe Mode in the future as the old name is actually pretty confusing.

Unfortunately, this method with putting overlay.d with a shell script to the ramdisk directory in the image does not work for all devices.
At least not working for Xiaomi Mi 9T, but due to the layout of MIUI boot.img, doubt that it could work on the other Xiaomi devices as well.
Reported at:
https://forum.xda-developers.com/showpost.php?p=82438847&postcount=40
discussion (with the author of the method on the subsequent page), with no solution yet

Btw, proposed an alternative solution (and easier for users than the need for a special Core Only Magisk installation) as the Issue #2756

a5d7c41d209527fe7b45a2ef7d031add9b6fad24

Nice work @topjohnwu didn't even think of that but it's along the lines of my idea anyhow 馃帀

Was this page helpful?
0 / 5 - 0 ratings