( probably works with other redmis too, but ull have to change some shit with firmware and whatnot )
i recently rooted my phone and installed lineageos so making this guide i guess ( huge credits to ducky, a person on the linux gang discord server, who has helped me a lot through all of this )
warning this will void ur warranty and this worked for me, i cannot guarantee anything for ur device, make sure both magisk and lineageos support ur device
- lineageos supported devices : https://wiki.lineageos.org/devices/
- magisk supported devices : theres no such list, but if lineageos supports it ur probably good, although i would recommend asking ai, looking stuff up and / or consulting others for guidance
requirements :
- at least 1 computer
- windows ( required for unlocking the bootloader )
- linux ( for everything else, although can b done on windows too, just easier on linux lol and as im a linux user this has more resources on that )
- a xiaomi redmi 8 phone which is supported by lineageos ( this guide might work with other redmis, but u will have to make changes in firmware and stuff u download )
( u might want to dualboot or spin up a vm if u have access to a singular computer )
by reading further u take full responsibility for anything that might happen to ur device and want to see the tutorial
# abstract
this tutorial walks through the process of enabling developer options on a redmi 8 device, unlocking the bootloader using the official mi unlock tool, then through the process of installing lineageos through recovery, patching the boot image using magisk and installing it so u can have a rooted lineageos system, i also cover the process of recovery in case of a failed installation
this guide is for redmi 8 mainly, although if ur using it as a resource for other redmis make sure to change out redmi 8 specific parts like partition flashing, roms, etc
# part one -- developer options
first u will have to enable developer options before doing anything, u might have to repeat this step multiple times during the process of this tutorial
- to to settings
- go to miui version
- spam click til it says 'u are now a developer'
now :
- go to settings home
- go to additional settings
- go to developer options
- enable OEM unlocking
- enable usb debugging
# part two -- host machine setup
i personally used linux for most of this process, but i did have to use windows on my stepfathers laptop for unlocking the bootloader ( mentioned below ), stuff u will need is simple
these tools are usually available as android-tools
in linux, for example the arch linux android-tools package on windows u will probably also require a few usb drivers, although i dont rlly have a clue, on my stepfathers windows 10 pc i had to install
- the drivers from the mi unlock tool ( mentioned below ) by pressing 'install driver' button
- https://www.xiaomidriversdownload.com/xiaomi-usb-drivers-official/
then had to reboot the laptop
but at this step, if ur on windows, ull have to figure out what drivers u need and how to install fastboot
and adb
, everything else should work for both linux and windows
# part three -- bootloader unlocking prep
( edit @ 2023/09/07 )
if u have a mediatek device, u can try out https://github.com/bkerler/mtkclient#unlock-bootloader, this method was tested ( discovered ? ) by once again ducky ( who helped me do all of this android stuff in the first place ), and it works, b aware of https://github.com/bkerler/mtkclient#unsupported-chipsets tho
using this method has these advantages, top one being the most important :
- the 7-day unlock time is bypassed
- no need to remember ur mi acc password as ur not prompted with it
- u can re-lock the device and keep ur warranty so they cant tell that it was ever flashed or unlocked
- no need for a sim card, mobile data or a mi account
and as per disadvantages, ill just leave this quote by ducky himself :
actually, if you're on a mediatek device, absolutely not, in fact, it's objectively better AND easier than the official method
just hold two buttons, plug the cable in, run a command, run another one to reset the device, unpluig the cable, profit
correction: two commands
you still need to wipe data
that's one command
I was being extra safe and I backed up the seccfg partition
but not needed
# official method
xiaomi devices come with a locked bootloader, meaning u have to unlock them, in our case we will use the official mi unlock tool which u can download here which is only available on windows, i have tried everything else, including ( but not limited to ) fucking around with adb and the unofficial mi unlock tool, but nothing worked, so its best u just get a laptop with windows or maybe a vm with usb passthrough, maybe find some better solution that works on linux ( or ur setup ), but idk
after downloading the tool, run it and log into ur account using ur password and phone number ( password will be required later so make sure to note it or something, make sure to not make it very complex because the password will be required to type by hand later ), if u dont have one, make sure to make one
then connect ur phone to ur pc using a usb connection and make sure to allow usb debugging when it prompts u to enable it
then open settings -> additional settings -> developer options and press on 'mi unlock status' and then :
- make sure u have a sim card inserted ( u have to keep it inserted always for it to unlock )
- turn off wifi and enable mobile data
- press add account and device
press agree and follow the instructions
then u will have to wait a painful long while, at least a week if not longer, xiaomi really hates users who want to gain control of their device, it might be anywhere from a week to months, nobody knows, but all u have to do at this stage is
- not log out of the mi unlock tool ( yes u can close it, but not log out, logging out resets everything )
- wait
- check on it semi-weekly ( like every 1.5-2 weeks or so )
# how do u know that u are legible for unlocking ?
well, just repeat the process of running the tool, connecting and whatnot and one day u will see that the 'unlock' button will b available
# part four -- bootloader unlocking
now, as u can unlock the bootloader, dont jump straight into it, make sure :
- u know ur mi account password and it isnt so complex u cant type it by hand
- u have all ur data backed up ( this step will erase all data )
- u dont care about the warranty ( this step will void it )
then, if ur device is ready and all set, press 'unlock', this step shouldnt take long, it should go by pretty quickly and then ull b booted into a stock rom basically
when u boot into it, u will b prompted for ur mi account password to unlock ur phone, enter it and thats it, after this step u will have to repeat the enabling developer options step again
# part five -- lineageos installation
this part might fail, if it does, just see # recovery
now, as ur phone is fully unlocked and set up for lineageos, its time to flash it, for redmi 7a, 8, 8a and 8a dual the rom download page is https://download.lineageos.org/devices/Mi439/builds so grab the latest build from there and extract it, also make sure to download super_empty.img
from the builds page as its not included in the build zip
now, connect ur phone again with usb debugging enabled and fastboot it using this command ( on windows ull probably have to use cmd.exe or powershell or something, not a clue ) :
adb reboot bootloader
extract ur build ( make sure u still have the zip of the build saved, but do extract it ), cd
into the directory, make sure u have the super_empty.img
, then flash the needed partitions for installation through recovery :
fastboot flash dtbo dtbo.img
fastboot flash vbmeta vbmeta.img
fastboot wipe-super super_empty.img
fastboot flash recovery recovery.img
fastboot boot recovery.img
if the wipe-super
command is not found, make sure ur adb is up to date
these commands vary based on what firmware u have, always make sure to consult the lineageos wiki, for example https://wiki.lineageos.org/devices/Mi439/install/variant2
then using volume and power keys go to factory reset -> format data / factory reset and format everything, this will erase everything
after that go back to the home menu of the recovery, press 'apply update' and select 'apply from adb', then use this command to fully install lineageos :
adb sideload lineage-<...>.zip
the zip is the one u downloaded from the builds page
if something fails, try to flash the stock rom first, which is covered in # recovery, after it is all done, proceed to boot into lineageos
# part six -- magisk installation ( rooting )
this part might fail, if it does, just see # recovery
in the extracted lineageos zip there is a boot.img
file, save it on ur phone using adb push boot.img /path/on/to/phones/storage
or anything else u prefer and install the latest magisk app from their releases by downloading the apk then open the magisk app, press install, check both 'patch vbmeta in boot image' and 'recovery mode' checkboxes, press next, press select 'select and patch a file' or something, select the boot.img
and patch it, after its done patching, transfer it back to ur computer using preferred method, i prefer adb pull /path/on/to/phones/storage/magisk_patched-<...>.img .
personally
now fastboot ur phone again, making sure its still connected, then boot the patched image :
fastboot boot magisk_patched-<...>.img
this boot into rooted lineageos, when it boots, go into the magisk app, press 'install' and select 'direct install', when it asks for superuser access, allow it, then itll install
after it installs, u are now free to reboot into ur rooted lineageos system
# part seven -- verifying root
now, after u boot into ur rooted system, verify it, go into magisk and see the 'superuser' tab, if its grayed out, ur phone isnt rooted, if u can access it, then it is rooted, even then, not counting that in, in the 'install section' it should show that u have magisk installed and should show u the version of magisk installed
if it didnt root, maybe proceed to repeat the rooting step or seek community support
and if it did, ur done, enjoy ur new rooted lineageos system :)
# recovery
if lineageos is working, but u borked ur boot image, just fastboot and run this :
fastboot flash boot boot.img
where boot.img
is ur original boot image ( u can get it in the lineageos build zip ), then just reboot
else, if something failed and u only have fastboot access ( meaning u havent bricked ur phone ) its easily fixable :
- download default fastbot rom, for redmi 8 its https://miuirom.org/phones/redmi-8#Global ( older firmware -> fastboot ( currently 4.05 GB tgz file ) )
- extract the tgz using
tar xvf <filename>.tgz
cd
into the directory - make sure ur phone is connected through usb
- run
bash flash_all.sh
- boot into stock rom
and well, if ur phone is in a state where it wont even boot into fastboot, i have nothing to say, best of luck trying to fix it :), a person told me https://new.c.mi.com/global/post/460894 might b helpful in such state