Tag Archives: HowTo

Upgrade your Nexus 5 using factory images without wiping your data

This is a tutorial how you can upgrade with Google’s Nexus factory images without wiping your apps or sdcard, based in a post I found in reddit.

This guide can be easily adapted to other Nexus devices.

NOTE: You must have your bootloader unlocked. If you’ve never unlocked your bootloader, I don’t know there’s any way to do this without wiping your data.

WARNING: If you’re moving between ROMs, you generally should do a complete reset, including wiping data. Many users have reported problems going from Kitkat to Lollipop without wiping data and recommend a factory reset anyway. If you’re okay with wiping everything, you can simply use Google’s included flash-all scripts, or flash the userdata.img file yourself.

STEP 1: Install fastboot and related software

Fastboot is Google’s utility for flashing factory images. You can also use it to flash custom recoveries like TWRP and CWM. The standard way to get is is through Google’s Android SDK, but that’s a bit heavy-duty, so you can also download just the most important tools (fastboot and adb) separately, packaged by users. Here are some links:

Official Google Android SDK (cross-platform): http://developer.android.com/sdk/index.html#Other
Unofficial for Windows: http://developer.android.com/sdk/index.html#Other
Unofficial Mac/Linux: http://code.google.com/p/adb-fastboot-install/
Windows users might also need to install drivers: http://developer.android.com/sdk/win-usb.html (can any Windows users confirm whether it’s necessary?)

To check if the adb is detecting the device, just plug the USB to the computer and write the command inside a terminal:

$adb devices -l

You must see your device listed

Custom recoveries are extremely useful for rooting your phone, installing system tweaks, creating backups, and troubleshooting problems. There are two main options: TWRP and CWM. These are the instructions for the one I use:

Root your phone: In case you would like to do that (you can find arguments here), download the latest SuperSU on your phone from: http://download.chainfire.eu/supersu

STEP 2: Prepare factory image

STEP 3: Flash the new image

  • Connect your phone to your computer via USB, and enter the bootloader. You can enter the bootloader in two ways:
    1. by holding down the power and volume-down buttons to boot. Once you see the bootloader, you can release the buttons.
    2. Running the command:
      $adb reboot bootloader
  • The following syntax might be slightly different on Windows than on Mac or Linux, but basically the same. Anything you see in <> you need to replace, e.g. with the actual path to your factory image folder. The rest you should be able to copy and paste. (Tip: you can easily enter a folder path into your terminal/command prompt by simply dragging the folder onto your terminal window. This works on Mac, Windows, and the vast majority of Linux GUIs.) Enter these commands:
cd </path/to/downloaded files>
$fastboot flash bootloader bootloader-hammerhead-*.img
$fastboot reboot-bootloader
$fastboot flash radio radio-hammerhead-*.img
$fastboot reboot-bootloader
$fastboot flash boot boot.img
$fastboot flash cache cache.img
$fastboot flash system system.img
  • If you DO NOT use a custom recovery (like TWRP or CWM), then also:
$fastboot flash recovery recovery.img

Don’t worry if you see messages like “target reported max download size of 1073741824 bytes”. Just wait and let it finish.

  • If you want to use a custom recovery, see STEP 4.
  • Reboot your phone and enjoy. It’s normal for the first boot to take a while, several minutes in case a a large update (from Kitkat to Lollipop up to 20 minutes).

BONUS STEP 4: Install custom recovery, root and custom kernel

CUSTOM RECOVERY:

  • Boot your phone into the bootloader (see below)
  • From the command line:
$fastboot flash recovery twrp-*-hammerhead.img
  • Boot into recovery (use the volume up/down buttons to select recovery from the bootloader, then the power button to select)
  • In TWRP, go to “mount”, then check “system”
  • Optional: go back to the main TWRP screen, then click through Advanced > File Manager > system > recovery-from-boot.p > Rename File. Rename it to something like recovery-from-boot.p.bak (this is necessary to ensure that Android doesn’t overwrite your custom recovery with the stock recovery on startup)

ROOT:

  • In TWRP, select “Install”, then navigate to wherever you saved the TWRP zip (probably in /sdcard/Download)
  • Swipe to confirm flash
  • In case you want to install a custom kernel (recommended), go to the next paragraph
  • Reboot your phone

CUSTOM KERNEL:

WARNING: Installing a custom kernel can broke the system. If you get strange behaviours, like infinite boot looping, repeat the procedures from STEP 2, and try to not install the custom kernel (or try a different one).

  • Download a custom kernel on your phone. ElementalX and Franco Kernel are quite popular and can be downloaded from their websites. I am using ElementalX.
  • In TWRP, select “Install”, then navigate to wherever you saved the kernel zip (probably in /sdcard/Download)
  • Swipe to confirm flash.
  • System reboot. In case you choose ElementalX, don’t let twrp fix root when it prompts!