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.

Comments

10
    TO
    tomyo Feb 9, 2019

    Error: Unlock request rejected with code 20036, After %d hours of trying to unlock the device

    What should I do?

    Thanks, awesome to be able to do this under linux. 🙂

      SW
      Shane Warren Author Sep 19, 2019
    YO
    yololegend Jul 23, 2020

    on the mac os command terminal, after entering the command sudo ./MiUnlockTool.sh username password. the terminal wants a password. but i’m not sure what to type

      SW
      Shane Warren Author Jul 23, 2020

      THe password for your useraccount

        YO
        yololegend Jul 23, 2020

        Which user account, I’ve tried the correct password for the Xiaomi account and that doesn’t work.

          SW
          Shane Warren Author Jul 26, 2020

          No the account that you are using on the MacOS, you have set a password for that right?

    AG
    Andre Giuria Jul 29, 2020

    i have problems opening MiUnlockTool.bat, it says theres no identified app to open it, even tho i already installed java like 3 times

      SW
      Shane Warren Author Jul 31, 2020

      Are you on a Linux or on a Mac?

    RA
    Raj Aug 5, 2020

    I can’t add. Account and device

      SW
      Shane Warren Author Aug 9, 2020

      Can you please elaborate?