Magisk is the most comprehensive rooting tool to date, though installing it is generally more effort as well. The general idea behind what is currently the most common rooting method is to get past SafetyNet so you can still use the root apps or modules you love but without getting Google angry in the process. Provided Google is happy with proceedings, this rooting method is likely to stand the test of time and remain relevant much longer than SuperSU.
The most common method for installing Magisk is with a custom recovery image (TWRP today); however, you can install Magisk without TWRP as well. Many people would like to get root access with Magisk without a PC, but it’s not possible yet. Most people won’t have trouble rooting with Magisk via TWRP but some people will need to learn how to get the boot.img for Magisk before they start the tutorial. Once you have gotten root access with Magisk, you will need to know where Magisk modules are stored as they are the modern method for customizing your device.
Thought it would be nice, there is no one universal tutorial that can show everyone how to get root access with Magisk. Given the length of the steps required, some of them invariably need slight altering depending on the device; some specific firmware tool versions are also recorded as being more reliable for certain versions of Magisk as well, et cetera, which means you should always look for a specific tutorial for the smartphone you have. That being said, here are the general guidelines for installing Magisk with TWRP on a smartphone:
1. Unlock the bootloader. This requires a tutorial in itself and the method to unlock varies between manufactuers and perhaps even model numbers, so be sure to look up the right guide for your smartphone. We have many unlock bootloader tutorials ourselves.
Note: When Magisk is installed, note the Ramdisk, A/B, and SAR values.
3. You now need to patch the boot image. To do that, you need the boot image from the firmware you download. Generally, you should download the latest firmware. The method for doing this varies between manufacturers once again — Samsung, for instance, has free Samsung firmware updating tools that allow you to download the latest files directly from Samsung’s servers to your PC.
Note: For most, the boot image is easily located inside the firmware file. However, if you have a firmware file that used the A/B partition scheme, you will need to extract the payload.bin file to locate the boot image. To extract a paylod.bin file, you need a specially developed payload.bin unpacker.
4. Once you have the boot image, you are ready to patch it. Copy the boot image to the smartphone. Press Install on the Magisk card. And select Select and Patch a File as the Method and then upload the boot image to this location. Wait for the boot image to be patched by Magisk.
Note: Samsung smartphones must copy the AP tar file to the smartphone and install it in Magisk. Samsung smartphones without a boot ramdisk need to check Recovery Mode in Magisk’s options. Follow the same method as step 4 to upload the file to Magisk but upload the AP file to this location instead of the boot image. Copy the patched tar to the desktop. Reboot the Samsung smartphone to Download Mode. Download and open Odin and flash the patched tar via the AP field and use the BL, CP, and CSC from the original firmware. Ensure to reboot to Recovery Mode if the Samsung smartphone has no ramdisk. Install the Magisk app. Let Magisk complete the process and wait for the smartphone to automatically reboot.
5. Open Magisk again and check that there is a number next to the Installed paramter. This ensures Magisk has rooted your smartphone.
In conclusion, that is how to install Magisk on smartphones that run the Android operating system.