Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
A step-by-step guide how to manually flash the Android 5.0.1 (LRX22C) OTA-Update on a Nexus 5 with modified system (custom recovery/kernel, rooted, modified framework etc.)..

Update: For those interested, here's the version for updating from Android 5.1.0 (LMY47D/LMY47I) to Android 5.1.1 (LMY48B):

     SET `VERSION`='5.0.1', `BUILD`='LRX22C', `RECOVERY`='CUSTOM', `ROOTED`=1 
   WHERE `VERSION`='5.0' && `BUILD`='LRX21O' && `RECOVERY`='CUSTOM' && `ROOTED`=1 
         && `WANNA_KEEP_USERDATA`=1;

A manual OTA for rooted hammerheads, quasi.

When you tampered with the Android system, you can't install OTAs; installation fails. Sometimes it's enough to flash the stock recovery to use adb sideload, but often, especially when you tampered a lot, this also fails.

Even after unrooting and flashing stock boot, recovery and cache it can fail. So one might ask whether the only way is to do a clean install using the latest factory image instead. For those who ask themselves this question: Before you do so, take a minute and read on.

This document describes how I successfully updated my Nexus 5 from stock Android 5.0 (LRX21O) with TWRP and rooted with SuperSU to Android 5.0.1 (LRX22C) with TWRP and rooted with SuperSU - without loosing user data.

NOTE: The steps outlined in this document assume the Android SDK to be installed on your PC and the adb, fastboot and android.[bat|sh] to be in your PATH variable! Oh, and if it burns down your house, it's not my fault. Proceed at own risk.

