Steps to root an Android Pixel 2 phone using Magisk and boot.img patching.
Unlock bootloader
- Enable debug mode in Android if not done already
- Reboot Pixel 2 into bootloader
adb reboot bootloader - Unlock bootloader
fastboot flashing unlock - Reboot into bootloader again
fastboot reboot - Enable debug mode again
Install Magisk
- Download Magisk apk ( Magisk v25.2 or latest) https://github.com/topjohnwu/Magisk/releases
- adb install Magisk-v25.2.apk
Get and patch boot.img
- Download Android image for pixel2 (e.g. walleye-opd1.170816.010-factory-63083164.zip). It should be same as the installed image.
- Unzip the image
unzip walleye-opd1.170816.010-factory-63083164.zip -d dir1cd dir1/walleye-opd1.170816.010unzip image-walleye-opd1.170816.010.zip -d dir2cd dir2 - Push boot.img to Android device
adb push boot.img /sdcard/Download - Run Magisk in phone and click on Magisk Install. Select “Select and patch file). Select boot.img and create a patch file.
- Pull patch file to Computer using
adb pull /sdcard/Download/magisk_patched-25200_W2fd4.img
Flash Android with patched image
- Reboot Pixel 2 into bootloader again
adb reboot bootloader - Flash patched boot image
fastboot flash boot magisk_patched-25200_W2fd4.img reboot - Wait for reboot to finish and open Magisk
- Click on Superuser tab and enable Shell. Device is not rooted.