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

nathanchance

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

Hello everyone, this is a guide to assist you with customizing your Pixel 2! 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. Run the following command:
    Code:
    fastboot flashing unlock
  5. Follow the prompts on your device then reboot!


Flashing factory images

NOTE #1: You CANNOT downgrade factory images. Google has prevented users from doing so to keep them safe from vulernabilities that were patched. You should only upgrade or reinstall the current image.

NOTE #2: 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 #3: 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:

Xxnoobkiller420xX

New member
Sep 21, 2017
4
0
0
Stuck on this step

Run the flash all script! Open a command prompt, navigate to the folder with the script, and run one of the following commands:

How do I navigate in command prompt? When I typed flash-all, it said it is not a internal command etc. When I dragged and dropped flash-all into the command prompt, it said C:\Users\W Balls\Downloads\SAMPWND_SYSTEMROOT_ADB_FILES>"C:\Users\****** Jim\Downloads\walleye-opd1.170816.025-factory-4752baae\walleye-opd1.170816.025\flash-all.bat"
error: cannot load 'bootloader-walleye-mw8998-002.0059.00.img'
rebooting into bootloader...
OKAY [ 0.004s]
finished. total time: 0.004s
error: cannot load 'radio-walleye-g8998-00122-1708311414.img'
rebooting into bootloader...
OKAY [ 0.010s]
finished. total time: 0.015s
W/ ( 6448): Unable to open 'image-walleye-opd1.170816.025.zip': No such file or directory
error: failed to open zip file 'image-walleye-opd1.170816.025.zip': I/O Error
Press any key to exit...
 

drmason

Senior Member
Sep 23, 2010
78
10
0
You are calling the flash-all.bat out of a differende directory (C:\Users\W Balls\Downloads\SAMPWND_SYSTEMROOT_ADB_FILES) therefore it can't find the system image files since they are located under C:\U sers\****** Jim\Downloads\walleye-opd1.170816.025-factory-4752baae\walleye-opd1.170816.025. Make sure you extract your image to that directory, open up a command promt and navigate to it with "cd C:\Users\W Balls\Downloads\SAMPWND_SYSTEMROOT_ADB_FILES" and call the flash-all.bat from there.

Check out this for basic command line stuff https://www.digitalcitizen.life/command-prompt-how-use-basic-commands

---------- Post added at 10:58 AM ---------- Previous post was at 10:56 AM ----------

I tried this and it seems the magisk manager isn't able to download magisk on its own at least on my device:

Code:
DownloadManager: [356] Stop requested with status HTTP_DATA_ERROR: Unable to resolve host "forum.xda-developers.com": No address associated with hostname
DownloadManager: [356] Finished with status WAITING_TO_RETRY
EDIT: Seems like DNS66 was blocking the download patching was scucessfull now.

This is weird, can't I make 2 posts in a row??
 
Last edited:
  • Like
Reactions: Schedonnardus

530farm

Senior Member
Aug 3, 2012
614
149
0
Oakland
Anybody figure out a solution for flashing when on MacOs High Sierra? Platform tools 26.0 1 was a fix for high Sierra, yet 26.0.2 seemed to have lost that commit, so fastboot doesn't work at all. Wondering if it's safe to use 26.0.1 on the pixel 2
 

JayBlack_686

Member
Nov 23, 2012
49
6
0
Dallas
Flashing factory images
First, thanks for putting this together. I've rooted using your method.

Regarding OTA updates: I've read that if we've rooted, we will need to un-root before we can receive an OTA update. Is this always true, or only if we've installed a custom recovery like TWRP? It would be really handy to have a guide on how to un-root, update, then re-root.

Related - let's say that for whatever reason, we have to flash an OTA update manually, rather than actually getting it OTA. Do we lose root by doing so?

Thanks!
 

nathanchance

Senior Recognized Developer / Recognized Contribut
Jul 22, 2015
13,748
49,941
113
25
Mesa, AZ
First, thanks for putting this together. I've rooted using your method.

Regarding OTA updates: I've read that if we've rooted, we will need to un-root before we can receive an OTA update. Is this always true, or only if we've installed a custom recovery like TWRP? It would be really handy to have a guide on how to un-root, update, then re-root.

Related - let's say that for whatever reason, we have to flash an OTA update manually, rather than actually getting it OTA. Do we lose root by doing so?

Thanks!
Magisk's OTA section should clear up some of your doubts: https://github.com/topjohnwu/Magisk/blob/master/docs/tips.md#ota-installation-tips
 

JayBlack_686

Member
Nov 23, 2012
49
6
0
Dallas
Last edited:

nathanchance

Senior Recognized Developer / Recognized Contribut
Jul 22, 2015
13,748
49,941
113
25
Mesa, AZ
Looks really straightforward, thank you! Might be cool to point to it in the OP. I bet I'm not the only one who was only vaguely aware of the impact that rooting has on how we get OTAs. Then again, maybe everyone else wants to run custom ROMs.
Good point, I'll add it here in a bit :)

Sent from my Pixel 2 XL using XDA Labs
 

tango650

Member
Nov 9, 2017
6
3
0
OTA vs factory image

Howdy,
really appreciate @nathanchance for putting this together. Would you mind adding a few lines about the differences between OTA and factory images. As a layman i haven't got the foggiest idea which route to go and would appreciate some wisdom. Thanks!
 
  • Like
Reactions: UpGrad3

UpGrad3

