[GUIDE] Unlock/Flash/Root for the Pixel 2 XL (taimen)

nathanchance

Senior Recognized Developer / Recognized Contribut
Jul 22, 2015
13,748
49,943
263
25
Mesa, AZ
Introduction

Hello everyone, this is a guide to assist you with customizing your Pixel 2 XL! I will be going over installing fastboot and adb, unlocking your bootloader, how to flash the factory images for clean flashes and upgrades, and how to root. Please feel free to ask any questions if you need clarification. Enjoy!

This information has been distilled from Google's official factory image site and the Magisk thread.


Installing fastboot and adb

Thankfully, Google has provided just adb, fastboot, and systrace as a simple zip file, making this process super easy. You MUST be on at LEAST 26.0.2 for the commands in this guide to work. When in doubt, grab the latest copy and install them using the following instructions.


Windows:

  1. Unzip the folder somewhere on your hard drive.
  2. Go to the folder containing the adb and fastboot files and type "cmd" in the path bar at the top.
  3. A command prompt should open with the current folder showing on the prompt.
  4. Type the following commands:
    Code:
    adb --version
    fastboot --version
    You should see some information appear. If that is the case, you were successful!

Mac/Linux:

  1. Unzip the folder somewhere on your hard drive.
  2. Navigate to that folder with your terminal.
  3. Run the following commands:
    Code:
    sudo install adb dmtracedump e2fsdroid etc1tool fastboot hprof-conv make_f2fs mke2fs mke2fs.conf sload_f2fs sqlite3 /usr/local/bin
    sudo mkdir -p /usr/local/lib64
    sudo install lib64/libc++.so /usr/local/lib64
  4. Type the following commands:
    Code:
    adb --version
    fastboot --version
    You should see the version information, along with telling you they are installed to /usr/local/bin. If so, you were successful!


Unlocking the bootloader

WARNING: This WILL wipe your entire phone. Please make copies or backups of any important data. This can also go wrong rendering your device inoperable. Proceed with caution.

  1. On your phone, open Settings, navigate to "System" then "About phone", and tap on the build number 7 times.
  2. Go one menu up, click on "Developer options", and turn on USB debugging and OEM unlocking.
  3. In your terminal, type the following command:
    Code:
    adb reboot bootloader
  4. Next, decide if you want to do a standard unlock or critical unlock. A critical unlock allows you to directly flash bootloader files, otherwise you will get an error when you try to do so.
  5. Depending on what you decided in the previous step, run the following commands:
    Code:
    fastboot flashing unlock
    (OPTIONAL)
    Code:
    fastboot flashing unlock_critical
  6. Follow the prompts on your device then reboot!


Flashing factory images

NOTE #1: If you have mounted /system as rw at any point (like in TWRP), you must upgrade using the factory image method. OTAs will fail because they cannot verify the integrity of the disk since its verity data has been changed.

NOTE #2: Flashing the factory images requires an unlocked bootloader. Flashing the OTA zips does not (but if anything goes wrong, you may not be able to recover without an RMA).

Updating to a new release (factory image):

  1. Download the latest factory image from Google's website.
  2. Reboot into the bootloader:
    Code:
    adb reboot bootloader
  3. Unzip the factory image.
  4. Inside you will see a bootloader image, a radio image, an image zip file, and a couple of flash scripts.
  5. If you are on Windows, open the "flash-all.bat" file in a text editor. If you are on Mac or Linux, open the "flash-all.sh" instead.
  6. Remove the "-w" flag before the fastboot command towards the end of the file. This will prevent fastboot from formatting your device.
  7. Run the flash all script! Open a command prompt, navigate to the folder with the script, and run one of the following commands:
    Windows:
    Code:
    flash-all
    Mac/Linux:
    Code:
    ./flash-all.sh
  8. Reboot once it is finished!
Updating to a new release (OTA zip):

  1. Download the latest OTA zip from Google's website
  2. Reboot into recovery:
    Code:
    adb reboot recovery
  3. Hold down the power button and push volume up
  4. Select "Apply update from ADB"
  5. Run the following command from the folder containing the OTA zip:
    Code:
    adb sideload <zip_name>.zip
  6. Reboot once it is finished!
Clean flashing a factory image (wipe everything):

  1. Download the latest factory image from Google's website
  2. Reboot into the bootloader:
    Code:
    adb reboot bootloader
  3. Unzip the factory image.
  4. Run the flash all script! Open a command prompt, navigate to the folder with the script, and run one of the following commands:
    Windows:
    Code:
    flash-all
    Mac/Linux:
    Code:
    ./flash-all.sh
  5. Reboot once it is finished!


Rooting with Magisk

