Categories
Android

Updating to Android 5.1.0/5.1.1 on rooted Nexus 5

Updated (2015-05-29) – I have tested this method successfully with Android 5.1.1 and have updated the post title/content to reflect this.

Does this post look familiar?
I wrote a post back in December 2014 solving this same problem for Android 5.0.1, whereby a rooted Nexus device will not update via over-the-air (OTA). Rather than go over everything again, I’ll cut straight to the chase of how to update your rooted Nexus 5 to Android 5.1.0/5.1.1 via fastboot.

This guide presumes you’re using either Linux or Mac, with the appropriate Android tools (adb and fastboot) installed, although the Windows method should be much the same. For the purposes of this example, I’ll assume this is the Android 5.1.0/5.1.1 update for Nexus 5 (hammerhead-lmy47d), but the instructions should be similar for future releases.

Note: This will not wipe your device. However, it is always a good idea to back up, as things can always go wrong.

First, download the appropriate Android factory image from the Google Developers site. Uncompress the archive, as well as the archive contained within it, as below:

$> tar -zxf hammerhead-lmy48b-factory-596bb9c1.tgz
$> cd hammerhead-lmy48b
$> unzip image-hammerhead-lmy48b.zip

Next, make sure your device is in fastboot mode (hold VolUp, VolDown and Power button from a powered-off device). Verify your device can be picked up by running fastboot devices, then run the following commands:

$> fastboot flash radio radio-hammerhead-m8974a-2.0.50.2.26.img
$> fastboot reboot-bootloader
$> fastboot flash recovery recovery.img
   (above recovery step is optional - will overwrite custom recovery)
$> fastboot flash boot boot.img
$> fastboot flash system system.img

If all goes well, your device will be flashed with the latest version of Android.

Bonus – re-root your device: grab the appropriate version of CF-Auto-Root for your device, extract it and run the correct root script contained within. Your device will need to be in fastboot mode for this to work.

Credit to /u/laxor09 on Reddit for much of this information.

90 replies on “Updating to Android 5.1.0/5.1.1 on rooted Nexus 5”

probably a good idea to flash the bootloader too. also most users doing this are likely on custom recovery, so no need to flash android recovery unless you really want it. you will have to flash a new recovery like CWM/TWRP regardless, it seems. i thikn i flashed the cache part also…not sure tho. I did what i just wrote and having a smooth experience on my n5 running 5.1 now.

Hey Bert. You don’t flash a bootloader as part of this process. “boot.img” is just the Linux kernel, initrd, etc. It is indeed unlocking your bootloader that causes a loss of data.

Wipe Cache Partition option in fastboot screen is missing!, I have rooted nexus 5, running 5.1.1 using your method. If I flash bootloader too, will it wipe all my data??

Hi Jignesh. You do not flash a bootloader as part of this process. The bootloader is generally specific to the phone. The only (likely) way to lose your data is to flash the userdata image. Please remember to take backups in case anything goes wrong – regardless of what you do!

Hey!

Will flashing the radio relock my bootloader? If so, will that mean I’ll lose all of my data to unlock it again?

Hey Ririshi,

Nope, flashing the radio won’t wipe anything. It’s just the radio firmware blob from what I understand. I think you’re mixing this up with the bootloader.

Hi, Aaron,thank you for your post and I did it exactly the way you wrote. It works fine except my phone become not-rooted anymore. What do you suggest to go back to root the phone? Why did it happen?

Hey Andrew,

Great, delighted it worked for you! If you read the bottom of the blog post – the “Bonus” section – you’ll see I cover exactly how to re-root your phone. Hope this helps 🙂

Hey, does using CF-Root really not wipe my Nexus 5? I’m currently on 5.0, rooted and unlocked, and are still searching for a way not to loose data if I want to upgrade to 5.1 and root my device again.

Thanks!
Eric

I just need to go to the directory and type in

– Mac OS X
— chmod +x root-mac.sh
— Run root-mac.sh

That’s it without wipe?

Yep, that’s it. The “root-mac.sh” command will need to have a “dot slash” (./) in front of it. Also, looking at my shell history, I tend to run the command with superuser privileges using sudo, i.e.

sudo ./root-mac.sh

Hope this helps!

Hey Eric,

Nope, using CF-Auto-Root will not wipe your device. You are thinking of the first time you rooted your device, which involves unlocking the bootloader. Unlocking the bootloader is what (annoyingly) wipes the device. You’re safe!

I’m rooted with 5.0.1, and want to upgrade my N5 to 5.1.0, but i can’t get my Mac to communicate with my N5. adb devices, or ./adb devices doesn’t work, so what am i missing? Thanks.

Hey, sorry for the delay in getting back to you. What exactly is the error ADB is throwing?

hi aaron,
i just rooted my nexus 5 (android 5.0.1) but i didnt install custom recovery and didnt flash my rom yet. i’m thinking to upgrade my android to 5.1 first before doing that.can i?and may i have step by step method by using windows,including command on the cmd. Thank you in advance.

