Magisk

Installation

If you already have Magisk installed, it is strongly recommended to upgrade directly via Magisk Manager. The following tutorial is for first time users.

Getting Started

Otherwise, follow the instructions in Knowing Your Device, and choose the right steps

Other notes:

Knowing Your Device

If your device is running anything older than Android 7.1, skip this section as your device will not be using A/B nor system-as-root.

First, you need to know whether your device is using A/B partitions. If you don’t know, use a terminal (adb shell or any terminal emulator) to check with this command:

getprop ro.build.ab_update

If the result is true, then your device is using A/B partitions.

If your device is A/B, then your device is also certainly using system-as-root. To find out whether you are using system-as-root on a non-A/B device, use a terminal to check with this command:

getprop ro.build.system_root_image

If the result is true, then your device is using system-as-root.

(P.S. If you are interested more regarding system-as-root, please check this Twitter thread)

Custom Recovery

If your device has custom recovery support, the easiest way is to install it through custom recoveries, such as TWRP.

Boot Image Patching

You would want to choose this method if either your device does not have custom recoveries, your device is A/B and you don’t want to mix recovery and boot images, or your device is using system-as-root without A/B partitions.

To use this method, you are required to obtain a copy of the stock boot/recovery image, which can be found by extracting OEM provided factory images or extracting from OTA update zips. If you are unable to obtain one yourself, you might be able to find it somewhere on the internet. The following instructions will guide you through the process after you have the copy of boot/recovery image.

Magisk in Recovery

Since some devices no longer use ramdisk in boot images, Magisk has no choice but to be installed in the recovery partition. For these devices, you will have to boot to recovery every time if you want Magisk. Since both Magisk and recovery lives in the same partition, what you actually end up getting when you choose to boot to recovery will be determined by how long you press volume up.

Each OEM and device has its own key combo to boot into recovery. For example on Samsung S10 it is (Power + Bixby + Volume Up), and for Huawei it is (Power + Volume Up). As soon as you press the combo and the device vibrates with a splash screen, the bootloader has already chosen which mode it is booting, either it be boot, recovery, or some OEM specific modes like download, fastboot, or erecovery. After the splash screen, release all buttons to boot into Magisk, since by default recovery mode will boot to the system with Magisk enabled. If you decide to boot to actual recovery, continue to press volume up until you see the recovery screen.

After installing Magisk in recovery:

Important Note: You CANNOT use custom recoveries to install/upgrade Magisk!

Samsung (System-as-root)

If your device is NOT launched with Android 9.0 or higher (released after 2019), you are reading the wrong section.

Before Installing Magisk

Unlocking Bootloader

Normally I wouldn’t provide instructions for this, but since things had changed drastically from previous Samsung devices, and there are some caveats, I figure this would be helpful.

Just when you think the bootloader is unlocked, it is actually not! Samsung introduced VaultKeeper, meaning the bootloader will reject any unofficial partitions before VaultKeeper explicitly allows it.

Instructions

  1. Download the firmware for your device.
  2. Unzip the firmware and copy the AP tar file to your device. It is normally named as AP_[device_model_sw_ver].tar.md5
  3. Install the latest Magisk Manager
  4. In Magisk Manager: Install → Install → Select and Patch a File and select the AP tar file.
  5. Magisk Manager will patch the whole firmware file and store the output to [Internal Storage]/Download/magisk_patched.tar
  6. Copy the patched file to your PC with adb pull /sdcard/Download/magisk_patched.tar. Do not use MTP as it is reported to corrupt files.
  7. Reboot to download mode, and flash magisk_patched.tar as AP in Odin, together with the BL, CP and HOME_CSC files. Never flash only an AP file, as Odin can shrink your /data file-system if you do.
    Important: Uncheck “Auto Reboot” in Options!
  8. Magisk is now successfully flashed to your device! But there are still several steps before you can properly use the device.
  9. We now want to boot into the stock recovery to factory reset our device.
    Full data wipe is mandatory! Do not skip this step.
    Press Power + Volume Down to exit download mode. As soon as the screen turns off, immediately press the combo key to boot to recovery (e.g. on the S10 it is Power + Bixby + Volume Up). Since we want to boot into stock recovery, continue pressing the volume up button until you see the stock recovery screen.
  10. Use volume buttons to navigate through the stock recovery menu, and the power button to select an option. Choose Wipe data/factory reset to wipe the data of the device.
  11. This time, we can finally boot to the system with Magisk. Select Reboot system now, and immediately press the combo key to recovery. After seeing the bootloader warning screen, release all buttons so it can boot to the system.
  12. The device will automatically reboot for the first time it boots. This is completely normal and done by design.
  13. After the device is booted up, do the usual initial setup. The following steps will need an internet connection.
  14. You shall see Magisk Manager in your app drawer; if not, manually install the APK you downloaded in step 3 and continue to the next step. The app would be a stub and it shall automatically upgrade to the full Magisk Manager when you open it.
  15. Magisk Manager will ask to do additional setups. Let it do its job and the app will automatically reboot your device.
  16. Voila! Enjoy Magisk :)

Additional Info

Huawei

Huawei devices using Kirin processors have a different partitioning method from most common devices. Magisk is usually installed to the boot partition of the device, however Huawei devices do not have this partition. Depending on what EMUI version your device is running, the instructions will be slightly different.

Obtain Stock Images

Huawei does not release official factory images, however most firmware zips can be downloaded from the Huawei Firmware Database. To extract images from UPDATE.APP in the zip, you have to use Huawei Update Extractor (Windows only!)

EMUI 8

For EMUI 8 devices, your device has a partition named ramdisk, which is where Magisk is going to be installed.

EMUI 9 or Higher

For EMUI 9+ devices, the ramdisk partition no longer exists. As a workaround, Magisk will be installed to the recovery_ramdisk partition. Please read the Magisk in Recovery section before following the instructions below!

Note: As I tested on my Honor View 10, Huawei’s kernel does not seem to be able to capture key button press events in early boot, so long pressing Volume Up does NOT boot to recovery on my device. Your experience may vary.