The below steps are assuming you have a Mac machine with adb and fastboot tools and developer option and usb debugging is enabled on your Pixel 2.
The below steps can also be used to revert to Android Oreo.
- Download TWRP .img file (Pixel 2: https://dl.twrp.me/walleye/ ) (Pixl2 XL https://dl.twrp.me/taimen/). E.g. for Pixel2 download twrp-3.2.3-0-walleye.img. It is specific to mobile model.
- Download Magisk app zip from site magiskmanager site. It is platform independent file.
- Ensure adb is able to connect to device. It should list the device name when we run thefollowing:
$ adb devices List of devices attached HT7AD1A0XXXX device
- Copy Magisk to mobile /sdcard/ directory
$ adb push Magisk-v16.7-1674-.zip /sdcard/
$ adb reboot bootloader
- Ensure fastboot can list the device name
- boot using twrp-3.2.3-0-walleye.img
$ fastboot boot twrp-3.2.3-0-walleye.img
- Select keep readonly => Install => Select Magisk file => Swipe to confirm Flash => Reboot system if everything is fine.
- Phone should be rooted now. Install Rootchecker on you mobile to check root status.