[GUIDE] Root Mi 9 Lite / Mi CC9 (with Magisk, no ramdisk)


Hallohannes123

Members
Dec 7, 2021
3
5
A bit of context: The guide on the magisk page does not fully apply to this phone. I had various issues on the way, so this is a guide avoiding every issue I had along the way.
I took the guide from the magisk website, modified it and added notes.




BEFORE YOU START:

If ramdisk shows "yes" only patch and flash boot.img, not recovery.img
You will need to have platform tools/adb installed
To execute adb/fastboot commands open cmd in administrator mode, enter "cd <path to the folder with adb.exe>"

create and run a .bat file with the following code:

Code:
@echo off
reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\usbflags\18D1D00D0100" /v "osvc" /t REG_BINARY /d "0000" /f
reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\usbflags\18D1D00D0100" /v "SkipContainerIdQuery" /t REG_BINARY /d "01000000" /f
reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\usbflags\18D1D00D0100" /v "SkipBOSDescriptorQuery" /t REG_BINARY /d "01000000" /f
pause

!!! FASTBOOT ONLY WORKS PROPERLY WHEN CONNECTING THE PHONE TO USB 2.0 PORTS !!! no idea why...

Disclaimer: Root will break each time you update


Patching Images​


You need the recovery.img and boot.img of your phone:

extracting recovery.img:
Code:
boot to recovery (adb reboot recovery or key combo)

Code:
adb shell
su
#(Don't worry if this shows an error it should work anyways)
Code:
dd if=/dev/block/bootdevice/by-name/recovery of=/sdcard/recovery.img
This extracts the image to INTERNAL STORAGE

extracting boot.img:
Download the Rom file (from xiaomi.eu), unzip and copy boot.img

Patching:
Copy the boot.img and recovery.img to the internal storage of your phone
Boot back into system
Open the Magisk App
Press the Install button
Make sure "Recovery Mode" option is checked
Choose “Select and Patch a File” in method, and select the stock recovery.img
The Magisk app will patch the image to [Internal Storage]/Download/magisk_patched_[random_strings].img.
Rename the file to "magisk_patched_recovery.img"

Open the Magisk App again
Press the Install button
This time make sure "Recovery Mode" option is NOT checked
Choose “Select and Patch a File” in method, and select the stock boot.img
The Magisk app will patch the image to [Internal Storage]/Download/magisk_patched_[random_strings].img.
Rename the file to "magisk_patched_boot.img"

Copy the patched images your PC with ADB
Code:
adb pull /sdcard/Download/magisk_patched_[random_strings].img
Or just move them via USB
Move them into the directory with the adb.exe and fastboot.exe file

Flash patched (rooted) images:
reboot into fastboot mode:
Code:
adb reboot bootloader
or power+ volume down on startup

Flash the patched boot and recovery image to your device.
Code:
fastboot flash recovery magisk_patched_recovery.img
fastboot flash boot magisk_patched_boot.img

Reboot and voila!

You might need to reinstall the magisk manager app if it doesn't show as rooted in the app
 
Last edited:

katerpanne

Members
Apr 19, 2014
2,546
332
you only have to do this if you dont have a ramdisk:
# fastboot flash recovery magisk_patched_recovery.img

1638943290967.png


If you have a ramdisk:
# fastboot flash boot magisk_patched_boot.img

does the Mi 9 Lite / Mi CC9 not have a ramdisk ?
 
Last edited:

Hallohannes123

Members
Dec 7, 2021
3
5
you only have to do this if you dont have a ramdisk:
# fastboot flash recovery magisk_patched_recovery.img

View attachment 39919

If you have a ramdisk:
# fastboot flash boot magisk_patched_boot.img

does the Mi 9 Lite / Mi CC9 not have a ramdisk ?
Thanks!
I added a disclaimer now, I didn't do so before because I assumed that with the same device and rom ramdisk would always be the same.
Not sure if it is, but it's better to disclose it.
 
  • Like
Reactions: katerpanne

katerpanne

Members
Apr 19, 2014
2,546
332
small error in description

Open the Magisk App again
Press the Install button
This time make sure "Recovery Mode" option is NOT checked
Choose “Select and Patch a File” in method, and select the stock boot.img
The Magisk app will patch the image to [Internal Storage]/Download/magisk_patched_[random_strings].img.
Rename the file to "magisk_patched_recovery.img"

it should be:
Rename the file to "magisk_patched_boot.img"
 
  • Like
Reactions: Hallohannes123

Motox

Members
Jun 3, 2011
121
40
when i boot to recovery over adb , there is no adb devices anymore, maybe reboot to fastboot?