Senior Member
Jul 31, 2009
349
28
0
Thank you so much for this guide but can anybody please explain how you can tell which image to patch ?
I am unable to get this to work magisk is showing this message: stock kernel cannot be patched please use a custom kernel
i downloaded: walleye-opd1.170816.010-factory-63083164.zip
unsure as to whether this is correct for my phone as they are quite a few and its unclear how to tell
i have a pixel 2 from the UK that was factory unlocked and i unlocked the boot loader
what am i doing wrong please help
 

nathanchance

Senior Recognized Developer / Recognized Contribut
Jul 22, 2015
13,748
49,941
113
25
Mesa, AZ
Howdy,
really appreciate @nathanchance for putting this together. Would you mind adding a few lines about the differences between OTA and factory images. As a layman i haven't got the foggiest idea which route to go and would appreciate some wisdom. Thanks!
The primary difference is that the OTA can be flashed on an unlocked bootloader and is designed not to wipe your phone.

Thank you so much for this guide but can anybody please explain how you can tell which image to patch ?
I am unable to get this to work magisk is showing this message: stock kernel cannot be patched please use a custom kernel
i downloaded: walleye-opd1.170816.010-factory-63083164.zip
unsure as to whether this is correct for my phone as they are quite a few and its unclear how to tell
i have a pixel 2 from the UK that was factory unlocked and i unlocked the boot loader
what am i doing wrong please help
Are you supplying the boot image to Magisk? Show me a screenshot of what Magisk says when it tries to patch.
 

fjm568

Member
Feb 5, 2012
44
9
0
Thanks @nathanchance for this. I'm not a technical person, but can follow directions. This is the 4th phone that I've rooted following directions of some very smart and talented people here on XDA. I don't do this kind of thing everyday, and am not up on programming or coding or whatever you guys call it now days.

All I ended up doing is taking the OTA from Google to the .025. Then followed the Magisk rooting instructions to get root. I had Unlocked it the first day I turned the phone on, I haven't put my SIM in yet, but will play around with it a little more, and finish setting it up,

Again, thanks for the GUIDE to this Pixel 2 phone.
 
  • Like
Reactions: nathanchance

UpGrad3

Senior Member
Jul 31, 2009
349
28
0
The primary difference is that the OTA can be flashed on an unlocked bootloader and is designed not to wipe your phone.



Are you supplying the boot image to Magisk? Show me a screenshot of what Magisk says when it tries to patch.
That is what i get. I have even flashed the whole factory image to the phone and still get this
 

Attachments

Last edited:

drmason

Senior Member
Sep 23, 2010
78
10
0
@UpGrad3 you need to extract the boot.img out of your zip (walleye-opd1.170816.010-factory-63083164.zip) file and process this one, I'll guess you tried with the whole zip?? Also you can "attach" pictures to the post and not include the full res with the image tags...
 

UpGrad3

Senior Member
Jul 31, 2009
349
28
0
@drmason I did extract the img from the zip. I followed the instructions exactly which is why im so confused as to what is going on ? Ok sorry i will do in future.
Amended post
 
Last edited:

JayBlack_686

Member
Nov 23, 2012
49
6
0
Dallas
@drmason I did extract the img from the zip. I followed the instructions exactly which is why im so confused as to what is going on ? Ok sorry i will do in future.
Amended post
You got the boot.img from the zip file that was inside the zip file?

from https://forum.xda-developers.com/showpost.php?p=74429474&postcount=90

Step by step

1. Download and extract factory image. Mine was taimen-opd1.170816.010-factory-c796ddb4.zip
***2. Once extracted go into the folder and extract image-taimen-opd1.170816.010.zip.
There you will find the boot.img.

---------- Post added at 08:36 AM ---------- Previous post was at 08:27 AM ----------

Good point, I'll add it here in a bit :)

Sent from my Pixel 2 XL using XDA Labs

@nathanchance, one more suggestion for the OP: at one point I was looking at using the stock boot img and couldn't figure out how to get it. Later, I found the below post, where the first two steps are essentially "open the zip inside the zip for the boot.img" to extract the stock boot image. Maybe it's really obvious, but I didn't get it.

https://forum.xda-developers.com/showpost.php?p=74429474&postcount=90
 
Last edited:

UpGrad3

Senior Member
Jul 31, 2009
349
28
0
You got the boot.img from the zip file that was inside the zip file?

from https://forum.xda-developers.com/showpost.php?p=74429474&postcount=90

Step by step

1. Download and extract factory image. Mine was taimen-opd1.170816.010-factory-c796ddb4.zip
***2. Once extracted go into the folder and extract image-taimen-opd1.170816.010.zip.
There you will find the boot.img.

---------- Post added at 08:36 AM ---------- Previous post was at 08:27 AM ----------
this is where i was going wrong i was using a file that had bootloader in the name rather than going into the second zip and finding boot


@nathanchance, one more suggestion for the OP: at one point I was looking at using the stock boot img and couldn't figure out how to get it. Later, I found the below post, where the first two steps are essentially "open the zip inside the zip for the boot.img" to extract the stock boot image. Maybe it's really obvious, but I didn't get it.

https://forum.xda-developers.com/showpost.php?p=74429474&postcount=90
@UpGrad3 you are using the latest Magisk Manager 5.4.1 for this?
yes i was

although im now stuck on the bootscreen with the G any suggestions ?

Fixed.
incase it happens to anyone else. i restored the factory image again then started the root procedure. im now rooted and fully working
 
Last edited: