How to Install Magisk on Xiaomi: A Complete Guide to Unlocking bootloader and TWRP

Installing Magisk on Xiaomi smartphones opens up access to root rights, modifications to system files, and the use of modules that extend the functionality of the device. However, the process requires care, from unlocking the bootloader to firmware custom TWRP and Magisk itself. Errors at any stage can lead to a device โ€œbrickโ€ or loss of warranty.

In this article, we will analyze the current way to install Magisk 26+ on Xiaomi running MIUI 14/15 or HyperOS, including models Redmi Note 12/13, POCO F5/X5, Xiaomi 13/14. Particular attention will be paid to the nuances of unlocking the bootloader through the Mi Unlock Tool, choosing the correct version of TWRP and bypassing the antirollback.

โš ๏ธ Warning: Unlocking the bootloader and obtaining root rights will void the Xiaomi warranty. On some models (for example, POCO F6 with HyperOS), the Anti-Rollback hardware lock may work, making the device unusable. Before you start, check for support for your model on the XDA Developers forum.

Preparation of the device: what to do before unlocking

Before you start installing Magisk, you need to follow a number of mandatory steps, and ignoring them can lead to the inability to unlock the bootloader or โ€œbrickโ€ of the smartphone.

1. Back up your data. Use Mi Cloud or third-party utilities like Swift Backup (requires ADB).

  • ๐Ÿ“ฑ Contacts and communications (export to.vcf)
  • ๐Ÿ“ท Photos and videos (PC or cloud copy)
  • ๐Ÿ”‘ Passwords from Mi Account (if you use synchronization)
  • ๐ŸŽฎ Game saving (via Helium or manual transfer /Android/obb)

2. Check the MIUI/HyperOS version in Settings โ†’ About Phone. Current firmware (e.g. MIUI 15.1.3.0 for Redmi Note 12 Pro+) may require additional steps to bypass Anti-Rollback. If the version is older than 2 years, it is recommended to update via About Phone โ†’ System Update.

3. Make sure you have the original USB Type-C cable (better from the kit). Cheap cables often don't support Fastboot mode, which leads to errors like FAILED (remote: 'unknown command').

๐Ÿ“Š What Xiaomi model do you use?
Redmi Note 12/13
POCO F5/X5
Xiaomi 13/14
Another model

Unlock the bootloader with the Mi Unlock Tool

Unlocking the bootloader is a must-have step for installing Magisk and TWRP. Xiaomi made the process more difficult in 2023 by introducing a 168-hour waiting period for new accounts.

Requirements:

  • ๐Ÿ“ฑ Mi Account linked to the device (not older than 30 days)
  • ๐Ÿ”— Internet connection (mandatory via SIM- card or Wi-Fi)
  • ๐Ÿ’ป PC with Windows 10/11 and Xiaomi drivers (download from official website)
  • ๐Ÿ”ง Developer Mode Enabled and Unlock OEM (Settings โ†’ About Phone โ†’ Version MIUI โ€“ tap 7 times)

Step-by-step:

  1. Download Mi Unlock Tool (version no lower than 5.5.224.30).
  2. Sign in to Mi Account on your phone and unlock tool.
  3. Transfer the smartphone to Fastboot mode: turn off the device, then press Volume down + Power.
  4. Connect your phone to your PC and launch the Mi Unlock Tool. Press Unlock.
  5. If you see the message "Couldn't unlock. Wait for 168 hours", wait for the deadline to expire (7 days).

โš ๏ธ Warning: HyperOS models (e.g. Xiaomi 14) may require additional confirmation via SMS. If unlocking is 99% frozen, reconnect the USB- cable and try again.

What if the Mi Unlock Tool canโ€™t see the device?
1. Check the driver installation via Device Manager (should display "Android Bootloader Interface"). 2. Try another USB-port (preferably 3.0). 3. Disable the antivirus (it can block the connection). 4. Use the original Xiaomi cable.

Installation of custom TWRP Recovery

TWRP

Magisk

MIUI/HyperOS

