The following step needs to be done only once per device. Unlocking the bootloader will erase all the data on your device Before proceeding, make sure to back up the data you wish to keep on your PC and/or your Google Account or equivalent.
Create a Mi account on the Xiaomi website. An Mi account is required to unlock the bootloader. Beware that an account is allowed to unlock a unique device every 30 days.
Add a phone number to your Mi- account.
Insert a SIM into the phone.
Enable the developer options in Settings> About Phone by repeatedly tapping MIUI Version.
Connect the device to your Mi account in Settings>- Additional settings> Developer options> Mi-Unlock status.
Download the Mi Unlock- app (Windows is required to run the app).
Run the Mi Unlock app & follow the instructions provided by the app. The app may also tell you that you have to wait for up to 30 days. In this case, wait for the indicated period of time before continuing to the next step.
After the device and the Mi account have been successfully verified, the bootloader must be unlocked.
Since the device completely resets, you will need to re-enable USB debugging to continue.
Install a custom restore via fastboot
Download a custom recovery: you can download TWRP. Just download the latest recovery, called something like twrp-xxx-x-dipper.img-.
Connect your devices to your PC via USB. On your computer, open a command prompt (on Windows) or terminal (on Linux or macOS) window and type: adb reboot bootloader. You can also start the quick start mode via a combination of keys: with the device off, press and hold Volume Up + Power.
Once the device is in quick start mode, check that the PC sees it by typing: fastboot devices.
Install the recovery on the device by typing: fastboot flash recovery <recovery_filename>.img. The file may not be identified identically to what you see in this command, so adjust it accordingly.
Now restart the recovery to verify the installation: with the device turned off, hold Volume Down + Power until the Xiaomi logo appears, then release Power for a second and press again until the recovery is displayed.
Alternatively, on some devices and recovery you can use fastboot to boot: fastboot boot <recovery_filename>.img.
The file may not be identified identically to the one found in this command, so adjust it accordingly.
Download and install Lineage OS 17.1 on Xiaomi Mi 8 (Android 10)
Download the LineageOS installation package you wish to install. Optionally, download packages of additional applications such as Google Apps (use the arm64 architecture).
If you are not in the recovery phase, restart in recovery: with the device turned off, hold Volume Down + Power until the LG logo appears, then release Power for a second then press it again until the recovery is displayed.
Now tap Wipe.
Now tap on Format Data and continue with the formatting process. This will remove the encryption and delete all the files stored in the internal memory.
Return to the previous menu & tap Advanced wipe, then select the Cache and System partitions, then scroll to wipe.
Reload the LineageOS.zip package: on the device, select “Advanced”, “ADB sideload”, then scroll to start the lateral transfer. On the host computer, upload the package via sideload: adb sideload filename.zip. If you want to install add-ons, run adb reboot sideload, then adb sideload filename.zip the packages in sequence.
If you want Google Apps on your-device, you must follow this step before starting LineageOS for the first time!
After installing everything successfully, run ‘adb reboot’. Depending on the restore used, you may be asked to install additional apps and services. We strongly recommend that you opt-out of installing these, as they may cause your device to start, as well as attempting to access or damage your data.