The forgotten pattern lock on Xiaomi's smartphone is one of the most common problems users face. PIN-If you have a code or a password, you can't always restore the lock pattern with standard methods: the system doesn't offer a hint, and after 5 failed attempts, the device can lock for 30 minutes or even require a factory reset. But where does this key even stay in the phone's memory? And can it be extracted or circumvented without losing data?
In this article, weβll break down the physical location of the file with the pattern lock in Xiaomiβs firmware (and why it canβt just be βdeletedβ through the file manager), as well as all the working ways to unlock it β from official methods through Mi Account to technical solutions using the use of the file manager. ADB We will also focus on the nuances for different models (Redmi Note 12, POCO X5, Mi 11 et al.) and versions MIUI (including HyperOS).
Where is the pattern lock physically stored in Xiaomi?
The pattern lock (like the PIN/password) in Xiaomi is not stored in plain text, instead it uses a hashed value that is written to protected memory areas.
- π /data/system/gesture.key β main file with a hash of the pattern lock (in older versions) MIUI).
- π /data/system/locksettings.db β database with lock settings (in new versions, starting with the MIUI 12).
- π /data/system/locksettings.db-wal and locksettings.db-shm β auxiliary files for the database.
However, simply delete or modify these files will not work: they are in the /data partition, which is encrypted and is only available with root rights. Moreover, even with root rights, modifying the files can damage the system or trigger anti-Rollback protection (on models with a locked bootloader).
β οΈ Note: Pattempts to manually edit locksettings.db on devices with HyperOS (MIUI 14+) may trigger a hardware-based lock due to the new Xiaomi Secure Storage mechanism. This can brick the device permanently.
| MIUI version | Key file | Protection method | Editing capability |
|---|---|---|---|
| MIUI 8β11 | gesture.key | FDE encryption | Possibly with root (risk of damage) |
| MIUI 12β13 | locksettings.db | Encryption of FBE + Keymaster | Partially (TWRP required) |
| HyperOS (MIUI 14+) | locksettings.db + hardware key | Secure Storage + TrustZone | Impossible without an official unlocker |
Since MIUI 12, Xiaomi has implemented hardware encryption (via a Qualcomm TrustZone or MediaTek Secure Boot chip), making manual key deletion virtually impossible. Even if you access files via TWRP, the system will check the integrity of the data when booted and can lock the device permanently.
Official method: unlocking through Mi Account
The safest and most recommended method for Xiaomi is to use a tied Mi Account, which works on all models, including the latest Redmi Note 13 and POCO F5, but requires a few conditions:
- π The device must be connected to the Internet (Wi-Fi or mobile data).
- π± Mi Account must be linked to phone before locking.
- π Find Device must be active in the settings.
- β³ After 5 failed key attempts, wait 30 minutes before using this method.
Instructions for unlocking:
- On the lock screen, tap Forgot the pattern lock? (or Forgot pattern).
- Select Sign in via Mi Account.
- Enter the login and password from the linked account.
- Confirm unlocking via SMS or email (if two-factor authentication is enabled).
β οΈ Note: If you reset your phone to factory settings via Recovery without waiving your Mi Account, the device may be in Activation Lock (requires you to enter account data after resetting.
Make sure your phone is connected to Wi-Fi | Check if your Mi Account is linked to your device | Wait 30 minutes after trying unsuccessfully | Access email/SMS to confirm
-->
Unlocking through Fastboot: for advanced users
If the Mi Account is not tied or you donβt remember the login details, you can try resetting the pattern lock via Fastboot mode.This method is suitable for most Xiaomi models, but requires:
- π₯οΈ Computer with drivers installed ADB/Fastboot and the Mi Flash Tool.
- π Cable. USB Type-C (original or quality).
- π± Unlocked bootloader (newer models may require waiting 7-15 days to unlock via Mi Unlock Tool).
Step-by-step:
- Turn off the phone. Press the Power button + Volume down to enter the Fastboot.
- Connect the device to your PC and check the connection with the command: fastboot devices must display the serial number of the phone.
- Download the firmware for your model (choose the Fastboot version, not Recovery).
- Unpack the archive and launch the Mi Flash Tool. Select the firmware folder and press Refresh.
- At the bottom, select Clean all and lock (this will delete all data but unlock the device).
- Press Flash and wait for the process to complete (5-10 minutes).
β οΈ Important: This method removes all data from your phone, including photos, messages and apps. If encryption is enabled on your device, you may need to enter a password from your Mi Account after you have firmware (even if you donβt remember it).
What to do if the Mi Flash Tool is an βAnti-Rollbackβ error
Recovery Reset: Does it work for the new Xiaomi?
The classic Recovery (Wipe Data) reset method on modern Xiaomi often fails because of its Mi Account binding. However, on some models (e.g. Redmi 9A or POCO M3), this method can help if:
- π No encryption is enabled on the phone (checked in Settings) β Additionally. β Encryption).
- π΅ The device is not tied to the Mi Account or the binding was disabled before locking.
- π οΈ Custom Recovery is installed (for example, TWRP).
Instructions for standard recovery:
- Turn off the phone. Press the Power button + Volume up to enter Recovery.
- Choose a language (if available).
- Go to Wipe Data β Wipe All Data.
- Confirm the reset (some models will require a password from Mi Account).
If after resetting the phone requires you to enter Mi Account data, and you do not remember them, there are two options:
- Contact the Xiaomi backport with proof of purchase (check, box with IMEI).
- Use paid unlock services (like DC-Unlocker or Xiaomi Tool PRO), but it is risky because of scammers.
π‘
If after resetting via Recovery, the phone asks for an old pattern lock, try entering any 4-9 point template β sometimes the system misses it after a hard reset.
Bypassing a pattern lock without losing data: myth or reality
Many users are looking for ways to delete a pattern lock without resetting data, which is theoretically possible, but only works in rare cases:
- For root-right devices: π± Install. TWRP and through it delete gesture.key or locksettings.db files. π§ Use it. ADB with the command: adb shell rm /data/system/gesture.key (works only MIUI beforehand 11).
For devices without root rights:
- π₯οΈ Connect your phone to your PC and try using utilities like Miracle Box or UFi Box (requires skill and risk).
- π‘ On some models (Redmi) 5A, Mi A1) Works through exploit ADB to bypass the lock (but closed in new firmware).
Starting with MIUI 13 and HyperOS, bypassing the pattern lock without losing data is virtually impossible due to hardware protection. Even if you delete the lock files via TWRP, the system will restore them the next time you download or lock the device permanently.
β οΈ Note: Use of informal tools to bypass locking (e.g. Bypass) FRP Tools can lead to: π« Loss of warranty (if the device is under warranty). π Activation of protection against rollback (brick device). π΅οΈ Data theft (many βunblockersβ contain malicious code).
π‘
The only officially supported way to unlock without losing data is to use the Mi Account, which is tied, and all other methods either delete data or risk building the device.
Features of unlocking on different models Xiaomi
The unlocking process may vary depending on the model and firmware version, and the following are key nuances for popular devices:
| Model | MIUI/HyperOS version | Supported Unlocking Methods | Features |
|---|---|---|---|
| Redmi Note 12/13 | HyperOS 1.0+ | Mi Account, Fastboot (with waiting for the bootloader to unlock) | Without Mi Account, unlocking is almost impossible due to Secure Storage. |
| POCO X5/F5 | MIUI 14 / HyperOS | Mi Account, Fastboot, EDL (requires authorization) | Some batches are exploited via ADB (closed in new firmware). |
| Mi 11/12 | MIUI 12.5β14 | Mi Account, Fastboot, TWRP (if installed) | When resetting via Recovery, you may need to enter a password from Mi Account. |
| Redmi 9/10 | MIUI 12β13 | Mi Account, Fastboot, Recovery (sometimes triggered) | Some firmware works by removing gesture.key via TWRP. |
| POCO M3/M4 | MIUI 12β13 | Mi Account, Fastboot, Recovery (with Activation Lock risk) | Often blocked after reset due to linking to the account. |
For HyperOS devices (such as Xiaomi 14 or Redmi K70), the only reliable way to do this is to use Mi Account, and even official service centers will not be able to unlock the phone without proof of ownership.
What to do if nothing helps: service centers and alternatives
If all of these methods don't work, you have to go to the service center, but there are a few things that you can do.
- π’ Xiaomiβs official service centers will require: π Document confirming the purchase (check, warranty card). π± Phone box with indication IMEI. π Data from Mi Account if the device is tied.
- π§ Unofficial services can offer unlocking through: π» EDL Mode (requires an authorized account and paid software). π JTAG (For older models, for example, Redmi 4X). π‘ Server-based unlock (risky, can lead to a block) IMEI).
The cost of unlocking in informal services varies from 1,000 to 5,000 rubles depending on the model. However, beware: some "masters" use methods that:
- π¨ Damage. IMEI (The phone stops catching the network).
- π Activate Anti-Rollback (the device turns into a brick").
- π΅οΈ Installing backdoors for data theft.
Before contacting the service, check the reviews and request a guarantee for work. Official Xiaomi centers in Russia can be found on the support website.
π‘
If the phone is locked on the Activation Lock screen (requires Mi Account data after reset), the official service center will not be able to help without proof of purchase, in which case you only need to contact Xiaomi with a check.