How to find the right TWRP:

  1. Go to the official TWRP website.
  2. Find your model (e.g. Redmi Note 12 Pro+ is codenamed ruby).
  3. Download the.img file (e.g., twrp-3.7.0_12-ruby.img).

Installation via Fastboot:

  1. Turn your phone into Fastboot mode (Loudness down + Power).
  2. Connect to your PC and execute the command: fastboot flash recovery twrp-3.7.0_12-ruby.img
  3. Immediately after the firmware, go to TWRP, clamping Volume up + Power (otherwise the system will overwrite the Recovery).

โš ๏ธ Warning: Some models (e.g., POCO F5) require that you disable the recovery signature check before you run TWRP:

fastboot flash vbmeta vbmeta.img


fastboot --disable-verity --disable-verification flash vbmeta vbmeta.img

The vbmeta.img file can be extracted from the official firmware via the Mi Flash Tool.

Xiaomi modelCode nameCompatible version of TWRPNotes
Redmi Note 12 Pro+ruby3.7.0_12Requires vbmeta shutdown
POCO F5marble3.6.2_11Supports the A/B section
Xiaomi 13fuxi3.7.0_9I need firmware through fastboot.
Redmi Note 11 Pro+peux3.6.2_10Works with MIUI 14

โ˜‘๏ธ Firmware preparation TWRP

Done: 0 / 4

Magisk firmware via TWRP

Once you install TWRP, you can start Magisk firmware. It is important to use the current version (26.1+), as older builds may not support HyperOS.

Step-by-step:

  1. Download the latest Magisk.zip (not.apk!).
  2. Transfer the file to your phone or flash drive (e.g. /sdcard/Download).
  3. Load to TWRP (Loudness Up + Nutrition).
  4. Click Install โ†’ select Magisk-v26.1.zip โ†’ swipe for confirmation.
  5. After installation, reboot to the system.

โš ๏ธ Warning: If the phone is stuck on the MI logo after the reboot, it was Anti-Rollback.

  • ๐Ÿ”„ Return to TWRP and run the official firmware through Fastboot.
  • ๐Ÿ”ง Try another version of Magisk (like the Canary-Build).
  • ๐Ÿ“ฑ Some models (Xiaomi 13 Ultra) require a patch boot.img via the Magisk App.

On HyperOS devices (such as the Xiaomi 14 Pro), the standard method of firmware Magisk via TWRP may not work.

  1. Remove boot.img from the official firmware.
  2. Patch it with the Magisk App (Install โ†’ Select and Patch a File).
  3. Sweat the patched boot.img through Fastboot: fastboot flash boot magisk_patched.img

๐Ÿ’ก

If after installing Magisk, banking applications (Sberbank, Tinkoff) stopped working, install the MagiskHide Props Config module and activate root hiding for these applications.

Checking the efficiency and eliminating errors

Once you install Magisk, you need to make sure everything works correctly, and there are frequent problems, such as no root rights, reboot cycles, or errors in banking applications.

How to check the installation:

  1. Install Magisk App (unless it is automatically installed).
  2. Open the app and check the status at the top of the screen. It should say "Installed: 26.1."
  3. Click Check SafetyNet. If Passed status is correct, root is correct.

Common mistakes and decisions:

  • ๐Ÿ”ด "Magisk is not installed" โ†’ Reflash Magisk.zip through TWRP or patch boot.img again.
  • ๐Ÿ”ด Cyclical Reboot โ†’ Remove modules in Magisk or stitch clean boot.img.
  • ๐Ÿ”ด Banking applications do not work โ†’ Install Universal SafetyNet Fix module.
  • ๐Ÿ”ด Error "This package is for "rubens" devices" โ†’ You downloaded Magisk for another model. Download the universal version.

โš ๏ธ Warning: Xiaomi may not have MagiskHide for some applications (e.g. Google Pay) with HyperOS.

  1. Activate Enforce DenyList in Magisk settings.
  2. Install the Shamiko module (alternative to MagiskHide).
  3. Clear the application data through Settings โ†’ Applications.

๐Ÿ’ก

