Root Xiaomi Mi A2 and Install TWRP Recovery Guide
In this article
Rooting a Xiaomi Mi A2 and installing TWRP recovery allows you to gain administrative access to the Android system, enabling the installation of custom ROMs, system-wide ad blockers, and deep customization of the OS. To achieve this, you must first unlock the bootloader, flash a custom recovery image (TWRP), and then install a rooting solution like Magisk. Note that this process will wipe all user data and may void your warranty.
What You'll Need
- A Xiaomi Mi A2 with at least 50% battery charge.
- A Windows PC with the latest ADB and Fastboot drivers installed.
- A high-quality USB-C data cable.
- The official TWRP recovery image (.img file) compatible with the Mi A2.
- The Magisk APK/ZIP file for rooting.
- A Google account signed in on the device for FRP (Factory Reset Protection) purposes.
Step-by-Step
- Enable Developer Options: On your Mi A2, go to Settings > About phone. Tap on the Build number seven times until a message appears stating that you are now a developer. Note that menu labels may differ slightly depending on your specific Android version or region.
- Enable USB Debugging and OEM Unlocking: Go back to Settings > System > Advanced > Developer options. Locate the OEM unlocking toggle and switch it on. Then, find USB debugging and switch it on as well. These two settings are mandatory for the PC to communicate with the phone's bootloader.
- Unlock the Bootloader: Connect your phone to the PC via USB. Open a command prompt or terminal window in the folder where your ADB tools are located. Type
adb reboot bootloaderand press Enter. Once the device is in Fastboot mode (indicated by the Fastboot logo), typefastboot flashing unlock. You will see a confirmation prompt on the phone screen; use the volume keys to select "Yes" and the power button to confirm. The device will wipe all data and reboot. - Prepare the TWRP Image: Ensure the TWRP .img file is in the same folder as your ADB and Fastboot binaries on your computer. Rename the file to
twrp.imgfor easier typing in the command line. - Boot into Fastboot Mode Again: Restart the phone and hold the Volume Down and Power buttons simultaneously until the Fastboot screen appears. Connect the device to the PC.
- Flash TWRP Recovery: In the command prompt, verify the connection by typing
fastboot devices. If a serial number appears, proceed by typingfastboot flash recovery twrp.img. Once the flash is complete, do not reboot normally. - Enter TWRP Recovery: While still in Fastboot mode, hold the Volume Up and Power buttons together. As soon as the Mi logo appears, release the Power button but keep holding Volume Up until the TWRP menu loads.
- Disable Encryption (Format Data): In TWRP, navigate to Wipe > Format Data. Type "yes" to confirm. This is necessary because the Mi A2 uses encrypted data partitions that TWRP cannot read by default. Warning: This deletes every file on the internal storage.
- Install Magisk for Root: Transfer the Magisk ZIP file from your PC to the phone while in TWRP (you can simply drag and drop the file into the device folder in Windows Explorer). In TWRP, go to Install, select the Magisk ZIP file, and swipe to confirm the flash.
- Final Reboot: Once the installation is finished, tap Reboot System. After the phone boots up, find the Magisk app in your app drawer. Open it and follow any prompts to complete the additional setup.
Common Mistakes
One of the most frequent errors is failing to enable OEM unlocking before attempting to unlock the bootloader. If this toggle is off, the fastboot flashing unlock command will return an error, and the process cannot proceed. Another common mistake is rebooting the system normally immediately after flashing TWRP. On many Xiaomi devices, the stock system will automatically overwrite the custom recovery with the original one during the first boot. You must boot directly into TWRP immediately after flashing it to ensure it sticks.
Users also often forget to format data. Simply performing a factory reset (Wipe > Factory Reset) is not the same as Format Data. Without formatting the data partition and typing "yes", TWRP will likely show 0MB available storage or display folder names as random alphanumeric strings, making it impossible to install the Magisk ZIP file.
Tips
To ensure a smooth experience, always use the original USB cable that came with the device. Third-party cables often lack the data stability required for fastboot commands, which can lead to "device not found" errors or corrupted flashes. If you encounter connection issues, try using a USB 2.0 port instead of a USB 3.0/3.1 port, as some older bootloaders have compatibility issues with newer USB standards.
It is highly recommended to create a full backup of your current system (Nandroid backup) once you enter TWRP for the first time. Navigate to Backup, select the Boot, System, and Data partitions, and swipe to backup. This allows you to restore your phone to its exact current state if a future modification causes a boot loop.
Troubleshooting
If the device is stuck on the Mi logo (a boot loop) after installing Magisk, return to TWRP recovery. The most common cause is a conflict with the current kernel or a corrupted flash. Try wiping the Cache and Dalvik Cache from the Wipe menu and rebooting. If the loop persists, you may need to flash the original boot image of your current ROM version to restore stability before attempting the root again.
If the computer does not recognize the device in Fastboot mode (fastboot devices returns nothing), check your Device Manager on Windows. If you see "Android" with a yellow warning triangle, right-click it, select Update Driver > Browse my computer for driver software > Let me pick from a list of available drivers, and select "Android Bootloader Interface." This manually forces the correct driver to load.
If TWRP fails to boot or the screen remains black, ensure you have downloaded the specific image for the Mi A2 (codename: androidone) and not the Mi A1 or another model. Flashing a recovery image intended for a different hardware revision can lead to a hard brick, which requires specialized tools to fix.
Frequently Asked Questions
Will rooting my Mi A2 stop OTA updates?
Yes, official Over-The-Air (OTA) updates will no longer install automatically because the system partition has been modified. You will need to manually flash updated ROMs via TWRP.
Can I go back to the original factory state?
Yes, you can relock the bootloader and flash the official Fastboot ROM using the Mi Flash Tool to return the device to its original, non-rooted state.
Does rooting drain the battery faster?
Rooting itself does not drain the battery, but the apps you install with root access (like CPU overclockers or custom kernels) can impact battery life depending on their settings.
Is my Google Pay/Wallet still working after root?
Most banking apps and Google Wallet will detect root and stop working for security reasons. You can use Magisk's "Hide" features (Zygisk and DenyList) to attempt to bypass these checks.
Do I need to root my phone to install a custom ROM?
No, rooting and installing a custom ROM are different. You need an unlocked bootloader and TWRP to install a ROM, but you only root the device if you want administrative privileges over the system files.