Hi Kalar,

Yes, that should not be any problem. I’m afraid I don’t have a Windows system currently available to test with, but – once you download the Android ADB tools – the commands should likely be the same. You may just need to run them from within the directory you download them to, but I’m afraid I can’t confirm that.

Hi Aaron

In the section on rooting, you link to the chainfire site – but it only lists a root image for Android 5.0.

Is using a 5.0 root image for a 5.1 device going to work?

Hey Chris,

Yep, that’s the one I used. I haven’t experienced any issues. The script itself seems to be relatively simple so there was probably no need for them to change it for 5.1.

But always take a backup beforehand, just in case!

Hi Aaron,

Does OTA updates work as they did previously with a rooted Nexus 5 with the latest Android 5.1 or must we unroot and install manually like with previous versions of Lollipop?

Hi Christopher. Apologies for the delay in responding. I’m afraid you will need to do the updates manually each time. Google seem to have removed support for OTA updates on rooted devices.

Easy to use guide, works great, thank you!

LMY47I now running on my Nexus 5 🙂

I also updated the bootloader (you can check your radio and bootloader versions very easily when in fastboot mode. they are displayed on your devices screen), because in some readme it said, it was required.

CF Auto Root for 5.0 worked fine with 5.1. No issues here.

After applying CF Auto Root, Apps were optimized again. The second time it took a little longer. SU binaries had to be updated too. After a newly reboot, everything is now up and running!

Thanks again. Best from Germany 🙂

Thanks! Your instructions saved me a lot of hassle reinstalling all my apps & configuration issues. Great post!

Hey Aaron,

After doing everything in your guide (flashed all four img’s), my Nexus 5 is stuck in the boot animation. (The four colored balls flying around.) I can’t find a way to start the device anymore. Do you have any ideas what I could do to make my phone work again?

Hey Teemu. Not to worry. We’ll fix this. Possibly a stupid question, but have you tried restarting the device (holding the power button for a few seconds) a few times? There is a memory leak issue with Lollipop that sometimes causes that stuck animation issue. I experience it myself every few boots.

If that doesn’t help, I suggest going through this process again. You won’t (in theory) lose any data, so you shouldn’t worry.

If this fails for some reason, try repeating the same process, but for an older version of Lollipop. If that still fails, you can try also flashing the data img. Please note that this will wipe your data, so take a backup if you can and save it to a PC.

If you’ve done all this and you’re still having no luck, I’d be really inclined to think it’s a hardware issue that has just now crept up, as the software should be being freshly re-applied when you go through this process.

I hope this helps in at least some way. Sorry you’re going through this.

This happened to me because I also flashed the 5.1.1 bootloader.
To workaround this issue, I flashed the bootloader from the older Android 5.1.0 and the Nexus 5 was able to boot normally without being stuck during the boot animation.

Hey Jose. I’m afraid I haven’t had the time to test this with 5.1.1. I would have thought it would work as usual, but Faizan here in the comments has mentioned he had issues with 5.1.1.

Hey again Jose. I have tested this and it does indeed work with 5.1.1. I have updated the post to reflect this.

Hi Aaron, if I do your method and if I don’t reroot, will I then be able to get future updates like normal?

Hey Victor. Yes, if you don’t re-root, you should receive OTAs, as far as I understand. Although I’ve never not rooted my device post-upgrade, so I can’t say for certain.

Hey Bill. I’m afraid I haven’t had the time to test this with 5.1.1. I would have thought it would work as usual, but Faizan here in the comments has mentioned he had issues with 5.1.1.

Just did it, worked fine.

Nexus 4 updated from 5.1.0 to 5.1.1 with this method.

Nothing wiped (but re-root needed).

Yep, I just updated myself a few minutes ago. I’ll update the post 🙂

Yep, I just updated myself a few minutes ago. I’ll update the post 🙂

while upgrading from android 5.1 to android 5.1.1, loading system.img in nexux 5 , error encountered- maximum size exceeds for uploading. pl help

Did it again with your procedure. First with 5.1 and now with 5.1.1. Thanks a lot, Aaron!

Fantastic! Great to hear it’s worked well for you, Arent. Have a great weekend!

Would I also need to do this for my Nexus 5 with Android 5.1 to 5.1.1 or will OTA work and not remove root?

Hi. If you root the device at all, you’ll need to do something like this manual process. As far as I understand, as long as a device is rooted, OTA will now work.

As mentioned above, it is true. The update process checks the fingerprint of the current firmware, and for some reason, it finds that rooted Android is using a test key instead of the production key, so it fails to update. Having TWRP installed, it can be seen if you try the OTA update, once it loads up TWRP select the icon on the bottom of the screen to look at the logs and you’ll see the keys not matching.

If you capture the update file from the cache, you can extract the contents and modify the key it is expecting to match, and then run the update. Issue is it will blow away the root access and will need to re-root using the AutoRoot tool. In the end, performing this is much more work than just following the guide here that Aaron had posted.

