How to Unlock and Root the Google Pixel 2
In this article
Unlocking the bootloader and rooting your Google Pixel 2 gives you full administrative control over the device, allowing you to install custom ROMs, remove bloatware, use root-only apps, and tweak system settings. This guide walks you through the entire process safely. Before you begin, back up all data — unlocking the bootloader wipes your phone completely.
What You'll Need
- A Google Pixel 2 (not the 2 XL — steps are similar but files differ)
- A Windows, macOS, or Linux computer
- A USB cable that supports data transfer
- Android SDK Platform Tools (ADB and Fastboot) installed on your computer
- The correct factory image for your Pixel 2 (to extract the boot image) — download from Google's official developer site
- Magisk ZIP (latest stable) — download from the official Magisk GitHub releases
- Unlocked developer options on your phone (Settings > About phone > tap “Build number” 7 times)
Step-by-Step
- Enable Developer Options and USB Debugging: On your phone, go to Settings > System > Developer options. Toggle on “USB debugging” and “OEM unlocking”. If “OEM unlocking” is greyed out, connect to the internet and ensure your phone is not carrier-locked (some carriers disable it).
- Back up your phone: Unlocking the bootloader erases everything. Back up photos, contacts, and any files you want to keep. Use Google's built-in backup or copy files to your computer.
- Install ADB and Fastboot: Download the platform-tools ZIP from the Android developer site, extract it to a folder on your computer (e.g., C:\adb). Open a terminal/command prompt in that folder.
- Connect your phone and test ADB: Plug your phone into the computer. On your phone, accept the RSA fingerprint prompt if it appears. In the terminal, type
adb devices— you should see your device listed as “device”. If not, reinstall drivers (Windows) or check the USB connection. - Reboot into bootloader: Type
adb reboot bootloader. Your phone will restart into the bootloader screen (with an Android robot and menu). - Unlock the bootloader: In the bootloader, type
fastboot flashing unlock. On your phone, use the volume keys to highlight “Unlock the bootloader” and press power to confirm. This wipes your phone. After it completes, the bootloader will be unlocked. - Reboot and set up your phone: Type
fastboot reboot. Your phone will restart. Set it up as a new device (or restore from backup). Re-enable developer options and USB debugging (they reset after the wipe). - Extract the stock boot image: Download the factory image for your Pixel 2 (matching your build number — check Settings > About phone > Build number). Extract the ZIP. Inside, you'll find another ZIP (e.g., walleye-...-factory.zip). Extract that, then find the image-walleye-...zip. Extract that and locate the
boot.imgfile. - Patch the boot image with Magisk: Transfer the
boot.imgto your phone. Install the Magisk app (APK) from the official GitHub. Open Magisk, tap “Install” next to Magisk, then “Select and Patch a File”. Choose the boot.img. Magisk will create a patched image (usually in Downloads). - Reboot to bootloader again: Type
adb reboot bootloader. - Flash the patched boot image: In the bootloader, type
fastboot flash boot /path/to/magisk_patched.img(replace with the actual path). Wait for it to finish. - Reboot and verify root: Type
fastboot reboot. After boot, open the Magisk app — it should show “Magisk is installed” and the version. You can also install a root checker app from the Play Store to confirm.
Common Mistakes
- Skipping the backup: Unlocking wipes all data. If you skip backup, you lose everything.
- Using the wrong boot image: The boot image must match your exact build number. Using a mismatched image can cause boot loops.
- Not enabling OEM unlocking: If you skip this, the
fastboot flashing unlockcommand will fail with an error. - Flashing the full factory image instead of just boot: You only need to flash the patched boot image, not the entire factory image (unless you want to restore stock).
- Forgetting to re-enable USB debugging after the wipe: After unlocking, USB debugging is reset. You must re-enable it before the next ADB steps.
Tips
- Keep the platform-tools folder on your computer for future updates or unrooting.
- Use the original USB cable that came with your phone to avoid connection issues.
- If you plan to install custom ROMs, you'll need a custom recovery like TWRP — but that's beyond this guide.
- Rooting voids your warranty and can break some apps (banking, Google Pay). Consider using Magisk's “MagiskHide” or “DenyList” to hide root from specific apps.
- Take note of your current build number before starting — you'll need it for the correct boot image.
Troubleshooting
“fastboot” is not recognized: Make sure you're running the command from the folder containing fastboot.exe (Windows) or that the folder is in your PATH. On macOS/Linux, you may need to use ./fastboot.
Device not detected in fastboot: Try a different USB port (preferably USB 2.0), reinstall the Google USB driver (Windows), or check that you're in bootloader mode (not the Android system).
Boot loop after flashing: This usually means the boot image doesn't match your build. Re-download the correct factory image, extract the boot.img again, and re-patch with Magisk. Then flash again.
Magisk app shows “Requires Additional Setup” or “Installation failed”: Make sure you're using the latest Magisk version. If the app says “Ramdisk not found”, your boot image may be corrupted — re-extract and re-patch.
OEM unlocking is greyed out: This is common on carrier-locked devices. Contact your carrier to unlock the bootloader, or check if your device is eligible. Some carriers never allow it.
If all else fails: You can restore the stock factory image by downloading it and running flash-all.bat (Windows) or flash-all.sh (macOS/Linux) from the extracted folder. This will return your phone to stock, but it will still be bootloader-unlocked.
Frequently Asked Questions
Will unlocking the bootloader delete my data?
Yes, unlocking the bootloader wipes your phone completely. Always back up before starting.
Is rooting the Pixel 2 legal?
Yes, rooting is legal in most countries, but it voids your warranty and may violate your carrier's terms. Check local laws.
Can I still receive OTA updates after rooting?
If you keep the stock ROM and only root via Magisk, you can install OTA updates, but you'll need to re-root after each update (re-patch the new boot image). Custom ROMs update differently.
Will Google Pay work after rooting?
Usually no, because Google Pay detects root. You can try Magisk's DenyList feature, but it's not guaranteed and may break with future updates.
How do I unroot my Pixel 2?
Flash the stock boot image (the unpatched one) via fastboot: fastboot flash boot boot.img. Then uninstall the Magisk app. Your phone will be unrooted but still bootloader-unlocked.
What if I don't know my build number?
Go to Settings > About phone > Build number. It looks like “OPM1.171019.011”. Use that exact string when downloading the factory image.