How to Relock Bootloader on Xiaomi Devices?

In the custom development scene, OEMs like Xiaomi, Mi, Poco, and Redmi are among the most popular names. From flashing custom ROMs and recoveries to gaining administrative privileges, you can do it all.

However, there is also another side of the coin and it could put you in all sorts of trouble. If you end up tripping the SafetyNet, you will no longer be able to use banking and payment apps. The only way to overcome such roadblocks is to relock bootloader on Xiaomi, Mi, Poco, or Redmi devices.

If you’re looking to know how to do that, then this guide will be helpful. In this guide, you will get to know how to relock bootloader on Xiaomi devices.

Steps to relock bootloader on Xiaomi devices?

Relock Bootloader on Xiaomi

Step 1: Remove all modules

Your first course of action will be to remove the modules installed on your device. Modules like Magisk mods, LSPatch, LSPosed, etc. must be removed.

  • For LSPosed: You should launch LSPosed -> Head over to Modules -> Long press on the module and select “Uninstall”
  • For Magisk: You should launch Magisk -> Head over to Modules -> Tap on Remove next to the module
  • Moreover, you should also remove any rooted apps that may impact the system components such as Viper4Android. Once you’ve removed the modules, you need to restart your device so that the changes can take place. Your device will get rebooted to the rooted environment but with the mods disabled.

Step 2: Unroot your Xiaomi device

  • Launch the Magisk app and then tap on “Uninstall Magisk”
  • After that, tap on “Complete Uninstall” and wait until the process gets completed
  • Once it is done, press Reboot
  • Your smartphone will be rebooted to the non-rooted OS

Step 3: Remove TWRP Recovery

If you have flashed the TWRP in the recovery partition, you should flash the stock recovery.img and it’ll get the job done. Meanwhile, if you flashed it in the boot partition, you will need to flash boot.img and a few other files like vendor_boot and dtbo. If you aren’t sure of the partition to which you flashed TWRP, then here are the steps to follow –

  • First, you should download and extract Android SDK Platform Tools on your PC
  • After that, download the Fastboot ROM before extracting the files onto your PC
  • Next, you should extract the partition to which you had flashed the TWRP Recovery
  • Place the files in the platform-tools folder
  • Connect your smartphone to the PC using a USB cable and make sure that USB debugging is enabled
  • Go to the platform-tools folder and type in CMD in the address bar before hitting Enter to launch the Command Prompt
  • Now, type the following command in the CMD window for booting your device to Fastboot Mode –
adb reboot bootloader
  • For verifying the Fastboot connection, you should type the following command and you’ll get back the device ID –
fastboot devices
  • If you aren’t getting any ID, then you should install the Fastboot Drivers on your PC
  • Flash the stock files to their respective partitions –
fastboot flash boot boot.img

fastboot flash dtbo dtbo.img

fastoot flash vendor_boot vendor_boot.img
  • Once done, you must reboot your smartphone to the OS using the following command –
fastboot reboot

Step 4: Relock bootloader on Xiaomi device using Mi Flash Tool

Now that you’re in a completely non-rooted stock ecosystem, you can proceed ahead and relock the bootloader on your Xiaomi device. It is recommended that you should flash the same software that was previously installed on your device to avoid Anti Rollback Protection.

Step 5: Check the results

Once you have carried out the necessary steps to relock bootloader on Xiaomi device, now comes the time to check the result. While there are multiple ways to verify if your attempt to relock bootloader on Xiaomi devices was successful or not, the easiest way would be using the Developer Options. Go to Settings -> Developer Options -> OEM Unlocking. The OEM Unlocking option should be set to Allow the bootloader to be unlocked, which will signify that your attempt to relock bootloader on Xiaomi device was successful.

Aviral Sharma
Aviral Sharma
Android Expert
Aviral Sharma is a talented and passionate writer who has been using words to express his thoughts ever since he learned how to hold a pen. He is passionate about outer space, history, sports, and most importantly, technology. Aviral has been a regular writer for rootmygalaxy for over 6 years and has been covering games and Android guides. He currently owns a Samsung Galaxy S24 Ultra, an iPhone 13, and a HP Pavilion laptop.

Leave a Comment