Download & prepare files

  • Download OTA zip from Google's servers to your PC. -

  • Rename the downloaded zip to '' (without the quotes (and if you're on windows and known file extension are hidden, make sure you not end up with

  • To the same folder, download the latest SuperSU flashable zip. -

  • To the same folder, download the latest TWRP recovery image for hammerhead. - openrecovery-twrp-

  • To the same folder, download the 5.0 factory image tgz archive from Google's servers. - hammerhead-lrx21o-factory-01315e08.tgz

  • From the 5.0 tgz archive extract the recovery.img, boot.img and system.img files to the same directory where your downloads are located.
    (Tip: With 7zip, for example, you can 'internally' open the archives within the archive and extract just the files you need. The same is possible with command line tools, of course.)

The directory structure should look like this now:


Time for the command line..

Open a terminal on your PC and cd into the directory where your downloaded files are located. Now go on by running the commands in the terminal as follows (type only those lines prefixed with '> ', but without actually typing the '> '!).

Update platform tools
# On Windows:
> android.bat update sdk -u -t platform-tools,tools
# On Linux/Mac:
> update sdk -u -t platform-tools,tools

You may need to accept a license agreement. Type 'y' and hit enter.

Do you accept the license 'android-sdk-license-5be876d5' [y/n]: y
Installing Archives:
  Preparing to install archives
  Downloading Android SDK Tools, revision 24.0.2
  Installing Android SDK Tools, revision 24.0.2
    Installed Android SDK Tools, revision 24.0.299%)
    Done. 1 package installed.</code>
Update adb
# On Windows:
> android.bat update adb
# On Linux/Mac:
> update adb

If adb was updated, command line will ask you to restart it. Do so.

adb has been updated. You must restart adb with the following commands
      adb kill-server
      adb start-server


Now, we're finally ready to go..

Time for flashing..

Connect your device (USB debugging enabled, of course) to your PC.

Back at your terminal, go on by running the commands as follows (type only those lines prefixed with '> ', but without actually typing the '> '!).

# Make sure the device is recognized
> adb devices

# Boot into bootloader mode
> adb reboot bootloader

# In bootloader mode, make again sure the device is recognized
> fastboot devices

# Flash stock LRX21O recovery image
> fastboot flash recovery recovery.img

# Flash stock LRX21O system image
> fastboot flash system system.img

# Flash stock LRX21O boot image
> fastboot flash boot boot.img

When the last flash is confirmed, use the volume rockers to choose 'Recovery mode' and confirm with the power button.

When you see the little Android lying with the red triangle warning sign on it, hold the power then press the volume up button to get to the recovery options.

When you got to the recovery options, select 'apply update from ADB' using the volume rockers again and press the power button to choose it. When the device says it's awaiting commands, type from the PC's command line:

adb sideload

When OTA update successfully installed, select 'reboot bootloader' from the recovery options again using the volume rockers and press the power button.

Back in bootloader mode, type from the PC's command line:

fastboot flash recovery openrecovery-twrp-

When the flash is confirmed, use the volume rockers to choose 'Recovery mode' and confirm with the power button.

Now in the TWRP recovery menu, choose 'Advanced' > 'adb sideload'. Check both option, clear 'Dalvik-Cache' and 'Clear Cache' and swipe the bar to start sideload mode. When the device says it's awaiting commands, type from the PC's command line:

adb sideload

When done, confirm to reboot system. Finished. Mission completed.

You're now on 5.0.1 with your custom recovery, rooted and can pick up from where you left.

PS: First boot, as always, will take some minutes.

Copy link

onedyle commented Dec 26, 2014

Thank you so much. Works perfectly.

Copy link

robrich commented Dec 28, 2014

@jonmcoe is right, it's trivial to get into stock recovery: power then volume up. PR from

Copy link

eyecatchup commented Dec 29, 2014

@robich yes, I also recognized this now (after I've read @jonmcoe's comment). True, it's actually trivial. As long as you follow the correct instructions. I'm not sure why, but all guides, I've been gone through so far, explained it wrong - as they suggested that you'd need to do it simultaneously?! Anyway. To get it right for this guide, I'd like to "merge" your "PR". Now, either I'm blind or dumb (or it's cause I'm on mobile).. But, is there any real PR functionality for gists? Or were you suggesting your version as "PR" PR?

Copy link

eyecatchup commented Dec 29, 2014

Updated gist.

Copy link

NimoTh commented Dec 30, 2014

Why don't you directly get, unpack and flash the 5.0.1 recovery, system and boot? Why the detour via old 5.0 images?

Copy link

eyecatchup commented Dec 30, 2014

Of course, you could also dirty flash the respective 5.0.1 partitions. That's one solution.

However, from my flashing experience (which dates back to the GRF39K for the Nexus One), I found to have less corrupted flashes (meaning, that the procedure resulted in anything between boot loops and, at best, permanent FCs) when I dirty flash the current version's required partions, applying the official OTA, and flashing back my custom recovery and install the latest SuperSU zip.

It might be totally up to my side and upstream dirty flashing might be as "safe" as this method. Who ever knows!? Anyway, both methods are equally valid and should both work the same. Just for said reason, I use the, let's say, "less-straight-forward way".

But, to be fair, if everything is set up, it's actually also not that much of a work. ;) (PS: And a guide, as detailed as this, for the other method, BTW, is probably just as "long" as this guide.)

Copy link

DIGINEX-zz commented Jan 9, 2015

From the command lines on updating the platform-tools, I get an error "please consider trying to update again without a package filter" and the confirmation message you've displayed doesn't even shown up.
Then went over through adb update and , followed the kill-server and start-server respectively. Then the rest of the flashing commands went smoothly till the sideload began from stock recovery.

"adb sideload"

Protocol Error within the command terminal and displayed, "You need to update to ADB 1.0.32 to sideload from this device".

From the SDK UI, the Android SDK tools and Android Platform-tools have been updated to latest. What really hinders the ADB from getting updated, The first command "android.bat update sdk -u -t platform-tools,tools" went running from cd to path "C:\Program Files (x86)\Android\android-sdk\tools"


Copy link

lahwran commented Jan 10, 2015

I used this to update from 4.4.4 ... and somehow ended up on 5.0.0? what? retrying the guide again, since presumably it goes from 5.0.0 to 5.0.1...

Copy link

DIGINEX-zz commented Jan 10, 2015

My ADB issue is solved at last, Please fix the TWRP version to from, as it may not push out of the curtains for most of the users. I panicked at very similar point and end up spending a few hours figuring up this!

Copy link

nathantsoi commented Jan 14, 2015

thx @eyecatchup, worked great. I put the whole thing in a bash script if anyone else needs to do this:

Copy link

eyecatchup commented Jan 19, 2015

seems useful to me, @nathantsoi. ty

Copy link

consultant1027 commented Jan 23, 2015

Can someone confirm what (if anything) should be changed in the instructions to go from 4.4.4 to 5.0.1?

Copy link

djhworld commented Jan 24, 2015


I just did exactly this but I played it safe by upgrading to 5.0 first, my setup was as follows

  • Nexus 5 running 4.4.4
  • TWRP 2.6 installed.

Disclaimer: please be careful, this worked for me but might not work for others!

Upgrading to 5.0.0

Follow the instructions here, these are a fork of the instructions above, the difference is you are downloading the 5.0.0 OTA update and 4.4.4 factory image instead of the 5.0.1 OTA update and 5.0 factory image

Upgrading to 5.0.1

Once I was on 5.0.0, I performed everything above "as is" and it worked great!

Thanks @eyecatchup !!

Copy link

Karmac commented Feb 7, 2015

Awesome working perfectly! thanks!

Copy link

minj2me commented Feb 16, 2015 was working perfectly, thank you!

Copy link

davidramos-om commented Feb 25, 2015

Thanks a lot, I was thinking my nexus died cause I deleted all data trying to root in last week (Sistem, Recovery,etc.)

Now it works.

Copy link

leewc commented Feb 28, 2015

This was great, thank you! Also note to some people who might get stuck on this part:

"When you see the little Android lying with the red triangle warning sign on it, hold the power then press the volume up button to get to the recovery options."

Notice that the tutorial mentions HOLD the power THEN press the volume up, if you hold power AND volume up you'll just do a force reboot. (at that time just do adb reboot bootloader again)

EDIT: also, if you happen to receive an error about not having permissions when in stock recovery:

adb sideload
loading: ''
error: insufficient permissions for device

Just do 'adb kill-server' then 'sudo adb start-server' which if it says adb command not found then manually point to the absolute path of adb, for example mine was in /Development/android/android-sdk-linux/platform-tools/adb

good luck!

Copy link

ev0rtex commented Mar 12, 2015

FYI, this is actually a pretty generic process and the same process will work with future updates and even on the Nexus 6 (except that download links will vary obviously). I just installed the 5.1 update (LMY47D) on my Nexus 6 using the same procedure. The only catch is that I had to unplug/replug my USB cable whenever I entered sideload mode so that adb would detect it.

Copy link

Leomosantos commented Mar 27, 2015

My Nexus 5 is running Android 5.0.1, with TWRP, Xposed and ElementalX kernel. Will I be able to update to 5.1 following these steps?

Copy link

jacobsin commented Apr 2, 2015

Thanks! Works for updating from 5.0.1 to 5.1.

Copy link

apporc commented Apr 9, 2015

I have just found that, the radio is needed to be rolled back too.

Copy link

singles commented Apr 23, 2015

Thanks you for this tutorial. Just used it (with minor changes) to update Nexus 4 from 5.0.1 to 5.1.0. 🍻

Copy link

mcampbell commented May 25, 2015

This worked fantastically well. I was stuck with a "release-keys" not matching issue trying to sideload 5.1.1 over 5.1 (a problem I've had since 4.4), and finally found this page and was able to get past it.

Thanks so much for putting this out in such a straightforward manner.

Copy link

anthonybaldwin commented May 31, 2015

Found this searching how to sideload the 5.1.1 OTA update to my rooted Nexus 6. Worked perfectly. Thank you!

Copy link

yuvilio commented Jun 4, 2015

Seems like twrp dropped the 'openrecovery' prefix. For my my 5.1.1 update on Nexus 5, the latest file was 'twrp-' . The sideload command works fine. Thanks for this.

Copy link

eyecatchup commented Jun 29, 2015

For those interested, here's the version for updating to Android 5.1.1 (LMY48B):

Copy link

eyecatchup commented Jun 29, 2015

If you run into the following error message:

target reported max download size of 1073741824 bytes
error: cannot load 'system.img'

Just use: fastboot flash -S 512M system system.img


Copy link

albinsuresh commented Aug 14, 2015

Can someone tell me where you get the OTA update links from? People have posted links for specific versions. But is there any generic URL or something where I can find OTA zips for different versions or rather the most recent version?

Copy link

hackel commented Aug 24, 2015

Just keep in mind this will still erase any customizations you may have made... build.prop, Xposed, busybox, init.d, etc. The Android update system really is crap.

Copy link

INFINITEKIFF commented Oct 13, 2016

My Nexus 5 is running Android 6.0.1, with TWRP, Xposed and ElementalX kernel. Will I be able to update to the 2016-10 security patches following these steps? sick of getting the notifcations which obviously dont go away until you apply the patch. obviously being a noob I discovered I cant apply these patches without first losing root since ota replaces twrp custom recovery right? or am I getting confised, theres so many steps?! I know last time I managed to do it from lollipop to MM but that wasnt a security patch update, so somehow updating the OS seemed easier, this whole security patch thing seems confusing and daunting?? what about if I have Flashfire installed, sint that supposed to retain Root? someone out there with a good idea about how to proceed safely? thanks in advance

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment