Install CyanogenMod on Nexus 4

  Last modified on Friday 21 August 2015

Replace stock Android with CyanogenMod on the Nexus 4 using Linux.

Let's go!

Thanks to a very generous friend who upgraded to a new smartphone I now have her old Google Nexus 4. I have dabbled with alternative Android firmwares in the past, and was inspired to give CyaonogenMod a go on this phone after reading Android without the mothership [].

0. Download

I install CyanogenMod from a host running Debian. Download adb and fastboot install tools:

$ sudo apt-get install android-tools-adb android-tools-fastboot

Nexus 4 device is code-named mako. Download:

1. Developer Options

On the Nexus I enable developer options by navigating to Settings->About phone, click to open and make +7 taps on Build number. Displays You are now a developer. Return to settings and Developer Options is now visible. Click to open and activate USB debugging.

2. Connect device

Connect phone to host via USB:

$ lsusb | grep -i nexus
Bus 001 Device 003: ID 18d1:4ee2 Google Inc. Nexus 4 (debug)
$ adb devices -l
* daemon not running. starting it now on port 5037 *
* daemon started successfully *
List of devices attached
[...]       offline usb:1-12

Confirm Allow usb debugging in pop-up on the phone. Re-run:

$ adb devices -l
List of devices attached
[...]       device usb:1-12 product:occam model:Nexus_4 device:mako

3. Unlock bootloader

Boot the device into fastboot mode:

$ adb reboot bootloader

Once device is in fastboot mode, verify host sees device and unlock:

$ fastboot devices -l
[...]       fastboot usb:1-12
$ fastboot oem unlock

4. Install TWRP

While in fastboot mode flash the TWRP recovery image:

$ fastboot flash recovery twrp-VERSION-mako.img
sending 'recovery' (9028 KB)...
OKAY [  0.287s]
writing 'recovery'...
OKAY [  0.501s]
finished. total time: 0.787s

Reboot the bootloader:

$ fastboot reboot-bootloader
rebooting into bootloader...
OKAY [  0.001s]
finished. total time: 0.001s

Use the device volume keys to navigate to Recovery mode and power key to select. TWRP recovery starts. Tap Wipe and swipe to start Factory Reset.

5. Install CyanogenMod

Copy the CyanogenMod distribution zip file into device:

$ adb push /sdcard
3753 KB/s (263171832 bytes in 68.465s)

Return to TWRP main menu and tap Install. Search in file system for the freshly-installed zip and tap to select. Tap checkbox Zip file signature verification and swipe to confirm flash. The message Successfull should appear. Tap Reboot System and device boots into CyanogenMod. Yes!

6. F-Droid

As a replacement for the non-free Google Play Store app I use the F-Droid free software app repository:

$ adb install /path/to/FDroid.apk
4373 KB/s (3942326 bytes in 0.880s)
        pkg: /data/local/tmp/FDroid.apk

Two apps I like and use daily are fbreader for ebooks and AntennaPod for downloading and listening to podcasts.

Happy hacking!

More • androidlinux