The Sometimes Rocky Road to Root

Nexus 5 Success

For all my bluster in a previous post about how trivial it is to make a Nexus your own, I seem to have conveniently forgotten that achieving root is sometimes not as easy as I’ve made it out to be.

My seventh rooting of a Nexus device — that’s five phones and two tablets in total — took place yesterday afternoon. The welcome screen you see above is what most users would see on first boot; for me it was a much more elusive prize. What should have taken twenty minutes was instead a two-hour ordeal, entirely due to my own impatience in getting my new toy up and running the way I wanted.

The cool thing about getting yourself into trouble is that you learn stuff along the way. So I’ve documented what happened to me in order to share that knowledge with you.

Prep

Though the infamous CyanogenMod Installer does not yet support the Nexus 5, there are at least a couple of other one-click bootloader-unlocking and rooting solutions out there. But hey, I’m a Linux user, so I’m used to doing things the hard way.

In days of old I would first install the Android SDK — and in so doing have to write a set of udev rules to hidden folders on my Linux box so that it could talk to a Nexus via adb and fastboot. The only real advantage to this was the additional benefit of being able to grab screens from the bootloader and recovery.

Then I discovered that adb and fastboot tools were available directly from my software repos, and forcing a connection between computer and phone was as easy as typing “sudo adb” or “sudo fastboot” in a terminal window. Easy.

I Got This

And so, with much excitement I cracked open the box of my new Nexus 5, connected phone to PC and booted directly into the bootloader by holding the power and volume down keys together. As I’ve already had a taste of Android 4.4 KitKat I didn’t even bother booting into the OS first.

The command “sudo fastboot devices” from my Linux terminal verified a connection; “sudo fastboot oem unlock” yielded a prompt on the Nexus to proceed. I did, and just like that, my bootloader was unlocked.

I had already pointed my terminal window to the folder where my custom recovery image was waiting, so installing that was as easy as typing “sudo fastboot flash recovery (name of recovery file).img”. I prefer TWRP for its excellent support of adb push; like the moniker suggests, you can push zip files directly from your computer to your phone and install them, rather than having to boot into the OS and transfer the files to the device first.

Only problem was, once I booted into my new custom recovery I couldn’t get adb push to work.

I Don’t Got This

During the procedure I had a window open with this XDA guide but wasn’t really paying attention, as I had done this so many times before. Turns out I had missed an important step:

After the bootloader is unlocked you must immediately boot into the OS.

I didn’t, and it put me in a world of hurt.

It was bad enough that I couldn’t install a custom ROM or even a superuser zip via adb push; when I tried to boot into Android proper I was greeted with the dreaded boot loop. My Nexus was trying as hard as it could to start up, but couldn’t.

When in Doubt, Google

A quick search brought me to another XDA thread posted by a user in the exact same situation. Someone suggested that they should restore the original recovery image. The OP went quite a bit further than that…

The Horror

Imagine my trembling fingers as I typed in these terminal commands:

“fastboot erase boot”
“fastboot erase cache”
“fastboot erase recovery”
“fastboot erase system”
“fastboot erase userdata”

That’s right, I wiped each and every partition from my phone, replacing them with a factory image direct from Google.I had never done this before; the good news is that it’s not really that hard — more importantly, it actually worked.

And somehow through all of this, the bootloader remained unlocked.

Once More, With Feeling

Having returned to where I started, I booted immediately into the OS like I was supposed to,  then immediately powered down and re-flashed my TWRP recovery.

This time adb push worked like a charm, and I installed a custom ROM and accompanying Google apps without issue. I booted into my new OS and…

Boot loop!

You’re Bad at This

Turns out that in my haste I had forgotten to do a factory reset while in recovery mode, which was needed to wipe the user data generated from my previous boot into Android. With that little checkbox ticked I could finally boot into my new firmware.

One More Thing

OmniROM is my custom ROM of choice. Despite being a nightly release it seems to work great — but for some strange reason it’s not pre-rooted.

So back into my recovery I went, one more time to flash a superuser zip…

Leave a Reply

Your email address will not be published. Required fields are marked *