Restore TWRP on Xiaomi after resetting or updating MIUI

After installing the official MIUI update or resetting, many Xiaomi users are faced with the loss of the custom TWRP Recovery. The system automatically replaces it with stock Mi-Recovery, blocking access to advanced functions: backups, root rights or custom firmware installation. You can restore TWRP, but the process requires accuracy - an error at any stage can lead to a "brick" of the device.

In this article, we will understand 3 working method of returning custom recavery: through Fastboot, using ADB And by patching the official firmware, we'll focus on the nuances of the bootloader and Qualcomm-based models. Snapdragon/Mediatek. You will also learn how to avoid loss. TWRP after future updates.

โš ๏ธ Critical warning: All manipulation of the recovery and bootloader will void the Xiaomi warranty.On models with a locked bootloader (e.g. Redmi Note 12 Pro)+ Xiaomi 13T) First, you need to officially unlock through the Mi Unlock Tool. TWRP impossible.

Why does TWRP disappear after MIUI update?

The reason lies in the protection mechanism of Xiaomi: stock firmware MIUI contains an anti-rollback script, which when you install an update via OTA or Mi Flash Tool automatically replaces custom recovery with the original.

  • ๐Ÿ“ฑ Installed. TWRP via Fastboot previously;
  • ๐Ÿ”„ Updated through System Update in Settings;
  • ๐Ÿ”ง Performed a reset (Wipe Data) through stock Recovery.

On some models (e.g. POCO F5 or Redmi K60), the script works even when manually firmware is running through TWRP, unless you disable the signature verification (dm-verity), the solution is to patch the firmware image before installation or use modified versions of the MIUI from the community (e.g. MIUI EU).

โš ๏ธ Note: On devices with Dynamic Partitions (all Android models) 10+) standard installation TWRP It's a special version of the Recaveri that's supported. super.img.

Preparation: What to do before TWRP recovery

Before starting the procedure, make sure that all the preconditions are met:

Unlock the bootloader via Mi Unlock Tool

Drivers installed ADB/Fastboot (team-tested `adb devices`)

Downloaded the current TWRP image for your model (from the site [twrp.me](https://twrp.me)

Backup of data (photos, contacts, messages)

Battery charge โ‰ฅ 50%

Mi Account and Factory Reset Protection (FRP)

-->

To check the status of the loader, perform at the terminal:

adb reboot bootloader


fastboot oem device-info

If you see Device unlocked: true, you can continue. Otherwise, unlock the bootloader through the official Mi Unlock Tool application (requires a Mi Account binding and waiting 7-168 hours).

๐Ÿ”น Important for owners POCO/Redmi 2023โ€“2026 On new models (e.g., on new models, POCO X6 Pro or Redmi Note 13 Pro+) Xiaomi has tightened its protections:

  • ๐Ÿ”ง Use OrangeFox Recovery instead of TWRP (Best Compatibility with Dynamic Partitions);

Redmi Note 10/11/12 series series

POCO F3/F4/F5

Xiaomi 11/12/13 series

Redmi K40/K50/K60

Another model-->

Method 1: Install TWRP via Fastboot (Universal Method)

This method is suitable for 90% Xiaomi devices with unlocked bootloader. You will need a PC with installed ADB/Fastboot downloadable TWRP.img.

Step-by-step:

  1. ๐Ÿ”น Just after the firmware, reboot to the TWRP, Not in the system: fastboot reboot recovery This will prevent the replacement of the Recovery with stock.

If the TWRP disappeared again after the reboot, it means that the firmware has activated anti-rollback. Solution: patch boot.img (see Method 3) or use MIUI EU without protection.

๐Ÿ’ก

On some models (e.g. Xiaomi) 12T) instead `fastboot flash recovery` We need to use the team. `fastboot flash recovery_ab twrp.img` because of the separate structure of the sections (A/B).

Method 2: Recovery of TWRP with ADB Sideload

If TWRP It is still partially working (for example, it is loaded, but does not install it). ZIP-files, you can restore them through ADB Sideload. This is a useful way to do this:

  • ๐Ÿ”„ The device is loaded into the recaveri, but can not flash the image;
  • ๐Ÿ“ฆ We need to update the version. TWRP data-free;
  • ๐Ÿ”ง No access to Fastboot (e.g. broken Volume Down button).

Instructions:

  1. Download the TWRP image in.img format and rename it twrp.zip (yes, the extension should be ZIP!).
  2. Load into the current recavator (even if it is broken) and select Advanced โ†’ ADB Sideload.
  3. On PC, do: adb sideload twrp.zip
  4. Once complete, reboot to new Recovery: adb reboot recovery

โš ๏ธ Note: On devices with Dynamic Partitions (e.g. Redmi Note) 11 Pro+) This method may not work, so use OrangeFox Recovery or go through the file. TWRP via Fastboot with a preliminary patch super.img.

Method 3: Patching the Official Firmware to Save TWRP

If TWRP disappears after each MIUI update, the only reliable solution is to patch the official firmware before installing it, which disables the signature verification (dm-verity) and blocks the anti-rollback script.

Tools required:

  • ๐Ÿ“ฅ Official firmware MIUI for your model (download from the [en.miui.com](https://en.miui.com/download.html));
  • ๐Ÿ› ๏ธ Magisk (for patching) boot.img);
  • ๐Ÿ”ง MTK Bypass or Qualcomm Firehose (for devices on the device) Mediatek/Snapdragon).

Step-by-step process:

  1. Unpack the downloaded firmware (.tgz or.zip format) and find the boot.img file.
  2. Move it. boot.img On your smartphone and patch it with Magisk: Open Magisk โ†’ Install โ†’ Select and Patch a File; Select and Patch a File boot.img And wait for the file to be created. magisk_patched.img.

boot.img

Fastboot

fastboot flash boot magisk_patched.img

TWRP

๐Ÿ”น For devices with Dynamic Partitions (e.g. Xiaomi 13 or XP) POCO F5):

  1. Download MIUI EU or custom firmware with the anti-rollback disabled;
  2. Unpack payload.bin with Payload Dumper.
  3. Replace boot.img and recovery.img with patched versions.
  4. Collect the firmware back and run through Fastboot or TWRP.

Critical information: On HyperOS devices (e.g. Xiaomi) 14 or Redmi K70) standard-patch boot.img Magisk can lead to a looped bootloop. init_boot.img.

๐Ÿ’ก

Main conclusion of the section: The only reliable way to save TWRP โ€” drop out OTA-Updates and only modified updates ZIP-file-recovery.

Frequent mistakes and their solutions

When you restore TWRP, you often have a problem with the typical problems, and we'll look at the most common ones.

Mistake.Reason.Decision
FAILED (remote: 'Flashing is not allowed in Lock State')bootloader lockedUnlock the bootloader via the Mi Unlock Tool (requires a wait of 7-168 hours).
Invalid sparse file format at headerA damaged TWRP image or incompatible versionDownload another image from twrp.me or check the checksum (SHA-256).
The device is loaded into Mi-Recovery instead of TWRPAnti-rollback has been activated after the updateFastboot TWRP and reboot it to Fastboot Reboot Recovery.
E: Unable to mount /data or E: Unknown command [log]Problems with FBE partitioning or encryptionScroll OrangeFox Recovery (best FBE support) or run Format Data in TWRP (data loss!).
The device does not turn on after firmware (brick)Incompatible firmware or bug when patching boot.imgRestore your device via EDL Mode (requires an authorized Mi and Mi Flash Pro account).

๐Ÿ”น Advice for owners POCO/Redmi 2023โ€“2026 If after installation: TWRP The device is loaded into the system, but the recaveri is replaced with a stock one - try it:

  1. Sweep TWRP slot-in (recovery_a and recovery_b):
  2. Turn off automatic updates via Fastboot:

FAQ: Answers to Frequent Questions

Can TWRP be restored without unlocking the bootloader?
No. Xiaomi blocks customized recavator firmware at bootloader level. Without official unlocking through Mi Unlock Tool, TWRP installation is impossible. Except for devices with vulnerabilities in the bootloader (for example, some models of 2018-2019), but for modern smartphones this method is not relevant.
Why does the phone not see internal memory after installing TWRP?
This is due to FBE (File-Based Encryption) encryption. Solutions: Enter a password/pattern lock into TWRP (if requested); Use OrangeFox Recovery - it works better with FBE; Run Format Data in TWRP (Warning: delete all data!).
How to check if TWRP is installed correctly?
Load into the Recavatorie (Power buttons) + Volume Up and pay attention to: ๐Ÿ”น Logo. TWRP (Blue robot with TeamWin label); ๐Ÿ”น Possibility of mounting partitions (Mount) โ†’ System, Data, Vendor); ๐Ÿ”น Touch screen operation (some models may not work โ€“ use it) USB-OTG If instead of a mouse TWRP You see Mi-Recovery (yellow robot with Mi) - no Recovery installed.
What if after TWRP firmware, the device gets stuck on the MI logo?
This is bootloop, cyclical reboot. Causes and solutions: ๐Ÿ”น Incompatible boot.img: Stitch the original boot.img via Fastboot; ๐Ÿ”น Patching error: Repeat the patching process through Magisk; ๐Ÿ”น DM-verity problems: In TWRP run the Wipe โ†’ Format Data (deletes all data!), then reflash the firmware. If nothing works, restore the device through the EDL Mode (requires an authorized Mi Account).
Can I install TWRP on Xiaomi with HyperOS?
Yes, but with reservations: ๐Ÿ”น HyperOS requires special versions TWRP supportive init_boot; ๐Ÿ”น Use OrangeFox Recovery or PitchBlack Recovery; ๐Ÿ”น Patching. boot.img Magisk may not work, but it needs to be modified. init_boot.img; ๐Ÿ”น On some models (e.g. Xiaomi) 14) TWRP Not yet supported โ€“ watch for updates on XDA Developers.