Originally Posted by diplomatic
Get full root with Magisk on a locked bootloader!
A major new development in MTK rooting is here. Now you can have Magisk on locked down devices! It runs entirely from the data partition: no need to modify boot or system. Any app that wants root access can have it. All Magisk Manager features are there as well.
Now for the not-so-fine print: Read this whole post before starting. Only use this on devices on which you can recover the firmware through an outside channel such as recovery mode, download tool, etc. It's still unclear how safe this is to run on locked devices. After launching this system, there is still significant potential to brick your device. While precautions have been taken to block modifications to the boot partition, not everything has or can be accounted for. You must anticipate when a superuser action might alter your boot or system partitions and avoid doing that command. Do not try to update Magisk through Magisk Manager's Direct Install!... Even though testing has shown that that feature will fail, it might succeed with future versions of MM or on specific devices.
A device compatible with mtk-su
mtk-su R15 (R17 for Pie) or higher
Magisk not installed on device
Familiarity with the Thanks button
Cannot modify boot partition unless bootloader is unlocked
Cannot modify system/vendor partitions unless boot partition is altered
Only Magisk versions up to 18.1 are currently supported--Magisk 19.x has lost the required 'magisk --startup' functionality
Your mileage may vary with Android 9
DOWNLOAD (UPDATED 2019-07-29)
My Magisk modules will not load properly. What is going on?
- Make sure you meet all the requirements, including the last one.
- Download and install the init.d scripts support app. (Support the developer.)
- Make a folder named 'init.d' on your internal storage. Also make a 'bin' folder inside 'init.d'. Set up the init.d app up like this:
Remember that the folder structure has to be exactly as described, unless you manually edit the path in the script. You can also, in principle, use a different app if you want, but in that case you have to edit the package name path in the script as well.
- Try to acquire root privileges: unchecked
- Run scripts at boot time: checked
- Execution delay: No delay
- Selected folder: /storage/emulated/0/init.d
- Execute all files: unchecked
- Download and install the Magisk Manager apk. For Android 9, the highest version that will work is 7.1.1. The latest version should be usable for Android 8.x and lower, but 7.1.1 may be better in all cases.
- In MM, go to Settings, Update Channel, Custom, and enter this URL: https://raw.githubusercontent.com/to...88/stable.json . This will freeze the update version of Magisk at 18.1. That's necessary for MM to create the right environment for Magisk modules to work.
- Download the current su-boot script, unzip it, and put suboot.sh inside your /sdcard/init.d folder.
- Download the current mtk-su zip and put your appropriate mtk-su file in your /sdcard/init.d/bin folder.
- Download the Magisk 18.1 zip (not 19.x or higher). Extract the arm/magiskinit file and move it to your /sdcard/init.d/bin folder. That is the only file you will need from that zip. (Support the developer.)
- Now you should be ready to launch the Magisk backend. Either reboot or tap 'Run scripts now'. The process will take a few seconds before telling you that 1 script has finished. If it ran successfully, last execution result will show something like this:
That output was made by the latest mtk-su & suboot script. If you get a different result, then something may have gone wrong.
UID: 0 cap: 3fffffffff selinux: permissive
source type magisk does not exist
Error in: allow magisk (null) (null) (null)
client: launching new main daemon process
- At this point, you should be able to run 'su' or do a root request from an app and get a prompt.
- When you open Magisk Manager, it will prompt you with Requires Additional Setup. On this window, you can tap Yes. This is safe. Make sure that you have done step 5 before doing this.
- Turn off update checking in MM. Never try to do a direct-install Magisk Update on a locked device.
This method can only launch root after the init.d app starts up and runs the script. This is late in the boot cycle. Up to that point, root is not available. Unfortunately, many Magisk modules need to be loaded early in the boot process to work properly. I don't think there is much that can be done about that. (Perhaps a warm reboot would help, but that would cause problems of its own.)
Can I modify or reimplement the suboot script and distribute it?
Yes, absolutely. You may do whatever you want with the suboot.sh script. However, you may not distribute the mtk-su zip or binary. Instead, please ask your users to download the latest release from this thread.
Huge thanks to @mrmazak
for helping me get this up and running on Android Pie