Update Nexus to 5.1 using factory image

With unlocked bootloader, update nexus from 5.0

Download new factory image and extract all contents
Extract all contents of image…zip file just extracted into a folder (images)
Boot to bootloader (adb reboot bootloader)

To update system
– fastboot flash bootloader bootloader…img
(reboot to bootloader)

– fastboot flash radio radio…img
(reboot to bootloader)

cd to images folder containing files of image.zip

– fastboot flash system system.img

update bootloader may be needed if booting process failed.

Don’t flash userdata/no need to flash userdata partition. fastboot flash will erase the partition! It is the same as using -w switch (see below)

To update boot, recovery, system partition without deletion of user data:
– fastboot update image-…zip (NO -w switch!!)

* refer to flash-all.sh/flash-base.sh script for more info

IMPORTANT!
fastboot with -w switch is to ERASE ALL userdata and cache
DO NOT use -w switch if to retain user data!!