[OnePlus 7T ROMs, Kernels, Recoveries, & Other Deve] _sky.captain_:
Consolidated documentation for using TWRP to root OnePlus 7T

Thank you, [MENTION=4537640]zioloiso[/MENTION]. It had just dawned on me that I have root with TWRP even if it all it does is give me a shell session.

Thanks also to [MENTION=6561751]pedritopl[/MENTION]. I didn't see a clear answer on the page that was linked in your message. Please elaborate if I'm missing something there).

I think it would be good to make a sticky post, or a pinned post, or whatever xda calls them, that can show people what to do. In fact, it's not that hard to express fairly clearly:

Make sure you can use adb and fastboot with your phone. If you don't know how to use this, there are many excellent articles you can find elsewhere. Try one and post specific questions if you get stuck.

Make sure your bootloader is unlocked. If it is not, know that doing so will not void your warranty with OnePlus but it will wipe your data. Again, there are many excellent articles on this elsewhere. Try one and post specific questions if you get stuck.

Boot your phone with the twrp image posted in this thread. This typically takes two commands:

adb reboot bootloader
fastboot boot /local/twrp.img

Find your boot image. It will be inside /dev/block/platform, though the specific location may vary on specific devices. One way to find it is as follows:

find /dev/ -name boot

On my phone, the file name was /dev/block/platform/soc/1d84000.ufshc/by-name/boot

Make a copy of that boot file, replacing /SOMEWHERE/ with a writable destination on your phone, and replacing the if parameter with the location of the boot image you found previously.

ii if=/dev/block/platform/soc/1d84000.ufshc/by-name/boot of=/SOMEWHERE/boot.img bs=2048

Back on your laptop, copy this file to your computer and delete it from your phone. This is just a safety precaution for any number of annoying problems that might arise if we leave the file on the phone when we boot into Android. For example, in my case, since the current twrp doesn't mount all my volumes, I wrote the boot image to /sdcard. If I would have left it there, my /sdcard mount point might have failed when Android loaded.

adb pull /SOMEWHERE/boot.img .
adb shell rm /SOMEWHERE/boot.img

Reboot your phone into Android.

Back on your PC, send the boot image back to your phone.

adb push ./boot.img /sdcard/Download/boot.img

Visit the XDA page for Magisk and install the current version of Magisk Manager.

Launch the Magisk Manager app.

At the top of the app, Magisk Manager will show you that Magisk is not installed. Click on the install button. When you are prompted for a method, choose "Select and Patch a File."

Tell Magisk to use the boot.img file you just sent to your phone.

Magisk will patch this file and tell you the location of the patched boot image.

Back on your PC, grab a copy of this patched file.

adb pull /sdcard/Download/magisk_patched.img

Boot into bootloader once again and then flash the newly-patched boot image to your phone.

adb reboot bootloader
# wait until you are in bootloader mode
fastboot flash boot ./magisk_patched.img

Reboot into Android, and the Magisk Manager should tell you that Magisk is properly installed, and you should have root access (which you can test by using adb to get a shell and just running the su command).

This is off the top of my head to start the process to get a procedure documented in a more consolidated way. I am suggesting that we take this as a starting point, and that others edit it if and where it needs it, and then we stick it at the top of this forum.

The only thing I would change about it is that since I like to err on the side of caution, I booted from the magisk_patched.img file once before I flashed it. To do this, get into bootloader mode and run this:

fastboot boot ./magisk_patched.img

Thoughts? Maybe I should refine this more and post it as a separate thread. I'm only moderately knowledgeable about Android so I've never posted a thread here to help others. Would this be worth its own thread, referencing this one to grab the twrp files?