How to Unroot Android and Relock the Bootloader (2026 Guide)
To unroot Android, you remove the root tool (usually Magisk) and put the phone’s original boot image back. Unrooting alone usually keeps your data. To make the phone fully stock again, so that banking apps and Google Wallet trust it, you also flash official firmware and relock the bootloader, and relocking erases everything on the phone. This guide covers Magisk, KernelSU and APatch, then relocking on Pixel, Samsung, Xiaomi and other phones.
Unroot vs Relock: What Each Step Does
| Step | What it changes | Your data |
|---|---|---|
| 1. Remove root | Removes su, root apps’ access and modules. The bootloader stays unlocked. | Usually kept |
| 2. Flash stock firmware | Replaces every modified partition with official software. | Often erased (depends on brand and options) |
| 3. Relock the bootloader | Turns verified boot back on, so the phone only starts officially signed software. | Always erased |
Why step 3 matters: Google’s Play Integrity documentation says that on Android 13 and higher, a phone passes the device integrity check only with hardware-backed proof that the bootloader is locked and a certified factory image is running. Google Wallet’s help page also lists an unlocked bootloader as a reason tap to pay may fail. Removing Magisk alone does not fix this.
Before You Start
- Back up everything. Android’s Verified Boot rules say user data is erased when the bootloader goes from unlocked to locked. See how to back up everything on Android.
- Know which root tool you used: Magisk, KernelSU or APatch.
- Get official firmware for your exact model and region, at the same build as your phone or newer. Google warns that some Pixel updates block older bootloaders: after the May 2025 update on Pixel 6 and Pixel 8 series phones, and the May 2026 update on Pixel 10 series phones, older builds cannot be flashed and booted.
- A Windows, macOS or Linux PC with Google’s SDK Platform-Tools (adb and fastboot) and a working USB driver. See our Android USB driver guide for Windows 11.
- A charged battery and a good USB data cable.
Warning: Relock only when every partition is official. In the locked state, the bootloader accepts only an OS signed with the maker’s key. If anything modified is left (a patched boot image, a custom ROM, a custom recovery or vbmeta), the phone may refuse to boot, and a locked phone cannot be reflashed with fastboot.
Step 1: Remove Root
Magisk
- Open the Magisk app and tap Uninstall Magisk.
- Tap Complete uninstall. Magisk warns that all modules will be removed and root will be removed. When it finishes, the phone restarts without root (restart it yourself if it does not).
- If Magisk shows Stock backup doesn’t exist!, use the manual method below.
Restore images only puts back the stock images Magisk backed up at install time. Magisk uses it before system updates. With a custom recovery, you can also rename the Magisk APK to uninstall.zip and flash it.
KernelSU and APatch
- KernelSU: in the KernelSU manager, open Settings > Uninstall > Uninstall permanently. This removes root and all modules. Uninstall temporarily only lasts until the next reboot.
- APatch: use the Uninstall option in the APatch app. If it fails, use the manual method.
Manual method: flash the stock boot image
This works for any root tool on phones that use fastboot. Do not use it on Samsung (see the note below).
- Extract the stock image from the firmware that matches the build on your phone. Phones that launched with Android 13 or later keep the ramdisk in init_boot.img. Older phones use boot.img.
- Turn on USB debugging, connect the phone and restart it into the bootloader:
adb reboot bootloader - Write the stock image over the patched one. This replaces only that partition and does not erase your data:
fastboot flash init_boot init_boot.imgor, on older phones:
fastboot flash boot boot.img - Restart the phone:
fastboot reboot
Samsung note: Magisk’s documentation says you should never restore the boot, init_boot, recovery or vbmeta partitions to stock on Galaxy phones, because this can brick the device. On Samsung, unroot by flashing the full stock firmware with Odin (Step 2).
Step 2: Return to Stock Firmware
- Google Pixel: flash the latest factory image for your model. Google says installing a factory image erases all data, and asks you to relock the bootloader when the process is complete. Our Pixel factory image guide shows the process.
- Samsung Galaxy: flash the full firmware (BL, AP, CP and CSC) with Odin. The CSC file performs a factory reset. Follow our Odin flashing guide.
- Xiaomi, Redmi and POCO: flash the official fastboot ROM with Mi Flash. You can relock in the same step (see below). Our Mi Flash Tool guide explains each option.
- Other brands: use your phone maker’s official firmware.
Step 3: Relock the Bootloader
Warning: Relocking erases all data on the phone. Do it only after Step 2 has finished and the phone has booted normally on official software.
Google Pixel and most fastboot phones
- Restart into the bootloader with
adb reboot bootloader, or turn the phone off and hold Volume Down while turning it on (Pixel). - Run the lock command. On phones made in 2015 or later:
fastboot flashing lockOn 2014 or older phones:
fastboot oem lock - Confirm on the phone screen with the volume and power keys. The phone wipes itself and restarts locked.
For more commands, see our fastboot commands list.
Samsung Galaxy
Samsung does not publish official relock steps. Developers describe it as the unlock process in reverse:
- Make sure the full, untouched stock firmware is installed (Step 2).
- Turn the phone off and boot into Download mode with your model’s key combination. Android Authority reported that on One UI 8.5, the Galaxy S26 series and Z Fold7 need Maintenance mode turned on first.
- Long-press Volume Up to open the bootloader lock screen and confirm. The phone wipes and restarts.
- After setup, you can turn off OEM unlocking in Developer options.
Magisk’s documentation says Download mode shows OEM Lock: ON (L) on a fully locked phone. Relocking does not reset the Knox warranty bit. Samsung’s Knox documentation says a tripped Knox bit cannot be reverted.
Xiaomi, Redmi and POCO
Xiaomi says an unlocked phone can be relocked by reinstalling the official ROM with the “delete and lock” script, flash_all_lock.bat. In Mi Flash this is the clean all and lock option. Use it only with the official fastboot ROM for your exact model and region. Afterwards, Settings > Developer options > Device unlock status should no longer show “Unlocked”, and the start-up screen should not say “unlocked”.
Check That the Phone Is Fully Stock
- The unlocked (orange) warning screen no longer appears at every boot. Android’s verified boot rules show it only on unlocked phones.
- In the Play Store, open Settings > About and check Play Protect certification.
- Google Wallet lets you set up tap to pay again.
Troubleshooting
| Problem | What to do |
|---|---|
| Banking app or Wallet still refuses after unrooting | The bootloader is probably still unlocked. Google’s advice for devices that fail device integrity is to install the factory ROM and lock the bootloader (Steps 2 and 3). |
| Magisk says “Stock backup doesn’t exist!” | Flash the stock init_boot or boot image with fastboot (manual method), or flash full firmware. |
| Phone loops at the logo after unrooting | The stock image probably does not match your build. Flash the full official firmware. See our boot loop fixes. |
< waiting for any device > in fastboot |
The PC cannot see the phone in bootloader mode. Install the USB driver and try another cable or port. |
| Phone will not boot after relocking | Something non-official was still installed. Contact the maker’s authorised service centre. |
| Samsung Secure Folder still fails | The Knox bit stays tripped. Samsung Community users report “unauthorized changes detected” even on official firmware. |
Related Guides
- Fastboot Commands List Explained (With Examples)
- How to Flash Samsung Firmware with Odin (2026 Guide)
- Mi Flash Tool Latest Version: How to Flash a Xiaomi Fastboot ROM
- Restore Google Pixel XL to Stock / Flash Factory Images
- Phone Stuck in a Boot Loop? Universal Fixes for Android Phones
FAQ
Does unrooting Android erase my data?
Removing Magisk or KernelSU from its app, or flashing the stock boot image with fastboot, normally keeps your data. Flashing full firmware often erases it (on Samsung, the CSC file does), and relocking the bootloader always erases it.
Can I relock the bootloader with a custom ROM installed?
Usually not. A locked bootloader only boots software signed with the maker’s key. Android does allow a user-set key (the “yellow” boot state), but only on phones and ROMs built to support it. For everything else, return to stock first.
Will unrooting restore my warranty?
Not automatically. Samsung’s Knox bit stays tripped for good, and Xiaomi says unlocking the bootloader invalidates the official warranty. Ask your local service centre how they treat a phone that is back on official software.
How do I know if my bootloader is locked?
A locked phone shows no unlocked warning at start-up. On Xiaomi, check Device unlock status in Developer options. On Samsung, Download mode shows OEM Lock: ON (L) when fully locked.
Can I just hide root instead?
Magisk’s FAQ says Magisk no longer handles root hiding. On Android 13 and higher, device integrity needs proof of a locked bootloader, so hiding root does not reliably fix banking apps.
https://droid-developers.com/unroot-android-relock-bootloader/https://droid-developers.com/wp-content/uploads/2026/11/unroot-android-relock-bootloader-featured-1024x538.jpghttps://droid-developers.com/wp-content/uploads/2026/11/unroot-android-relock-bootloader-featured-150x150.jpgHelp & TroubleshootingHow ToRootTo unroot Android, you remove the root tool (usually Magisk) and put the phone's original boot image back. Unrooting alone usually keeps your data. To make the phone fully stock again, so that banking apps and Google Wallet trust it, you also flash official firmware and relock the bootloader,...Fahim MahmudFahim Mahmud[email protected]AdministratorDroid-Developers
Leave a Reply