NOTE #4: This section assumes you are not going to install TWRP. If you are, skip to the next section and just flash the latest Magisk zip after installing TWRP.

  1. Download the Magisk zip from the official thread and install the manager from the zip.
  2. Grab a boot image to patch (either the one from the latest factory image or a custom kernel one) and push it to your device:
    Code:
    adb push <path_to_file> /sdcard/Download
  3. Open Magisk Manager and click the Install button.
  4. Click "Install" at the first prompt then choose "Patch Boot Image File". A file manager will pop up.
  5. Select the boot image you want to patch and let Magisk Manager patch it.
  6. Pull it off your device:
    Code:
    adb pull /sdcard/MagiskManager/patched_boot.img
  7. Reboot into the bootloader:
    Code:
    adb reboot bootloader
  8. Flash the boot image and reboot.
    Code:
    fastboot flash boot patched_boot.img
    fastboot reboot
  9. Open Magisk Manager and you should be rooted!


Installing TWRP

NOTE #5: If you just want to temporarily boot TWRP to flash Magisk and your custom kernel, you can just skip flashing the installer zip in this process.

NOTE #6: TWRP can be unstable at times given the way that security has been set up on this device (lack of decryption, failing to boot, etc).

  • Download both the TWRP image and zip installer from the official site.
  • Temporarily boot the TWRP image.
    Code:
    fastboot boot <path_to_twrp_image>
  • Flash the TWRP installer zip.
  • Reinstall Magisk and your custom kernel if you had them.
  • Reboot and profit!


Common issues

  • Outdated fastboot/adb: This device requires the latest fastboot and adb binaries to work properly. A lot of common quick adb/fastboot installation guides link to installers that are old. Please manually install the latest using the information at the beginning of the thread!
  • Using a USB-3.0 or USB-C port: Some newer USB ports do not work with fastboot. Issues manifest as weird errors during a flash. Use a different USB cable/port.


Closing statements

If there are any procedures you would like to see added (like flashing a custom kernel or booting TWRP), I am happy to add them if requested. Also, when requesting help, please be as specific as possible where you get confused. I want this guide to be clear as possible.
 
Last edited:

iamjimmy

Senior Member
Dec 11, 2013
349
73
0
Thanks so much for your efforts. These are much appreciated. Just what we needed for Pixel 2 XL.

One can only hope that we eventually get SU Root, TWRP and Custom ROMs. The Pixel 1 XL's development was disappointing. Hopefully this phone has more.
 
  • Like
Reactions: Jiggs82
Jan 23, 2016
8
2
0
To Ubuntu users: the
Code:
android-tools-adb

android-tools-fastboot
packages won't necessarily work. The fastboot from the repos didn't have the same options as the one from the zip from Google. So if you are getting a usage dialog after running fastboot, that is why.
 
Last edited:
  • Like
Reactions: fracman

trim81

Senior Member
Feb 11, 2006
812
150
63
I always took the noobish method and used twrp...


If my device is bootloader unlocked and in developer mode, and in a chance I am stuck in a bootloop, can I fastboot adb the stock image and be back up and running?


Question is: with fastboot enabled, can I recover if I F up installing magisk/root?
 

nathanchance

