• Introducing XDA Computing: Discussion zones for Hardware, Software, and more!    Check it out!
  • Fill out your device list and let everyone know which phones you have!    Edit Your Device Inventory

How To Guide ROOTING + CUSTOM ROM, YOUR BRAND NEW REDMI NOTE 9 T FOR THE NOOB

Search This thread

chmick

Member
Jul 9, 2017
24
13
Redmi Note 9t
## first version , errors may still occur
Hi everybody, as a noob in the rooting world , here is my small contribution. A step by step how-to , to completely root + installing a custom.
DO NOT HESITATE TO COMMENT SO I CAN IMPROVE THE DOC:
=======================================================================

Read the complete procedure carefully before start: Beware you will loose all data you may have on the phone .and you will loose warranty .

## REQUIREMENTS :​

a brand new redmi note 9T (direct from the store, no modifications), a pc with windows , the usb cable to link the pc to the phone.
A sdcard where you can store the rom and some zip to put in your phone

Make sure the pc is up ot date with latest android usb driver and adb available :
usb drivers here : https://developer.android.com/studio/run/win-usb
adb software : https://www.xda-developers.com/install-adb-windows-macos-linux/
we also need 7zip https://www.7-zip.org/

Also try to update your phone with the latest MIUI version you can get (at the the time I'm writing this it should be MIUI 12.5, based on android 11).

To upgrade go to system/about phone/ tap on the MIUI logo/ check for update .

If your phone is still stuck to a lower version, you may trick it by changing the region (I choose hong kong) in system/additional settings/region
then try to check for MIUI update again.


## FIRST STEP : unlock the booloader .​

for this you need a xiaomi account (if you created one with your phone , use it)
You also need to enable developper mode in your phone , so you can access usb debuging . (see the video tutorial)
a video tutoriel here :

you will probably have to wait 168 hours before you can unlock the phone (Yes you're not alone to think it's annoying, do not hesitate to complain to xiaomi business department)


there is also this version of the unlocker (to bypass the wait time), but I have not tested it
Moreover the bypass works for devices not yet linked to mi account

Once your bootloader unlock you phone will be reseted and when you restart it you will be asked for the xiaomi account password again (and you need a network connection).
After completing the setup again, don't forget to reactivate usb debuging option .

### SECOND STEP download and save files


In case your want to rollback, and also if your want to install magisk in some custom rom , you need to download the original MIUI rom here :

from the zip file , you need to extract the boot.img file and transfer the file on your phone

then the install on your phone the magisk apk file : https://magiskapp.com/#magisk-app-apk
run the magisk app , choose install magisk , select patch a file and choose the boot.img file then press the let's go button
Magisk will generate a patched_image_file in your download folder .
copy the patched image file to your sdcard.

on your phone you can install this : https://play.google.com/store/apps/details?id=tk.hack5.treblecheck

It will help you select the type of rom you need to download

Plug your phone to the computer , open a command shell in your adb fastboot directory and type :
adb devices

you should see something like :

List of devices attached
sceqxxxxxxxxxxk device


(if not check your phone screen ,if there is some grant access dialog)

download orangefox from here https://github.com/gsuzeda/twrp_cannon/releases/

put the vbmeta.zip and OrangeFox-R11.0-Unofficial-cannong.zip on the sdcard

put the recovery.img in the same directory than your adb fastboot program

download the latest magisk files release from here :
first the zip : https://magiskapp.com/zip/#download-now
and the apk file : https://magiskapp.com/#magisk-app-apk
and put them on the sdcard


download the latest of the custom rom you want to install. Based on this link (thank you @gsuzeda) https://docs.google.com/spreadsheets/d/1Nm1RAQ_kiSoSBgtzux8uKklLF9TF6-1QvIVCPzW3OCs/edit#gid=0

, I will try AOSP rom here : https://github.com/phhusson/treble_experimentations/releases/latest
but you can also try lineageOS here : https://sourceforge.net/projects/andyyan-gsi/files/
(if you choose AOSP , you can not install magisk , at least for now)
NOTE: If your choose another custom rom , remember you may also need to install google apps as a separate package .
Example for lineageOS , you can download the gapps (MindtheGapps for arm64 )here https://androidfilehost.com/?fid=2188818919693781601
and copy the file to your sdcard

The redmi note 9T code name is CANNONG . It uses ARM64 A/B IMAGES and we want vndklite (read/write on system)

This is important whatever the custom rom you choose to download and install

Now we prepare the image files from the custom ROM so we can choose between two install methods

METHOD ONE is flashing the system.img from the computer with the phone in fastboot mode plugged to the pc.

METHOD TWO is flashing a zip file with the phone in recovery mode (using the orangefox program or twrp)
I choose his method , because you can do all the operation from orangefox recovery
for method two we will use https://forum.xda-developers.com/attachments/gsi_flasher_sdcard-zip.5183639/
(thank you @gsuzeda for the complete method here https://forum.xda-developers.com/t/...ung-galaxy-a51-super-partition-image.4216083/ )

unzip the gsi flasher somewhere on your PC (for me Mydocument\gsiflasher)

exemple usage with AOSP rom:

uncompress the system-roar-arm64-ab-vndklite-gapps.img.xz
copy the img file in the gsi directory of the gsi flasher and rename it system.img (so for me cp system-roar-arm64-ab-vndklite-gapps.img to Mydocument\gsiflasher\gsi\system.img).
then create a zip file with the 3 directories (gsi, META-INF, scripts) in Mydocument\gsiflasher using 7 zip , for example system-roar-arm64-ab-vndklite-gapps.zip.
And finally copy this zip to the root of your sdcard .

## THIRD STEP : install orangefox​

orangefox is a recovery program like twrp but with more option.

Check if you booloader is unlock in your phone by going to system\additonal settings\developper option\mi unlock status

If the booloader is unlock then you can install recovery orangefox .

Make sure than usb debugging and install via usb is checked in the developper option of your phone
power off your phone and restart your phone in fastboot mode (volume down + power )
plug it to your pc .
open a command shell in the directory were fastboot is installed
write the command :
fastboot devices

it should give you a list with your device
then write the command
fastboot flash recovery recovery.img

once the install complete reboot your phone in recovery mode with the command :
fastboot reboot recovery

once boot in recovery mode you should see the orangefox menu.

orangefox-recovery_557748_full.jpeg



Use the "Files" at the bottom at the screen explore to go to the sdcard and tap on the orangefox zip files .

then swipe to install

Once the file installed , the phone should reboot in recovery.

Then use the file explorer to find the vbmeta.zip
ttap the file and swipe to install

after the install the phone should reboot.
a simple check step to see if everything went right

## FOURTH STEP , test and install custom OS​

There is two method to install , via recovery or via fastboot

I choose to use orangefox recovery

via recovery
reboot in recovery mode (volume up +power)
Once booted in orangefox recovery

first format the DATA (using the wipe menu,and you need to type yes to confirm )
Then reboot to recovery (from the orangefox menu choose reboot then recovery)
once rebooted in recovery
wipe data cache and dalvik

then with the file menu of orangefox navigate to the root of your sdcard where you stored the system zip we created for example system-roar-arm64-ab-vndklite-gapps.zip.

tap the zip and swipe to install
(if your choose another rom , do the same thing to also intall the gapps zip file)

once the install complete
wipe data cache and dalvik
reboot the phone .

## FIFTH STEP check install​

your phone should now start with AOSP version of android and start the setup program.

If you get a message like your device is not play protect certified :

connect your phone to your computer, in a command shell type :

adb root
adb shell
sqlite3 /data/data/com.google.android.gsf/databases/gservices.db
select * from main where name = "android_id";


then copy the id number printed and go there :

and enter the id in the text box and press register

wait 15 minutes and reboot your phone and finish the setup process and connect to google store with your gmail account
If your installation complain about the sd card, choose format as external. (you may have to transfer the files of step one in the card again)

## SIXTH STEP : install magisk​

(DOES NOT WORK WITH AOSP ROM)

reboot in recovery.
in the orangefox file menu :
search your magisk.zip file on the sdcard , tap and swipe to install.
Then choose the patched_boot_img file and choose /boot to install
Then choose the vbmeta.zip and install
wipe cache and reboot
All you want to know about magisk is here : https://magiskapp.com/

### LAST STEP , secure back​

now disable usb debugging
unchecked the option : install app from unknow sources

### ROLLBACK​

In case you want to rollback to MIUI rom
go there : https://www.getdroidtips.com/guide-flash-miui-rom-xiaomi-devices/
and follow the chapter : the How to Flash Xiaomi Firmware via TWRP Recovery
 
Last edited:

dsclee1

Member
Oct 16, 2015
22
19
Looks good.

The default PHH GSI Custom Rom has inbuilt root rather than Magisk, which is a bit annoying as you can't get SafetyNet working, so can't use Google Pay (and other apps that require SafetyNet).

You can uninstall the inbuilt root and replace it with Magisk, but it's a bit fiddly (like most things on this phone!), as the Magisk app has an issue finding the Magisk su binary.

You need to be using the vndklite build so you can get write access to the system partition. From a root shell (which will be using the inbuilt root to start with). You need to run this:

Code:
mount -o remount,rw /
echo 'export PATH /sbin:/product/bin:/apex/com.android.runtime/bin:/apex/com.android.art/bin:/system_ext/bin:/system/bin:/system/xbin:/odm/bin:/vendor/bin:/vendor/xbin' >> init.environ.rc
mount -o remount,ro /

Reboot to OrangeFox, and in terminal run this (to remove the inbuilt su):
Code:
mount /system_root
mount -o remount,rw /system_root
touch /system_root/system/phh/secure
umount -l /system_root/system/xbin/su
rm /system_root/system/xbin/su
rm /system_root/system/bin/phh-su
rm /system_root/system/etc/init/su.rc
rm /system_root/system/bin/phh-securize.sh
rm -Rf /system_root/system/{app,priv-app}/me.phh.superuser/
rm -Rf /system_root/data/su
umount /system_root

Download the latest Magisk apk (v23 at time of writing) from https://github.com/topjohnwu/Magisk/releases/download/v23.0/Magisk-v23.0.apk and rename it to Magisk-v23.0.zip. Copy it over to your phone, and install it using OrangeFox (topjohnwu has stated in future Magisk versions the renaming to zip will stop working, but it's good for now).

From memory I think you now need to wipe the data partition again, but it's worth a try without, and see if you bootloop?

Once you're back into the regular system you'll need to install the Magisk app (if you haven't done so already), and then activate MagiskHide, and install the MagiskHide Props Config module. You can then use Google Pay again!
 
  • Like
Reactions: ps000000 and chmick

chmick

Member
Jul 9, 2017
24
13
Redmi Note 9t
Looks good.

The default PHH GSI Custom Rom has inbuilt root rather than Magisk, which is a bit annoying as you can't get SafetyNet working, so can't use Google Pay (and other apps that require SafetyNet).

You can uninstall the inbuilt root and replace it with Magisk, but it's a bit fiddly (like most things on this phone!), as the Magisk app has an issue finding the Magisk su binary.

You need to be using the vndklite build so you can get write access to the system partition. From a root shell (which will be using the inbuilt root to start with). You need to run this:

Code:
mount -o remount,rw /
echo 'export PATH /sbin:/product/bin:/apex/com.android.runtime/bin:/apex/com.android.art/bin:/system_ext/bin:/system/bin:/system/xbin:/odm/bin:/vendor/bin:/vendor/xbin' >> init.environ.rc
mount -o remount,ro /

Reboot to OrangeFox, and in terminal run this (to remove the inbuilt su):
Code:
mount /system_root
mount -o remount,rw /system_root
touch /system_root/system/phh/secure
umount -l /system_root/system/xbin/su
rm /system_root/system/xbin/su
rm /system_root/system/bin/phh-su
rm /system_root/system/etc/init/su.rc
rm /system_root/system/bin/phh-securize.sh
rm -Rf /system_root/system/{app,priv-app}/me.phh.superuser/
rm -Rf /system_root/data/su
umount /system_root

Download the latest Magisk apk (v23 at time of writing) from https://github.com/topjohnwu/Magisk/releases/download/v23.0/Magisk-v23.0.apk and rename it to Magisk-v23.0.zip. Copy it over to your phone, and install it using OrangeFox (topjohnwu has stated in future Magisk versions the renaming to zip will stop working, but it's good for now).

From memory I think you now need to wipe the data partition again, but it's worth a try without, and see if you bootloop?

Once you're back into the regular system you'll need to install the Magisk app (if you haven't done so already), and then activate MagiskHide, and install the MagiskHide Props Config module. You can then use Google Pay again!
oupps . Finally things did not as planned . After the running the commands , I was stuck in a loop , always going back to recovery (even if after wipe data). Finally I decided to reflash completely, but this time with lineage OS .

This time I did :
boot to recovery
format data
install lineageOS zip

I tried to install the gapps but the install crash (out of ressources)
so i reboot in system
then reboot back in recovery
flash the gapps file
flash the magisk.zip (the apk previously renammed ) and got an error.
reboot back to system , took the opportunity to declare the phone so google app store works.
then resynchronize with my google account.
once the update and sync completed boot to recovey
flash the magisk zip (the real one from here https://magiskapp.com/zip/#download-now
flash the vbmeta
then reboot to system

It boots fine But I have no root acces . Below are a few screenshot from magisk :

Screenshot_20210625-182719_Trebuchet.png
Screenshot_20210625-182738_Trebuchet.png
Screenshot_20210625-182801_Trebuchet.png
 

chmick

Member
Jul 9, 2017
24
13
Redmi Note 9t
@gsuzeda , @dsclee1
trying to redo the al process all other again. Things are getting worse.
This time, I can flash the lineage rom but when I try to flash the gapps , I got a not enough space .
whatever I do , i got the error, I tried try wipe format everything :

Here is quick step
boot in recovery
format data,
wipe cache , dalvik, internal storage, data.
flashing lineage OS
flashing the gapps (there i get a not enough space)

What did I missed ??

Meanwhile I'l go back to AOSP without magisk


I also updated the doc . Can you check especially the flash ROM part and the magisk part ?
Thanks
 
Last edited:
  • Like
Reactions: gsuzeda

gsuzeda

Member
Dec 2, 2020
13
14
@gsuzeda , @dsclee1
trying to redo the al process all other again. Things are getting worse.
This time, I can flash the lineage rom but when I try to flash the gapps , I got a not enough space .
whatever I do , i got the error, I tried try wipe format everything :

Here is quick step
boot in recovery
format data,
wipe cache , dalvik, internal storage, data.
flashing lineage OS
flashing the gapps (there i get a not enough space)

What did I missed ??

Meanwhile I'l go back to AOSP without magisk


I also updated the doc . Can you check especially the flash ROM part and the magisk part ?
Thanks

I think you can only install gapps if they are systemless like litegapps
 

KevinAix

New member
Jul 5, 2019
1
0
## first version , errors may still occur
Hi everybody, as a noob in the rooting world , here is my small contribution. A step by step how-to , to completely root + installing a custom.
DO NOT HESITATE TO COMMENT SO I CAN IMPROVE THE DOC:
=======================================================================

Read the complete procedure carefully before start: Beware you will loose all data you may have on the phone .and you will loose warranty .

## REQUIREMENTS :​

a brand new redmi note 9T (direct from the store, no modifications), a pc with windows , the usb cable to link the pc to the phone.
A sdcard where you can store the rom and some zip to put in your phone

Make sure the pc is up ot date with latest android usb driver and adb available :
usb drivers here : https://developer.android.com/studio/run/win-usb
adb software : https://www.xda-developers.com/install-adb-windows-macos-linux/
we also need 7zip https://www.7-zip.org/

Also try to update your phone with the latest MIUI version you can get (at the the time I'm writing this it should be MIUI 12.5, based on android 11).

To upgrade go to system/about phone/ tap on the MIUI logo/ check for update .

If your phone is still stuck to a lower version, you may trick it by changing the region (I choose hong kong) in system/additional settings/region
then try to check for MIUI update again.


## FIRST STEP : unlock the booloader .​

for this you need a xiaomi account (if you created one with your phone , use it)
You also need to enable developper mode in your phone , so you can access usb debuging . (see the video tutorial)
a video tutoriel here :

you will probably have to wait 168 hours before you can unlock the phone (Yes you're not alone to think it's annoying, do not hesitate to complain to xiaomi business department)


there is also this version of the unlocker (to bypass the wait time), but I have not tested it
Moreover the bypass works for devices not yet linked to mi account

Once your bootloader unlock you phone will be reseted and when you restart it you will be asked for the xiaomi account password again (and you need a network connection).
After completing the setup again, don't forget to reactivate usb debuging option .

### SECOND STEP download and save files


In case your want to rollback, and also if your want to install magisk in some custom rom , you need to download the original MIUI rom here :

from the zip file , you need to extract the boot.img file and transfer the file on your phone

then the install on your phone the magisk apk file : https://magiskapp.com/#magisk-app-apk
run the magisk app , choose install magisk , select patch a file and choose the boot.img file then press the let's go button
Magisk will generate a patched_image_file in your download folder .
copy the patched image file to your sdcard.

on your phone you can install this : https://play.google.com/store/apps/details?id=tk.hack5.treblecheck

It will help you select the type of rom you need to download

Plug your phone to the computer , open a command shell in your adb fastboot directory and type :
adb devices

you should see something like :

List of devices attached
sceqxxxxxxxxxxk device


(if not check your phone screen ,if there is some grant access dialog)

download orangefox from here https://github.com/gsuzeda/twrp_cannon/releases/

put the vbmeta.zip and OrangeFox-R11.0-Unofficial-cannong.zip on the sdcard

put the recovery.img in the same directory than your adb fastboot program

download the latest magisk files release from here :
first the zip : https://magiskapp.com/zip/#download-now
and the apk file : https://magiskapp.com/#magisk-app-apk
and put them on the sdcard


download the latest of the custom rom you want to install. Based on this link (thank you @gsuzeda) https://docs.google.com/spreadsheets/d/1Nm1RAQ_kiSoSBgtzux8uKklLF9TF6-1QvIVCPzW3OCs/edit#gid=0

, I will try AOSP rom here : https://github.com/phhusson/treble_experimentations/releases/latest
but you can also try lineageOS here : https://sourceforge.net/projects/andyyan-gsi/files/
(if you choose AOSP , you can not install magisk , at least for now)
NOTE: If your choose another custom rom , remember you may also need to install google apps as a separate package .
Example for lineageOS , you can download the gapps (MindtheGapps for arm64 )here https://androidfilehost.com/?fid=2188818919693781601
and copy the file to your sdcard

The redmi note 9T code name is CANNONG . It uses ARM64 A/B IMAGES and we want vndklite (read/write on system)

This is important whatever the custom rom you choose to download and install

Now we prepare the image files from the custom ROM so we can choose between two install methods

METHOD ONE is flashing the system.img from the computer with the phone in fastboot mode plugged to the pc.

METHOD TWO is flashing a zip file with the phone in recovery mode (using the orangefox program or twrp)
I choose his method , because you can do all the operation from orangefox recovery
for method two we will use https://forum.xda-developers.com/attachments/gsi_flasher_sdcard-zip.5183639/
(thank you @gsuzeda for the complete method here https://forum.xda-developers.com/t/...ung-galaxy-a51-super-partition-image.4216083/ )

unzip the gsi flasher somewhere on your PC (for me Mydocument\gsiflasher)

exemple usage with AOSP rom:

uncompress the system-roar-arm64-ab-vndklite-gapps.img.xz
copy the img file in the gsi directory of the gsi flasher and rename it system.img (so for me cp system-roar-arm64-ab-vndklite-gapps.img to Mydocument\gsiflasher\gsi\system.img).
then create a zip file with the 3 directories (gsi, META-INF, scripts) in Mydocument\gsiflasher using 7 zip , for example system-roar-arm64-ab-vndklite-gapps.zip.
And finally copy this zip to the root of your sdcard .

## THIRD STEP : install orangefox​

orangefox is a recovery program like twrp but with more option.

Check if you booloader is unlock in your phone by going to system\additonal settings\developper option\mi unlock status

If the booloader is unlock then you can install recovery orangefox .

Make sure than usb debugging and install via usb is checked in the developper option of your phone
power off your phone and restart your phone in fastboot mode (volume down + power )
plug it to your pc .
open a command shell in the directory were fastboot is installed
write the command :
fastboot devices

it should give you a list with your device
then write the command
fastboot flash recovery recovery.img

once the install complete reboot your phone in recovery mode with the command :
fastboot reboot recovery

once boot in recovery mode you should see the orangefox menu.

View attachment 5349227


Use the "Files" at the bottom at the screen explore to go to the sdcard and tap on the orangefox zip files .

then swipe to install

Once the file installed , the phone should reboot in recovery.

Then use the file explorer to find the vbmeta.zip
ttap the file and swipe to install

after the install the phone should reboot.
a simple check step to see if everything went right

## FOURTH STEP , test and install custom OS​

There is two method to install , via recovery or via fastboot

I choose to use orangefox recovery

via recovery
reboot in recovery mode (volume up +power)
Once booted in orangefox recovery

first format the DATA (using the wipe menu,and you need to type yes to confirm )
Then reboot to recovery (from the orangefox menu choose reboot then recovery)
once rebooted in recovery
wipe data cache and dalvik

then with the file menu of orangefox navigate to the root of your sdcard where you stored the system zip we created for example system-roar-arm64-ab-vndklite-gapps.zip.

tap the zip and swipe to install
(if your choose another rom , do the same thing to also intall the gapps zip file)

once the install complete
wipe data cache and dalvik
reboot the phone .

## FIFTH STEP check install​

your phone should now start with AOSP version of android and start the setup program.

If you get a message like your device is not play protect certified :

connect your phone to your computer, in a command shell type :

adb root
adb shell
sqlite3 /data/data/com.google.android.gsf/databases/gservices.db
select * from main where name = "android_id";


then copy the id number printed and go there :

and enter the id in the text box and press register

wait 15 minutes and reboot your phone and finish the setup process and connect to google store with your gmail account
If your installation complain about the sd card, choose format as external. (you may have to transfer the files of step one in the card again)

## SIXTH STEP : install magisk​

(DOES NOT WORK WITH AOSP ROM)

reboot in recovery.
in the orangefox file menu :
search your magisk.zip file on the sdcard , tap and swipe to install.
Then choose the patched_boot_img file and choose /boot to install
Then choose the vbmeta.zip and install
wipe cache and reboot
All you want to know about magisk is here : https://magiskapp.com/

### LAST STEP , secure back​

now disable usb debugging
unchecked the option : install app from unknow sources

### ROLLBACK​

In case you want to rollback to MIUI rom
go there : https://www.getdroidtips.com/guide-flash-miui-rom-xiaomi-devices/
and follow the chapter : the How to Flash Xiaomi Firmware via TWRP Recovery
I will try after thanks you and everybody who help to do this !
 

Top Liked Posts

  • There are no posts matching your filters.
  • 2
    ## first version , errors may still occur
    Hi everybody, as a noob in the rooting world , here is my small contribution. A step by step how-to , to completely root + installing a custom.
    DO NOT HESITATE TO COMMENT SO I CAN IMPROVE THE DOC:
    =======================================================================

    Read the complete procedure carefully before start: Beware you will loose all data you may have on the phone .and you will loose warranty .

    ## REQUIREMENTS :​

    a brand new redmi note 9T (direct from the store, no modifications), a pc with windows , the usb cable to link the pc to the phone.
    A sdcard where you can store the rom and some zip to put in your phone

    Make sure the pc is up ot date with latest android usb driver and adb available :
    usb drivers here : https://developer.android.com/studio/run/win-usb
    adb software : https://www.xda-developers.com/install-adb-windows-macos-linux/
    we also need 7zip https://www.7-zip.org/

    Also try to update your phone with the latest MIUI version you can get (at the the time I'm writing this it should be MIUI 12.5, based on android 11).

    To upgrade go to system/about phone/ tap on the MIUI logo/ check for update .

    If your phone is still stuck to a lower version, you may trick it by changing the region (I choose hong kong) in system/additional settings/region
    then try to check for MIUI update again.


    ## FIRST STEP : unlock the booloader .​

    for this you need a xiaomi account (if you created one with your phone , use it)
    You also need to enable developper mode in your phone , so you can access usb debuging . (see the video tutorial)
    a video tutoriel here :

    you will probably have to wait 168 hours before you can unlock the phone (Yes you're not alone to think it's annoying, do not hesitate to complain to xiaomi business department)


    there is also this version of the unlocker (to bypass the wait time), but I have not tested it
    Moreover the bypass works for devices not yet linked to mi account

    Once your bootloader unlock you phone will be reseted and when you restart it you will be asked for the xiaomi account password again (and you need a network connection).
    After completing the setup again, don't forget to reactivate usb debuging option .

    ### SECOND STEP download and save files


    In case your want to rollback, and also if your want to install magisk in some custom rom , you need to download the original MIUI rom here :

    from the zip file , you need to extract the boot.img file and transfer the file on your phone

    then the install on your phone the magisk apk file : https://magiskapp.com/#magisk-app-apk
    run the magisk app , choose install magisk , select patch a file and choose the boot.img file then press the let's go button
    Magisk will generate a patched_image_file in your download folder .
    copy the patched image file to your sdcard.

    on your phone you can install this : https://play.google.com/store/apps/details?id=tk.hack5.treblecheck

    It will help you select the type of rom you need to download

    Plug your phone to the computer , open a command shell in your adb fastboot directory and type :
    adb devices

    you should see something like :

    List of devices attached
    sceqxxxxxxxxxxk device


    (if not check your phone screen ,if there is some grant access dialog)

    download orangefox from here https://github.com/gsuzeda/twrp_cannon/releases/

    put the vbmeta.zip and OrangeFox-R11.0-Unofficial-cannong.zip on the sdcard

    put the recovery.img in the same directory than your adb fastboot program

    download the latest magisk files release from here :
    first the zip : https://magiskapp.com/zip/#download-now
    and the apk file : https://magiskapp.com/#magisk-app-apk
    and put them on the sdcard


    download the latest of the custom rom you want to install. Based on this link (thank you @gsuzeda) https://docs.google.com/spreadsheets/d/1Nm1RAQ_kiSoSBgtzux8uKklLF9TF6-1QvIVCPzW3OCs/edit#gid=0

    , I will try AOSP rom here : https://github.com/phhusson/treble_experimentations/releases/latest
    but you can also try lineageOS here : https://sourceforge.net/projects/andyyan-gsi/files/
    (if you choose AOSP , you can not install magisk , at least for now)
    NOTE: If your choose another custom rom , remember you may also need to install google apps as a separate package .
    Example for lineageOS , you can download the gapps (MindtheGapps for arm64 )here https://androidfilehost.com/?fid=2188818919693781601
    and copy the file to your sdcard

    The redmi note 9T code name is CANNONG . It uses ARM64 A/B IMAGES and we want vndklite (read/write on system)

    This is important whatever the custom rom you choose to download and install

    Now we prepare the image files from the custom ROM so we can choose between two install methods

    METHOD ONE is flashing the system.img from the computer with the phone in fastboot mode plugged to the pc.

    METHOD TWO is flashing a zip file with the phone in recovery mode (using the orangefox program or twrp)
    I choose his method , because you can do all the operation from orangefox recovery
    for method two we will use https://forum.xda-developers.com/attachments/gsi_flasher_sdcard-zip.5183639/
    (thank you @gsuzeda for the complete method here https://forum.xda-developers.com/t/...ung-galaxy-a51-super-partition-image.4216083/ )

    unzip the gsi flasher somewhere on your PC (for me Mydocument\gsiflasher)

    exemple usage with AOSP rom:

    uncompress the system-roar-arm64-ab-vndklite-gapps.img.xz
    copy the img file in the gsi directory of the gsi flasher and rename it system.img (so for me cp system-roar-arm64-ab-vndklite-gapps.img to Mydocument\gsiflasher\gsi\system.img).
    then create a zip file with the 3 directories (gsi, META-INF, scripts) in Mydocument\gsiflasher using 7 zip , for example system-roar-arm64-ab-vndklite-gapps.zip.
    And finally copy this zip to the root of your sdcard .

    ## THIRD STEP : install orangefox​

    orangefox is a recovery program like twrp but with more option.

    Check if you booloader is unlock in your phone by going to system\additonal settings\developper option\mi unlock status

    If the booloader is unlock then you can install recovery orangefox .

    Make sure than usb debugging and install via usb is checked in the developper option of your phone
    power off your phone and restart your phone in fastboot mode (volume down + power )
    plug it to your pc .
    open a command shell in the directory were fastboot is installed
    write the command :
    fastboot devices

    it should give you a list with your device
    then write the command
    fastboot flash recovery recovery.img

    once the install complete reboot your phone in recovery mode with the command :
    fastboot reboot recovery

    once boot in recovery mode you should see the orangefox menu.

    orangefox-recovery_557748_full.jpeg



    Use the "Files" at the bottom at the screen explore to go to the sdcard and tap on the orangefox zip files .

    then swipe to install

    Once the file installed , the phone should reboot in recovery.

    Then use the file explorer to find the vbmeta.zip
    ttap the file and swipe to install

    after the install the phone should reboot.
    a simple check step to see if everything went right

    ## FOURTH STEP , test and install custom OS​

    There is two method to install , via recovery or via fastboot

    I choose to use orangefox recovery

    via recovery
    reboot in recovery mode (volume up +power)
    Once booted in orangefox recovery

    first format the DATA (using the wipe menu,and you need to type yes to confirm )
    Then reboot to recovery (from the orangefox menu choose reboot then recovery)
    once rebooted in recovery
    wipe data cache and dalvik

    then with the file menu of orangefox navigate to the root of your sdcard where you stored the system zip we created for example system-roar-arm64-ab-vndklite-gapps.zip.

    tap the zip and swipe to install
    (if your choose another rom , do the same thing to also intall the gapps zip file)

    once the install complete
    wipe data cache and dalvik
    reboot the phone .

    ## FIFTH STEP check install​

    your phone should now start with AOSP version of android and start the setup program.

    If you get a message like your device is not play protect certified :

    connect your phone to your computer, in a command shell type :

    adb root
    adb shell
    sqlite3 /data/data/com.google.android.gsf/databases/gservices.db
    select * from main where name = "android_id";


    then copy the id number printed and go there :

    and enter the id in the text box and press register

    wait 15 minutes and reboot your phone and finish the setup process and connect to google store with your gmail account
    If your installation complain about the sd card, choose format as external. (you may have to transfer the files of step one in the card again)

    ## SIXTH STEP : install magisk​

    (DOES NOT WORK WITH AOSP ROM)

    reboot in recovery.
    in the orangefox file menu :
    search your magisk.zip file on the sdcard , tap and swipe to install.
    Then choose the patched_boot_img file and choose /boot to install
    Then choose the vbmeta.zip and install
    wipe cache and reboot
    All you want to know about magisk is here : https://magiskapp.com/

    ### LAST STEP , secure back​

    now disable usb debugging
    unchecked the option : install app from unknow sources

    ### ROLLBACK​

    In case you want to rollback to MIUI rom
    go there : https://www.getdroidtips.com/guide-flash-miui-rom-xiaomi-devices/
    and follow the chapter : the How to Flash Xiaomi Firmware via TWRP Recovery
    2
    Looks good.

    The default PHH GSI Custom Rom has inbuilt root rather than Magisk, which is a bit annoying as you can't get SafetyNet working, so can't use Google Pay (and other apps that require SafetyNet).

    You can uninstall the inbuilt root and replace it with Magisk, but it's a bit fiddly (like most things on this phone!), as the Magisk app has an issue finding the Magisk su binary.

    You need to be using the vndklite build so you can get write access to the system partition. From a root shell (which will be using the inbuilt root to start with). You need to run this:

    Code:
    mount -o remount,rw /
    echo 'export PATH /sbin:/product/bin:/apex/com.android.runtime/bin:/apex/com.android.art/bin:/system_ext/bin:/system/bin:/system/xbin:/odm/bin:/vendor/bin:/vendor/xbin' >> init.environ.rc
    mount -o remount,ro /

    Reboot to OrangeFox, and in terminal run this (to remove the inbuilt su):
    Code:
    mount /system_root
    mount -o remount,rw /system_root
    touch /system_root/system/phh/secure
    umount -l /system_root/system/xbin/su
    rm /system_root/system/xbin/su
    rm /system_root/system/bin/phh-su
    rm /system_root/system/etc/init/su.rc
    rm /system_root/system/bin/phh-securize.sh
    rm -Rf /system_root/system/{app,priv-app}/me.phh.superuser/
    rm -Rf /system_root/data/su
    umount /system_root

    Download the latest Magisk apk (v23 at time of writing) from https://github.com/topjohnwu/Magisk/releases/download/v23.0/Magisk-v23.0.apk and rename it to Magisk-v23.0.zip. Copy it over to your phone, and install it using OrangeFox (topjohnwu has stated in future Magisk versions the renaming to zip will stop working, but it's good for now).

    From memory I think you now need to wipe the data partition again, but it's worth a try without, and see if you bootloop?

    Once you're back into the regular system you'll need to install the Magisk app (if you haven't done so already), and then activate MagiskHide, and install the MagiskHide Props Config module. You can then use Google Pay again!
    1
    ## TO DO

    improve the magisk part :
    adding a list of apps for securing the phone

    ## TO DO: EXTRA STEP :
    how to move back from custom to stock rom
    1
    @gsuzeda , @dsclee1
    trying to redo the al process all other again. Things are getting worse.
    This time, I can flash the lineage rom but when I try to flash the gapps , I got a not enough space .
    whatever I do , i got the error, I tried try wipe format everything :

    Here is quick step
    boot in recovery
    format data,
    wipe cache , dalvik, internal storage, data.
    flashing lineage OS
    flashing the gapps (there i get a not enough space)

    What did I missed ??

    Meanwhile I'l go back to AOSP without magisk


    I also updated the doc . Can you check especially the flash ROM part and the magisk part ?
    Thanks