How to Unlock Xiaomi Devices on Linux and Mac

Owners of Xiaomi devices who want to flash and unlock their devices have the official MiFlashUnlock tool available to them – however, it does not run on Linux. The MiFlashUnlock software can be ran inside Wine or a VM, but there exists a better way.

MiUnlockTool is an unofficial tool based on MiFlashUnlock, which runs natively on Linux (but can also be installed on Mac and Windows). MiUnlockTool is a bridge between fastboot, your Xiaomi credentials, and the Xiaomi server. It retrieves your device info and sends it to the Xiaomi server together with your login token, then checks if you meet all the requirements to receive an unlock key from the server.

The tool will then send the unlock key to your Xiaomi device utilizing a custom build of fastboot. There are no different requirements for receiving an unlock key via MiUnlockTool compared to MiFlashUnlock – you require an authorized Xiaomi account tied to the device through Developer Options.

Requirements

Linux Users

  1. Download the MiUnlockTool, it comes in a .zip file.
  2. Open your terminal and CD to the extracted directory.
  3. In the terminal, type “sudo ./MiUnlockTool.sh”, which will launch the GUI interface. Alternatively, you can use “sudo ./MiUnlockTool.sh username password” for a command-line interface.

Windows and Mac Users

  1. After extracting the .zip file, launch MiFlashUnlock.bat for a graphical interface.
  2. Alternatively you can open a command prompt, CD to the extracted directory, and type “MiUnlockTool.bat username password” for a command-line interface.

 

After you have launched the MiUnlockTool in whatever OS you’re using, connect your Xiaomi device to your computer while it is in Fastboot Mode.

If you launched the GUI mode, follow the on screen directions. If you are using the command-line interface, there won’t be a confirmation request before unlocking, nor will it check if the bootloader is already unlocked.

Troubleshooting

MiUnlockTool device not recognized.
  • If you receive permission errors on Linux or Mac when launching the MiUnlockTool, you need to open a terminal and CD to the extracted directory.
  • Then grant it 777 permissions using “chmod 777 MiUnlockTool.sh” (or MiUnlockTool.command on Mac), which will set the proper permissions.
  • If you have problems launching the tool even with the Sudo command, you can try the command “java -jar bin/MiUnlockTool.jar”.
  • If you encounter errors with JavaFX class not being found, you are missing JavaFX library from your package. Check the OpenJFX package on Linux.

Final Notes

This tool is absolutely safe to use, as is the unlock procedure. Your Xiaomi device will not be damaged, even if the MiUnlockTool attempts an incorrect unlock key.

However, Windows users should probably stick to the official Xiaomi unlock tool. Because MiUnlockTool is a third-party copy built more specifically for Linux users, it can have additional bugs, and Windows will not manage the drivers for example. So MiUnlockTool does work on Windows, its just not recommended.

ABOUT THE AUTHOR

Kamil Anwar


Kamil is a certified MCITP, CCNA (W), CCNA (S) and a former British Computer Society Member with over 9 years of experience Configuring, Deploying and Managing Switches, Firewalls and Domain Controllers also an old-school still active on FreeNode.