This is an A-Z guide for you to manually install a factory image to your nexus device or root your nexus device or both. If you have crashed your custom ROM or if you have badly screwed your device and you still have access to your bootloader, then this guide will probably work for you too. If you were brought here in the name of “Written companion” you’re at the right place.
<The latest android version during the making of this guide was Android Lollipop 5.0.2>
DISCLAIMER: I’m not responsible for any harm that may happen for not following the steps properly.
(The process works, but don’t want to take unwanted blame)
List of Software/Hardware required
- A PC/Laptop running any version of Ubuntu
- A Nexus 4,5,6,7,9 or 10 (it may work for the older devices too)
- micro-USB to USB cable
- Fastboot(optional, only for root): download it from here
- Factory image file, download from here. Please download the correct version.
- Patience depending upon how fast or slow your internet is.
After downloading all the required files, it will take utmost 15 minutes to get through the installation and the rooting process. Please ensure that you have all your data backed up, and ensure that you have 50% of charge in your battery. Connect your phone/tablet to your Ubuntu PC using the micro-USB to USB cable and you are good to go.
<Terminal shortcut : Ctrl+Alt+t>
Before going through the steps, Make sure that you follow the stream of the steps as I sort according to the task that has to be performed.
- If you want to manually install the factory image only, Follow all the steps, skip step 5. Also need not download the fastboot.zip file.
- If you want to root you device only,
After Step 1 and Step 2, run the command
$sudo fastboot oem unlock
skip step 3, continue with the remaining steps.
- If you want to do both, you got to do all the steps.
Step 1: Install fastboot and adb development tools
In the terminal run the following two commands:
$sudo apt-get install android-tools-adb
$sudo apt-get install android-tools-fastboot
Step 2: Enable USB debugging in your phone/tablet
Head to your device settings,
Settings>About phone/tablet>Build number
Tap the build number 7 times. This will recognise you as a developer. This will also unhide the “Developer options” hidden in your settings.
Again head to your device settings,
Settings>Developer Options>Tick/Check the USB debugging option.
Assuming that you have connected your device to the computer and have never done this steps before, you’ll get a pop up asking you to authenticate your current connected PC, Press ok to this pop up.
Step 3: Flash the Factory Image
Extract the factory-image.zip file and Fastboot.zip file(fastboot is optional, if you intend to root your device) to a known location in your computer. Move “fastboot-linux” and “adb-linux” to the unpacked factory-image folder. Also ensure that your Factory image folder has a shell script named “flash-all.sh”.
In your terminal, traverse to the factory-image folder,
Run the following commands:
$adb reboot bootloader
(the fist command will reboot your device to the bootloader, and the second command will actually flash the factory image, bootloader etc to your device)
You’ll need to authorize the request to unlock the bootloader, the flashing step may take a while. (unlocking the bootloader voids the warranty. We’ll lock the bootloader in the last step)
After the flashing is complete the Device should boot to the OS,
- If at all you are stuck in a bootloop, redo step 3.
- If you are unable to run adb reboot bootloader command, you can manually boot to the bootloader by:
-Press the power button for about 7-10 seconds.
-Press volume down when the system reboots.
- Finally an issue I have encountered personally, sometimes it may take forever to boot to your OS, In that case, disconnect your device (ONLY IF THE FLASHING PROCESS IS COMPLETE), and reboot. After you boot to your OS reconnect your device to the computer.
Step 4: Enable USB debugging
Same as Step 2, enable USB debugging.
After this step, reboot to the bootloader using the command:
$ adb reboot bootloader
Step 5(optional, for rooting only): Installing custom recovery and finally rooting your device
Download latest twrp recovery toolkit from their official website for
Nexus 4 , Nexus 5 , Nexus 6 , Nexus 7 WiFi , Nexus 7 3G , Nexus 7 (2013) WiFi , Nexus 7 (2013) LTE , Nexus 9 , Nexus 10
(you’ll need twrp version 220.127.116.11 minimum to root android lollipop devices)
please check that you are downloading the latest version from their official website : TWRP device list
Save this image file to a known location in your computer. Flash the custom recovery image file using the following command:
$ sudo fastboot flash recovery path_to_recovery_image.img
(path_to_recovery_image.img has to be replaced with the actual path to the recovery image)
then in your device’s bootloader, boot to the recovery mode(using the volume up-down keys for navigation).
In the recovery choose the reboot option, and then choose reboot to recovery(you could select system, I’m doing it ensure proper flash of the SuperSU). Before rebooting you’ll be asked if you want to install SuperSU to root your device, please swipe to install SuperSu.
After the SuperSu installation is done your device should reboot to the recovery where you can choose:
Reboot, and then choose reboot to system.
After you boot to your android OS. There will be a notification waiting for you to install SuperSU, Tap to that notification (If not search for SuperSU in your app drawer and open it) . Choose your method of installing SuperSU. After the installation is complete. You’ll get a SuperSU installer pop up to reboot to TWRP and install SuperSU, Select continue to finish rooting your device.
After the reboot to the OS is complete, your device should now be rooted. Please confirm by installing applications that require root.
(Personal recommendation) Root Checker, iFont, Titanium Backup etc.
After confirming root, boot to your boot loader,
$adb reboot bootloader
Step 6: Lock your bootloader
The unlock sign that appears on the bottom of the screen is a clear indication that your warranty is void. This can easily be taken care off, by locking the bootloader
(If you have followed the flow of steps then you are probably in the bootloader mode already, if not run $adb reboot bootloader in your terminal)
To Lock your bootloader, run the following command in your terminal.
$sudo fastboot oem lock
Select Start and you are good to go, This ends our Manual Installation and Root guide for all nexus devices.
Do checkout my video on the same if you have any confusions.
Connect with me on
Feel free to comment.
This is Sahil Satishkumar logging out.
P.S.:HAPPY NEW YEAR!