If the phone doesnโ€™t turn on after installing Magisk, try booting into TWRP and flashing the original boot.img. 90% of the time, this solves the problem.

Update to Magisk and system components

Once installed successfully, it is important to keep Magisk and TWRP up to date, and updates close vulnerabilities and add support for new versions of MIUI/HyperOS.

How to update Magisk:

  • ๐Ÿ“ฑ Through Magisk App: Settings โ†’ Update โ†’ Install.
  • ๐Ÿ”„ Through TWRP: Download the new Magisk.zip and run it like a regular zip file.

TWRP update:

  1. Download the new version of.img for your model.
  2. Fastboot: fastboot flash recovery twrp-new.img
  3. Reboot to TWRP for verification.

Update MIUI/HyperOS with Magisk:

When you update your system via About Phone โ†’ Update root rights will disappear.

  1. Download the full firmware package (.zip) for your model.
  2. Put it on the phone.
  3. Download to TWRP and run the firmware WITHOUT WIPE (Install โ†’ select zip โ†’ swipe).
  4. Then, you can re-scan Magisk.zip.

โš ๏ธ Warning: On HyperOS, updating via TWRP may result in data loss in /data. Before the procedure, backup via TWRP โ†’ Backup (select Data, Boot, System).

Remove Magisk and restore the original firmware

If you need to return the phone to its original state (for example, for sale or warranty repair), you need to completely remove Magisk and restore the stock firmware.

Methods of disposal:

  • ๐Ÿงน Through Magisk App: Settings โ†’ Complete Deletion (reboots the phone to stock recavator).
  • ๐Ÿ”ง Through TWRP: Sweeve the original boot.img (extracted from stock firmware).
  • ๐Ÿ”„ Through the Mi Flash Tool: Complete Fastboot firmware with clear all and lock.

Restore the original firmware:

  1. Download the official firmware for your model (choose Fastboot or Recovery).
  2. For Fastboot firmware: miflash unlock --clean_all_and_lock (this will block the bootloader and delete all data!)
  3. For Recovery firmware: transfer.zip to your phone and run through the stock Recovery (Loudness up + Power).

โš ๏ธ Warning: After recovering the stock firmware, you may need to re-assign the Mi Account (especially on HyperOS).If the phone requests an old account after a reset, use the official restore form.

FAQ: Frequent questions about installing Magisk on Xiaomi

โ“ Can I install Magisk without unlocking the bootloader?
No. Unlocking the bootloader is mandatory for installing a custom recovery (TWRP) or firmware patched boot.img. The only exception is the use of vulnerabilities (such as DirtyPipe), but they only work on older versions of MIUI (until 2022).
โ“ Why Google Pay and banking apps donโ€™t work after Magisk is installed?
Banking applications block root-enabled devices due to security requirements. Solutions: Activate MagiskHide (newer versions โ€” DenyList); Install Universal SafetyNet Fix and Shamiko; Hide root for specific applications in Magisk settings.
โ“ How to bypass the 168-hour bootloader unlock timer?
Unofficial methods (such as resetting time through ADB) can result in a Mi Account being blocked, and the only legal way is to wait 7 days or use an account that previously unlocked other Xiaomi devices.
โ“ Can I install Magisk on Xiaomi with HyperOS?
Yes, but the process is more complicated than on MIUI. HyperOS often requires: Patch boot.img instead of firmware through TWRP. Use special versions TWRP (e.g., Xiaomi 14 needs a build that supports dynamic partitions). Disable AVB 2.0 via commands: fastboot --disable-verity --disable-verification flash vbmeta vbmeta.img Before installing, check compatibility with XDA Developers.
โ“ What to do if the phone doesn't turn on after Magisk firmware?
Most likely, there was a conflict with Anti-Rollback or incorrectly stitched boot.img. Try: Load in TWRP and flash the original boot.img. If it does not help - flash the full stock firmware through Mi Flash Tool (choose clean all). For models with HyperOS, you may need to roll back to MIUI through EDL- mode (requires an authorized Xiaomi account).