Nice, thanks for the tip! Good to know there are alternative/easier methods.

Is it possible to mod the firmware in the Android SDK emulator so it already is rooted before updating?

Just some food for thought, as I know it is possible to re-root afterwards, would like to have the rooted firmware on hand.

Hi Aaron!

I was especially interested in your article because I am running LMY47I on a rooted Nexus 5 as per the instructions I followed on here:

http://www.androidpit.com/how-to-root-nexus-5-on-android-lollipop

This worked fantastically, but when the OTA update to 5.1.1 came out and I tried to install it, of course the CWM Recovery prompt came up with the following:

ClockworkMod Recovery v6.0.4.5
E: Invalid command argument
Finding update package…
Opening update package…
Verifying update package…
E: failed to verify whole-file signature
E: signature verification failed
and
Install Untrusted package?
THIS CAN NOT BE UNDONE.
-NO
-Yes – Install untrusted zip
– +++++Go Back+++++
so, I say Yes, and then,
Installing update…
Package expects build fingerprint of google/hammerhead/hammerhead:5.1/LMY47I/1767468:user/release-keys or google/hammerhead/hammerhead:5.1.1/LMY48B/1863243:user/release-keys; this device has google/hammerhead/hammerhead:4.4/KRT16M/893803:user/release-keys
E: Error in /cache/update.zip
(Status 7)
Installation aborted.
Rebooting…

I’m not sure what this means exactly and am unsure of how to proceed now as I’d love to get the 5.1.1 update but it keeps giving me the above… Any help would be greatly appreciated!

Hi Matthew. Yes, you will need to update manually for all updates as long as you have a rooted device. OTA simply won’t work. It’s a real pain. You should be able to follow the manual process in the post for 5.1.1 without any issue. Take backups, etc. to be safe!

That’s fantastic and really good to know. On a side note, I noticed you omitted the following:

fastboot flash cache cache.img
fastboot flash userdata userdata.img

Are these the things you DON’T flash in order to keep from losing all of one’s already installed apps and data associated with them? I ask because I made the ‘mistake’ of doing so and did end up having to redownload and configure all my apps and re-root my phone (which wasn’t the end of the world, but a hassle nonetheless).

Thanks for all your help again! =]
-Matthew

Hi Matthew. Thanks for your comment and sorry for the delay in getting back. Flashing the cache.img shouldn’t make any difference as far as I know, since it’s just cache. Flashing userdata.img will absolutely remove all your existing configuration, apps, etc.

Thank you very much, it worked like a charm on my Nexus 5! No data loss, even the look & feel of the widgets was the same after the update 😀

Hi,

I have gone through the procedure and ended up with the logo screen dancing forever. no clue how to get from there. I started from a rooted Nexus 5 , still being able to get into fastboot mode, secure boot-enabled, lock state-unlocked, recovery mode ends with little droid “no command” indication. Any idea ?
Thanks,

Oh man, I have no idea, gabdia. I’ve never even heard of that particular error. Sorry I can’t be of any help.

If you get the an error when trying to flash the system like:
load_file: could not allocate 1046266608 bytes
error: cannot load '.\system.img': Not enough space

Use the -S option like this:
fastboot flash -S 512M system system.img

Hope that helps someone.

Excellent instructions. Upgraded from rooted 4.4.2 to 5.1.1. Piece of ake. Worked like a charm. Thank you for your help and hard work.

My absolute pleasure, Albyone! Delighted to hear it worked so well for you. Enjoy Lollipop!

Methode works fine! But now google announced they will reviel monthly securety updates. Problem is those little updates can’t be installed OTA eather. So you have to get the whole factory image with the new patch and go through the whole procedure.
Is there more simple solution?

Great!

Hmmm… hadn’t thought about that actually. I guess we’ll have to wait and see what form the updates come in. Maybe some of them will come through Google Play Services?

Ah, but thinking about it, these will be patches to AOSP, won’t they? Hmmm… looks like monthly flashing will indeed be necessary. Sigh…

I not have Linux or Mac. I have a rooted stock 5.1.1 in nexus 4. It’s shows me a message for updates my system but not install. How can I do it, using Windows? Have done way? Thanks

Hi Anamaria. These instructions should be applicable to Windows using the appropriate Android tools (adb, fastboot, etc.). The tools themselves are the same, I just don’t have the confidence to explain how to do it since I have no test system to work with.

Hey man, this guide is awesome.
It’d be great to know if it works on the Androd M upgrade too.

Cheers!

Hi Antani. Apologies for the late reply. I haven’t tested this with Android Marshmallow yet, but I don’t see why it wouldn’t. As I always say, make sure you take a backup before attempting anything like this. The likelihood of something going wrong is low, but it’s always best to play it on the safe side.

I’ve actually held off upgrading to Android Marshmallow as I have a new Nexus device on the way.

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.