Your little handy guide for flashing and rooting Nexus device

- Download Image from https://developers.google.com/android/nexus/images

- Extract the ZIP file.

- Always try running the flash-all script (only if resetting the device. Do NOT run this if updating OS***)

- Open it, extract another ZIP inside it.

- Enable USB Debugging in Settings -> Developer Options

Check that device is detected

$ adb devices

Reboot the device in bootloader

$ adb reboot bootloader — arb *

If you are only rooting your device, jump to rooting section below.

If the device does not have unlocked bootloader

$ fastboot oem unlock

cd into top extracted directory

$ fastboot flash bootloader bootloader-XXX.img
$ fastboot reboot-bootloader — frbootl *
$ fastboot flash radio radio-XXX.img
$ fastboot reboot-bootloader — frbootl *

Erase all data (only if resetting the device. Do NOT run this if updating OS***)

$ fastboot -w

cd into second extracted directory

$ fastboot flash boot boot.img — fboot *
$ fastboot flash recovery recovery.img — freco *
$ fastboot flash cache cache.img — fcache *
$ fastboot flash system system.img — fsys *
$ fastboot flash vendor vendor.img — fvend *(if present)
$ fastboot flash userdata userdata.img (only if resetting the device. Do NOT run this if updating OS***) — fuser *
$ fastboot reboot — frboot *

Rooting Nexus device

Following steps root the Nexus device

Let the phone finish booting into the OS.

Verify in Developer Options that ‘Allow OEM Unlock’ is checked.

Reroot the phone using Chainfire Nexus Root method

http://autoroot.chainfire.eu/

$ sh root-mac.sh

Lock the bootloader if required

$ fastboot oem lock

*** The flash-all script has a line “fastboot -w” which erases all data on the device. Hence, run the script only if you intend to do that.

Another way could be to open the flash-all script and remove “-w” parameter in the fastboot command.

I am not 100% sure if this is because of this -w or because flashing userdata.img

*These are the aliases I have in my shell profile file.

Like what you read? Give Harshad Kale a round of applause.

From a quick cheer to a standing ovation, clap to show how much you enjoyed this story.