Owners of Xiaomi, Redmi and POCO smartphones, who actively use root rights, often face an unpleasant situation: after another system update or just reboot, a standard Recovery is launched instead of the usual TWRP. This is due to the built-in MIUI and HyperOS protection mechanism, which checks the integrity of the boot partition and replaces the modified files with the original ones.
The process of returning a custom recovery environment requires understanding the structure of memory partitions and following a strict sequence of actions. If you just try to re-install the archive through Flashtool, the system can re-write it at the earliest opportunity, so it is important not only to install files, but also to prevent automatic replacement.
In this article, we will discuss the proven methods for fixing custom Recovery on a device, you will learn how to properly prepare the file system, what ADB commands to use to block the partition, and how to avoid errors that can lead to a bootloop.
Why does custom recavator fly to Xiaomi
The main reason for the disappearance of TWRP lies in the security mechanism that Xiaomi implements in its shells. The system checks the recovery partition checksums when downloaded. If changes are detected that do not match the system database, a special service (often called βwatchdogβ) forcibly restores the original file from the vendor or system partition.
Users often face this after OTA-Even if you upgraded through the About Phone menu, the installer can wipe the modified bootloader or recovery partition, and it can also cause an accidental reboot in the Update mode, even if the firmware file itself was not downloaded to the end.
There are several scenarios in which a failure occurs:
- π Automatic system updates over Wi-Fi that patches security sections.
- π± Trying to log into Fastboot mode without first blocking the recovery section.
- β‘ Abrupt power outage during background system processes.
It is important to understand that having an unlocked bootloader is a must, but does not guarantee the safety of modifications. Without additional steps to "seal" the partition, MIUI will constantly strive to return to the factory state.
β οΈ Attention: All partitioning activities are risky. If you interrupt the recording process at the time of critical changes, the device can go into Hard Brick mode, which can only be restored through a retrieval process. EDL and authorized account.
Tools and training required
Before you start, make sure you have all the components you need, you need a computer with ADB and Fastboot drivers installed, you can't interact with low-level commands without them, and you need the recovery image file that is compatible with your model and the Android version.
Donβt try to use images from other devices or even from other versions of Android on the same device, for example, a file for Android 13 wonβt work for Android 14 due to changes in partition structure. You should only download files from trusted sources, such as official developer threads on forums. 4PDA or XDA.
βοΈ Firmware readiness check
To work, prepare the following software:
- π» Platform Tools (Platform Tools) by Google.
- π Image recovery.img Or.zip archive for your model.
- π Original or qualitative USB-stable-connection.
Connect your smartphone to your PC in USB debugging mode. If you've previously disabled debugging, you'll need to turn it back on through the Developer Menu. Make sure your computer sees the device by following the adb device command. The list should show a serial device.
Fastboot Flashing Method
The most reliable way to get TWRP back is to record the image directly via Fastboot mode. This method works on most Xiaomi devices, regardless of the shell version. First, turn the smartphone into fast boot mode. To do this, turn off the phone and press the negative volume and power buttons simultaneously.
When the android repair bunny appears on the screen, connect the cable to your computer. Open the console in the ADB tool folder. Enter the fastboot device command to make sure the device is identified. If the serial number is displayed, you can go to the record.
The firmware command is as follows:
fastboot flash recovery recovery.imgOnce you've successfully recorded (the "Finished" message will appear), don't boot into the system in the usual way. If you just hit "Start" or wait for the autoload, the Android system will start and immediately replace the file you just recorded in the factory. You need to immediately boot into Recovery mode.
What to do if the team is not executed?
To get into the receptacle, press the volume plus and power button (or use the fastboot boot recovery.img command for a temporary start, but better flash it). Hold the buttons until the MI logo appears, then release power, but keep the volume up until the TWRP menu appears.
Automatic replacement lock (partition mounting)
It's not enough to simply flash a file, you have to prevent it from being replaced again, and there's a way to mount the recovery partition in read-only mode or use special scripts to protect it, but the most versatile method for modern versions of HyperOS and MIUI 14 is to use Magisk modules or manually lock it through ADB.
If you already have superuser rights, you can use the terminal on the device itself. Open the Termux app or any root terminal emulator. Enter the command to rewire:
su
mount -o ro,remount /dev/block/bootdevice/by-name/recoveryThe exact path to the block may vary depending on the device. -l /dev/block/bootdevice/by-name/. Look for a section marked as recovery.
An alternative and more reliable way is to install a protection module in Magisk. There are modules, such as Disable Recovery Ramdisk or specific scripts for Xiaomi, which create a file marker that prevents the system from touching the recovery partition when booting.
π‘
After installing custom recavator and superuser rights, install the Magisk module right away, which disables the bootloader integrity check to avoid problems with banking applications.
Itβs also worth checking the settings in the TWRP itself. Some versions have a βKeep Recoveryβ or similar option that tries to prevent overwriting, although you shouldnβt rely on it alone.
Solving problems with sections A/B
Modern Xiaomi smartphones (starting with the Redmi Note 8 Pro, Mi 9T and later) use an A/B partition scheme (Seamless Updates).This means that you have two sets of system partitions: slot A and slot B. When you flash recovery, it is important to understand which slot is being written to.
When using the fastboot flash recovery command without specifying the slot, the recording usually occurs in the active slot. However, there may be situations when the system switches to another slot when booting, and there is an old stock Recovery. To avoid confusion, you can explicitly specify the slot:
fastboot flash recovery_a recovery.img
fastboot flash recovery_b recovery.imgThe firmware of both slots ensures that no matter which slot is active, you will have custom recovery.This is especially true if you plan to experiment with firmware or roll back on previous versions of Android.
The table below shows the differences in commands for different partition schemes:
| Type of device | Fastboot Team | Feature |
|---|---|---|
| Old (A-only) | fastboot flash recovery img | One section, the risk of replacement is high |
| New (A/B) | fastboot flash recovery_a img | You need to stitch both slots. |
| Dynamic Partitions | fastboot flash recovery img | The section inside the superimage |
Use of specialized scripts
For those who donβt want to manually prescribe commands every time, the development community has created automated scripts. For Xiaomi devices, Python or Bash-based scripts are popular, which not only flash an image, but also immediately execute commands to block a partition.
One effective method is to use a script that, after firmware, sends a command to rename an executable file within a partition or change access rights, making it impossible to run a regular replacement mechanism, but this requires a deep knowledge of Linux.
A simpler option is to use ready-made ZIP-archives for installation through TWRP (These archives contain an updater-script that prescribes itself to autoload or modify fstab.
Remember that using scripts from unverified sources can be dangerous. Always check the contents of the archive before you launch.
β οΈ Warning: Don't download all-in-one scripts from questionable sites, use proven repositories on GitHub or themes on GitHub. 4PDA, where the code is open to community verification.
Frequent errors and ways to fix them
Even experienced users make mistakes, and one of the most common is trying to flash an image that's meant for another model, which can cause the touchscreen to stop working in the Recovery, and you can't press a single button, and then just flashing the right image through the Fastboot will help.
Another common problem is the Failed to mount /data error, which often happens if you upgrade from Android 11 to 13 and the encryption format changes, so in the TWRP menu, you have to select Wipe -> Format Data and type "yes." This will delete all the data, but restore access to memory.
If the recaveri goes off immediately after the reboot, check if you have Verity Boot mode activated.
fastboot disable-verity
fastboot rebootAlso make sure you have the latest version of TWRP or OrangeFox installed.Old versions may not work properly with Xiaomi's new encryption schemes, which the system perceives as damage and tries to fix by replacing the file.