Senior Recognized Developer / Recognized Contribut
Jul 22, 2015
13,748
49,943
263
25
Mesa, AZ
followed from the nexus 6p threads, waiting for TWRP to get stable and then it's on!
That's exactly what I'm doing. Waiting for TWRP, then I will buy the pixel. 6P is working perfect at the moment, after a battery replacement.
Not to sound pessimistic but if that's what you are waiting for, you'll probably never get this device lol. Even the Pixel 1's TWRP isn't the most stable thing (it's close but still).

Sent from my Pixel 2 XL using XDA Labs
 

iamjimmy

Senior Member
Dec 11, 2013
349
73
0
Not to sound pessimistic but if that's what you are waiting for, you'll probably never get this device lol. Even the Pixel 1's TWRP isn't the most stable thing (it's close but still).
Oh no :( So you're saying we might never get a stable TWRP and no good custom ROMs for Pixel 2 XL?
Any idea whether PureNexus or any of the other custom ROMs of Nexus/Pixel will come to Pixel 2 XL?

Based on my experience custom ROMs/Kernels can transform a mid range device to Flagship performance and features. I am using the 2 XL and still within the return window. If it is speculated that this phone will not have much development, then I might as well return it and continue using OG Pixel XL or get a OnePlus. Thanks.
 

nathanchance

Senior Recognized Developer / Recognized Contribut
Jul 22, 2015
13,748
49,943
263
25
Mesa, AZ
Oh no :( So you're saying we might never get a stable TWRP and no good custom ROMs for Pixel 2 XL?
Any idea whether PureNexus or any of the other custom ROMs of Nexus/Pixel will come to Pixel 2 XL?

Based on my experience custom ROMs/Kernels can transform a mid range device to Flagship performance and features. I am using the 2 XL and still within the return window. If it is speculated that this phone will not have much development, then I might as well return it and continue using OG Pixel XL or get a OnePlus. Thanks.
I'm saying if that is your only deciding factor for owning this device, considering getting another like the OnePlus 5 which has a guarantee of that. TWRP may get stable eventually but it may not. I personally love the kernel source that Google puts out and have been digging stock so I'm comfortable with just root with my kernel. If you aren't, then doing something else may be a good idea.

ROMs may end up coming in the form of images though (like system and boot and such), negating a need for TWRP. We will have to see.

Sent from my Pixel 2 XL using XDA Labs
 

JDROIDS

Senior Member
Mar 4, 2013
260
162
0
That's so strange. Why is that? It's a pixel which is the successor to Nexus phones so I'm not sure why the line of phones would have a hard time with twrp and custom ROM flashing.
 
  • Like
Reactions: inkdaddy66

nathanchance

Senior Recognized Developer / Recognized Contribut
Jul 22, 2015
13,748
49,943
263
25
Mesa, AZ
That's so strange. Why is that? It's a pixel which is the successor to Nexus phones so I'm not sure why the line of phones would have a hard time with twrp and custom ROM flashing.
Well few reasons...

1. A/B partitioning makes it so the boot and recovery partition are unified, meaning when you flash a ROM, you need to reflash TWRP.

2. With the Pixel 2 (XL), as stated in the TWRP thread, the secure crypto chip requires a rewrite of some things into Java, which will take time.

The Pixel isn't really a successor to the Nexus line because these are geared purely to consumers. It's Google's iPhone.

Sent from my Pixel 2 XL using XDA Labs
 

iamjimmy

Senior Member
Dec 11, 2013
349
73
0
I'm saying if that is your only deciding factor for owning this device, considering getting another like the OnePlus 5 which has a guarantee of that. TWRP may get stable eventually but it may not. I personally love the kernel source that Google puts out and have been digging stock so I'm comfortable with just root with my kernel. If you aren't, then doing something else may be a good idea.
ROMs may end up coming in the form of images though (like system and boot and such), negating a need for TWRP. We will have to see.
Sent from my Pixel 2 XL using XDA Labs
Thanks for the reply.
That is unfortunate. If we can't have custom Kernels, we miss out on features such as color control, calibration, sound amplication , bluetooth high performance audio, USB fastcharge, vibration strength control and other mods. Will this be developed in any Kernel? I'm assuming it will take a long time (if ever) to get Elemental X, Franco Kernal or anything similar.

Also for Root, I just unlocked my bootloader. If I use the Magdisk Root Manager for Root, is there any way to flash next month's security patch WITHOUT factory reset. With SU root of Pixel XL, it was usually as simple as flashing factory images (without wipe switch) and then flashing SU plus kernel.
For Magdisk, will a full wipe or unroot needed before flashing an update?
 
  • Like
Reactions: slaydog

nathanchance

Senior Recognized Developer / Recognized Contribut
Jul 22, 2015
13,748
49,943
263
25
Mesa, AZ
Thanks for the reply.
That is unfortunate. If we can't have custom Kernels, we miss out on features such as color control, calibration, sound amplication , bluetooth high performance audio, USB fastcharge, vibration strength control and other mods. Will this be developed in any Kernel? I'm assuming it will take a long time (if ever) to get Elemental X, Franco Kernal or anything similar.

Also for Root, I just unlocked my bootloader. If I use the Magdisk Root Manager for Root, is there any way to flash next month's security patch WITHOUT factory reset. With SU root of Pixel XL, it was usually as simple as flashing factory images (without wipe switch) and then flashing SU plus kernel.
For Magdisk, will a full wipe or unroot needed before flashing an update?
Custom kernels will absolutely be a thing on this device. I already have mine publicly available. I haven't looked into external features (and probably won't be able to for a bit as I am rather busy) but they will certainly come.

It's the same process for the Pixel 2 XL except you need to patch the boot image you are doing to flash first in Magisk Manager then flash it after the factory images.
 
  • Like
Reactions: iamjimmy

choder

Senior Member
Feb 26, 2010
164
22
48
I'm saying if that is your only deciding factor for owning this device, considering getting another like the OnePlus 5 which has a guarantee of that. TWRP may get stable eventually but it may not. I personally love the kernel source that Google puts out and have been digging stock so I'm comfortable with just root with my kernel. If you aren't, then doing something else may be a good idea.

ROMs may end up coming in the form of images though (like system and boot and such), negating a need for TWRP. We will have to see.

Sent from my Pixel 2 XL using XDA Labs
I need Verizon, so the OnePlus 5 is out of the question. Maybe once the V30 source is released and bootloader unlocked that may be worth looking at. But it probably won't get much development anyway.
Possibly the Essential Phone (seems to be a good deal now, and it has root and twrp)

I probably would be okay with kernel tweaks and root on the Pixel 2 XL.
 
Last edited:
  • Like
Reactions: State.of.mind