Introduction / Why This Is Needed
Root access (superuser) on Android provides unlimited opportunities for customization and system management. However, it also has significant drawbacks: voiding the warranty, security risks, incompatibility with banking apps and services (Google Pay, Samsung Pay), and issues with receiving official OTA updates. This guide is intended for those who have decided to return their device to its "factory" state, remove all traces of root, and once again fully use all services. We will cover two main methods: a soft removal (for Magisk) and a full one (with reflashing).
Requirements / Preparation
Before starting, complete the following mandatory steps:
- Backup. All data on the device will be erased. Make a backup via Google Drive, to a computer, or to another cloud service.
- Battery charge. The battery level should be at least 80%.
- Computer with ADB/Fastboot. On your PC (Windows/Linux/macOS), you must have Android SDK Platform-Tools installed.
- Drivers. For Windows, install the correct USB drivers for your device (usually provided by the manufacturer or via PC Suite installation).
- Exact stock firmware. Find and download the exact version of the official stock ROM for your specific model and regional variant (e.g., for SM-G991B, not for SM-G991U). Use sources:
- Official manufacturer websites (Samsung, Xiaomi, etc.)
- Trusted communities (XDA Developers).
- Important: The firmware must be unofficially unlocked if your bootloader was unlocked. Usually, the filename includes the tag
unlockedorENG.
- Unlocked bootloader. To flash stock ROM, the bootloader generally must remain unlocked. If it was locked, the process may become more complicated.
Step-by-Step Instructions
Step 1: Remove Magisk and Modules (Soft Method)
If you obtained root only through Magisk (without modifying the system partition), this step may be sufficient for many apps.
- Open the Magisk Manager app.
- Tap the three dots in the top right corner → Settings.
- Scroll down and select Uninstall Magisk.
- In the window that appears, choose Restore Images. Magisk will attempt to restore the original boot and system images.
- Confirm the action. The device will reboot.
- After reboot, the Magisk app will be gone. Ensure it is not in the list of installed apps.
⚠️ Important: This method does not remove traces in the
systempartition (if Magisk was installed in "Systemless Hostless" mode). For a complete cleanup from all traces (especially for banking apps), a full reflash (Step 2) is almost always required.
Step 2: Full Reflash with Stock ROM (Guaranteed Method)
This is the primary and most reliable method, which completely erases all system modifications.
- Boot into Fastboot (Bootloader) mode.
- Power off the device.
- Hold the key combination (usually Volume Down + Power) to enter Fastboot/Bootloader mode. Text and the Android logo will appear on the screen.
- Connect the device to the computer via a USB cable.
- Check the connection. On the computer, open a terminal (cmd/PowerShell) and run:
You should see your device's serial number. If not — install drivers or try a different cable/port.fastboot devices - Extract the downloaded firmware archive. Inside, you will typically find files with the
.imgextension (images) or a ZIP archive for flashing via recovery. - Choose the flashing method:
- Method A (Recommended, if separate
.imgfiles exist): Flash the images in the correct order. Most commonly:
Order matters! Follow the instructions accompanying the firmware.fastboot flash boot boot.img fastboot flash recovery recovery.img # optional fastboot flash system system.img fastboot flash vendor vendor.img # for newer devices fastboot flash userdata userdata.img # or just erase - Method B (Via Fastboot update): If the archive contains a single large ZIP file (e.g.,
update.zip), copy it to theplatform-toolsfolder and run:fastboot update update.zip - Method C (Via Recovery): If the firmware is meant for installation via Recovery (TWRP), copy the ZIP file to internal storage or an SD card. Enter Recovery (usually Volume Up + Power), perform a wipe (Data/Factory Reset), then Install and select the ZIP file.
- Method A (Recommended, if separate
- Data wipe (if not done automatically). After flashing, perform a full wipe of user data:
This ensures old data and cache do not affect the new system.fastboot erase userdata fastboot erase cache - Reboot. Run:
The device will reboot into the newly installed stock ROM. The first boot may take 5-10 minutes.fastboot reboot
Step 3: Lock the Bootloader (To Return to Full "Stock")
After successfully reflashing, you can (and often should) lock the bootloader to fully restore warranty and stock compliance.
- Re-enter Fastboot mode (as in Step 2.1).
- Connect the device to the computer and ensure
fastboot devicessees the device. - Run the command:
Or, for some devices (e.g., newer Google Pixel):fastboot oem lockfastboot flashing lock - A warning will appear on the device. Use the volume buttons to select Yes and confirm with the power button.
- The device will reboot and start the bootloader locking process. After this, the bootloader will be locked, and you will not be able to flash arbitrary images without official permission.
⚠️ Caution: Bootloader locking is irreversible on most consumer devices. After this, you will not be able to unlock it again using standard methods. If you plan to use custom ROMs or root again in the future — skip this step.
Verification
- Root check. After fully setting up the device, install the Root Checker app from Google Play. Run it. If everything was done correctly, you will see the message: "No root permissions found" or similar.
- SafetyNet/Play Integrity check. Install the Play Integrity API Checker or YASNAC app. Run the check. A successful result is
MEETS_BASIC_INTEGRITYandMEETS_STRONG_INTEGRITY(orDEVICE_CERTIFICATION). If you seeMEETS_BASIC_INTEGRITYbut notSTRONG— there may be remnants in thevendorpartition or an unofficial firmware is in use. - Build check. Go to Settings → About phone → Build number. The end of the line should not contain words like
magisk,root,test-keys, or similar. It should sayrelease-keys. - Update check. Go to Settings → Software update. The system should check for OTA updates from the manufacturer.
Potential Issues
- Device stuck on logo (Bootloop).
- Cause: Incorrectly flashed firmware (wrong model/region), corrupted archive, interrupted flashing process.
- Solution: Re-enter Fastboot/Recovery and reflash the correct stock ROM. Ensure the firmware matches your exact model (e.g.,
SM-G991Binstead ofSM-G991U).
- Error
fastboot: command not foundordevice not found.- Cause: Platform-tools not installed/not in PATH, missing drivers, incorrect cable/port.
- Solution: Reinstall Android SDK Platform-Tools, add the
platform-toolsfolder to the system PATH variable (Windows) or use the full path tofastboot. For Windows, install drivers viaandroid_winusb.inffrom theextras\google\usb_driverfolder inside the SDK, or use universal drivers (e.g., from PDAnet). Try a different USB port (directly on the motherboard, not through a hub).
- Error
FAILED (remote: 'device is locked')when trying to flash.- Cause: Bootloader is locked, and you are trying to flash an unofficial image.
- Solution: Either unlock the bootloader using the standard method (if the manufacturer allows it), or find an officially signed stock ROM intended for a locked bootloader (often OTA updates in ZIP format for Recovery). Sometimes flashing via official Recovery (e.g., Samsung Odin) works.
- Apps still detect root after a full reflash.
- Cause: An unofficial (custom) stock ROM was used, which already contains modifications. Or an issue in the
vendor/productpartition (for Android 10+). - Solution: Find an official firmware from the manufacturer's website. Ensure you flash all partitions, including
vendorandproduct. As a last resort, try flashing firmware for a different but adjacent regional variant (e.g., for Europe instead of Russia), then update back to your own via an official OTA.
- Cause: An unofficial (custom) stock ROM was used, which already contains modifications. Or an issue in the
- Cannot lock the bootloader (
fastboot oem lockdoes not work).- Cause: Some manufacturers (Samsung, Xiaomi on some models) use proprietary commands or require confirmation in a special menu on the device itself.
- Solution: For Samsung, use
fastboot oem lock-goor go to developer options and use the "OEM Unlock" toggle (to lock). For Xiaomi, you may need to enter a code in the dialer (*#*#717717#*#*) or use Mi Flash with the "Erase and lock" option. Research your specific model on XDA Developers.