Where in Xiaomi is stored pattern lock and how to get around it: the full guide 2026

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 versionKey fileProtection methodEditing capability
MIUI 8–11gesture.keyFDE encryptionPossibly with root (risk of damage)
MIUI 12–13locksettings.dbEncryption of FBE + KeymasterPartially (TWRP required)
HyperOS (MIUI 14+)locksettings.db + hardware keySecure Storage + TrustZoneImpossible 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.

πŸ“Š What Unlocking Method Have You Tried Before?
Mi Account
Fastboot
Recovery (TWRP)
I've been to the service.
Never blocked.

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:

  1. On the lock screen, tap Forgot the pattern lock? (or Forgot pattern).
  2. Select Sign in via Mi Account.
  3. Enter the login and password from the linked account.
  4. 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:

  1. Turn off the phone. Press the Power button + Volume down to enter the Fastboot.
  2. Connect the device to your PC and check the connection with the command: fastboot devices must display the serial number of the phone.
  3. Download the firmware for your model (choose the Fastboot version, not Recovery).
  4. Unpack the archive and launch the Mi Flash Tool. Select the firmware folder and press Refresh.
  5. At the bottom, select Clean all and lock (this will delete all data but unlock the device).
  6. 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
On Anti-Rollback devices (e.g. Redmi Note 10 or POCO X3), the firmware of the older version of MIUI will block the bootloader. Solution: 1. Download the newest firmware for your model. 2. In Mi Flash Tool, select the Clean all option (not Clean all and lock). 3. If the error repeats, use EDL Mode (requires an authorized developer account).

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:

  1. Turn off the phone. Press the Power button + Volume up to enter Recovery.
  2. Choose a language (if available).
  3. Go to Wipe Data β†’ Wipe All Data.
  4. 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:

  1. Contact the Xiaomi backport with proof of purchase (check, box with IMEI).
  2. 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:

  1. 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:

ModelMIUI/HyperOS versionSupported Unlocking MethodsFeatures
Redmi Note 12/13HyperOS 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/F5MIUI 14 / HyperOSMi Account, Fastboot, EDL (requires authorization)Some batches are exploited via ADB (closed in new firmware).
Mi 11/12MIUI 12.5–14Mi Account, Fastboot, TWRP (if installed)When resetting via Recovery, you may need to enter a password from Mi Account.
Redmi 9/10MIUI 12–13Mi Account, Fastboot, Recovery (sometimes triggered)Some firmware works by removing gesture.key via TWRP.
POCO M3/M4MIUI 12–13Mi 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.

FAQ: Frequent questions about the pattern lock in Xiaomi

Can I find out the pattern lock through a computer if my phone is connected via USB?
No. Even when connected to a PC, locking data (gesture.key or locksettings.db) is encrypted and not available without root rights. Programs like Dr.Fone or Tenorshare 4uKey promise to "delete the pattern lock," but in practice they either reset the phone to factory settings or don't work on newer versions of MIUI/HyperOS.
I dropped my phone through Recovery, but now it's asking for data from Mi Account.
This is Activation Lock, anti-theft. Solutions: Enter your Mi Account (if you remember). If you don't remember, contact Xiaomi with a check to buy. If you have a hands-on phone, try contacting the previous owner to unbundle your account. Attention: Bypassing Activation Lock through informal methods (e.g., EDL) can lead to IMEI blocking.
Does removing gesture.key via TWRP work on Xiaomi with HyperOS?
No, starting with HyperOS (MIUI 14+), The pattern lock is not only stored in files, but also in hardware storage (Secure Storage). TWRP lead to: πŸ”„ Automatic file recovery when downloading. 🚫 Anti-Rollback (if the firmware is incompatible) is likely to work, and the only way to work is to run a Fastboot full reset (Clean all and lock).
Can you unlock Xiaomi through Google Account like you would on Samsung?
No. Unlike Samsung or Google Pixel, Xiaomi does not support unlocking through Google Account.The only official way is Mi Account.If it is not tied, only Fastboot or Recovery (with loss of data) reset methods remain.
How to protect yourself from losing your phone in the future?
To avoid problems with blocking: πŸ” Attach Mi Account and enable Find Device in Settings. πŸ“ Write down the pattern lock/PIN In a safe place (for example, in Google Keep or 1Password). πŸ”„ Make backups regularly through Settings β†’ System system β†’ Backup. πŸ›‘οΈ Turn off device encryption if you plan to use custom firmware (but this will reduce security).