Flashing LineageOS on LG/Google Nexus 5 (hammerhead)

7 minute read Published: 2022-10-23

Unfortunately the smartphone I was using since 2018 died. Long story short, tried to replace the battery but it does not charge anymore. I'm not sure if this can be fixed but now I have a more urgent problem to solve. I need another smartphone quickly. Buy a new one? Maybe, but first let's try to put an old friend back on its feet. I'll document the process for my reference.

§ Introducing the LG/Google Nexus 5

Quick intro, courtesy of Wikipedia: "Nexus 5 (code-named Hammerhead) is an Android smartphone sold by Google and manufactured by LG Electronics. (...) It was unveiled on October 31, 2013 and served as the launch device for Android 4.4 KitKat. The Nexus 5 received mostly positive reviews [for its] overall performance (...), cost [and] quality of its display".

It has a 5" screen, 2GB RAM and 16GB storage. What's not to love of this little device!

So, as the description says it comes with Android 4.4 KitKat. The original ROM can be easily restored but it is totally unwise to run such an ancient version. For the record the procedure to perform a factory reset is:

Also video: https://yewtu.be/watch?v=mHJV_UprpE8

I started looking for a third-party ROM. I didn't want to investigate too much so I went straight to LineageOS. Unfortunately the last ROM officially supporting the Nexus 5 (available at this link) only supports LineageOS 14.1 (Android 7.1.2 Nougat) which is quite old. In order to get a more recent ROM one I had to search among the unofficial releases on the XDA forum. The latest I could find is a LineageOS 18.1 (Android 11, 2020). LGTM.

To install a third-party ROM on this device, these are the macro tasks:

Let's see them step by step.

§ Install TWRP

Download TWRP HH.R ("R" means that has repartition support) from this link.

Guide: https://twrp.me/lg/lgnexus5.html

Ensure you have the adb tools installed. Connect the device to the USB port of your computer and check if the Nexus 5 is listed with adb devices.

Now we need to unlock the device, this step is needed to be allowed installing anything on the device:

Rename the TWRP image downloaded to twrp.img (not sure why but it seems to be required). Reboot to the bootloader with adb reboot bootloader and install the TWRP recovery ROM with fastboot flash recovery twrp.img.

Reboot to finalize the installation with fastboot reboot while holding volume up+down. At the Android menu select "recovery mode" -> TWRP menu will appear.

§ Enlarge the /system partition

Repartition guide at this link, specifically this comment:

  1. Flash twrp-3.3.1-HH-hammerhead.img (done in the previous steps)
  2. Open terminal (TWRP -> Advanced -> Terminal)
  3. Type hh_repar -m
  4. Wait until your phone reboots

How to revert everything:

  1. Open terminal (TWRP -> Advanced -> Terminal)
  2. Type hh_repart -r
  3. Wait until your phone reboots
  4. Install original TWRP (3.3.1-0 at the current moment)

§ Sideload LineageOS + gapps

The following guide is copied from this tutorial.

Download the unofficial LineageOS from this link and the correct Google apps at this link. I choose the "pico" version because I don't use any Google Apps (calendar, chat, maps, etc.) but I need to access Google Play to download some apps that won't ever be published on F-droid.

Now we are ready to install the new operating system!

Sideload the LineageOS .zip package:

Then sideload the gapps with: adb sideload gapps.zip

Reboot to close the procedure: adb reboot

To access again the TWRP menu:

§ Conclusions

After installing all the apps that I need (unfortunately more than I'd like), now that I have in front of me a fully functional smartphone again at almost zero cost (just about $15.00 for a new battery), here's the mandatory rant about the planned obsolescence of modern devices.

A contingent situation pushed me to experiment if a relatively old phone (2013) was still usable and I discovered that it is indeed a completely valid device for everyday use, though a bit limited because of the meager space ("only" 16GB, about 40% of that already taken by the apps and data). Coupled with the impossibility to add an SD card, certainly this is not a device that I can use for a lot of multimedia content. Other than that, it won't be the snappiest smartphone, but it does its job.

In these times where the world is changing behind our eyes, I feel before I was living in a sort of bubble where electronic devices were cheap by definition (why shouldn't be, right?) and it was easy to order a single nail from the other side of the world. Now things are becoming different and we need to adjust accordingly. In particular, asking healthy questions about sustainability and trying to use out devices and tools until it's possible.

Once again, volunteers of free/open source projects have reached out to the needs of the community and solved a problem that the companies, focused on (and sometimes blinded by) their profits don't want to fix.

Before, it was annoying thinking that mobile devices are so artificially chocked and hard to hack, but now it is becoming more and more a criminal offense against the environment and the global economic/political world situation. We cannot afford anymore this level of reckless consumerism and now it is right under our eyes. Companies producing consumer electronics should become extremely aware now and should be mandated by law to have more sustainable policies (not the mild green-washing they trump on they're websites).

By the way, same applies for my now dead smartphone. If it was even limitedly serviceable, maybe I could investigate the issue myself (or more probably a laboratory with the proper know-how and tools) or just change a component.