How to flash factory image on any Nexus device to return to stock

A couple of days ago, Google released the Android 4.4 KitKat factory images for the Nexus 4, 7 (2012/2013) and the Nexus 10. The factory images were already available for download on the day the device went up for sale on the Play Store. Factory images are a great way of completely resetting your Nexus device and putting them back to stock.

If you have rooted, flashed a custom ROM on your Nexus device but now want to go back to complete stock, simply follow the steps below. Do note that the below steps will completely wipe your Nexus of any data, so make backups. Also, you will need to have an unlocked bootloader to flash the factory image.

Step 1: Download the ADB/Fastboot files and the USB drivers for Windows based PC first. The the latest factory image for your Nexus device can be downloaded directly from Google’s website.

Extract the contents of the ADB/Fastboot ZIP file inside a new folder called ‘google’ on your desktop. Extract and transfer the contents of the factory image inside this folder as well. The list of files will include a ZIP file containing the codename of your Android device, two files with “flash-all” names, and a bootloader image file. All the extracted contents of the factory image should be inside the same folder as the ADB and Fastboot file, otherwise you will get a file not found error.


Make sure to install the ADB drivers as well if you are running a Windows based PC.

Step 2:  Now, reboot your Nexus device in bootloader mode. This is usually done by switching off the device, and pressing the Volume down + Volume Up + Power button simultaneously. If that does not work, try the Volume down + Power button combination.

After the device has booted into bootloader mode, connect it to your PC.

Step 3: Open a new Terminal or Command Prompt window, and navigate to the ‘google’ folder that you created in Step 1. Before we start flashing the factory image, we need to make sure that your Nexus device is being detected by the PC.

fastboot devices

If you are using a Mac, then you need to prefix a “./” before every Fastboot command. So, the above command will look something like this on a Mac -:

./fastboot devices

The above command should confirm if your device is indeed being detected by your PC or not. If it is, then proceed to the steps below. If not, repeat the steps above again. Make sure that you have properly installed the drivers and are inside the correct folder.


If you are running Windows, copy-paste the following command in the command prompt window -:


On a Mac, copy-paste the following command -:


The script will then automatically flash the full factory image on your Nexus device. Once the factory image has been fully flashed, your device will automatically reboot. Keep in mind that the first boot might take some time so please be patient.

The flash-all script included in the factory image might not work for all. It has always been pretty unreliable and has only worked once for me in the last 2 years. If you are in the same boat as me, you will have to flash each partition manually on your device. This is slightly cumbersome though.

The command to manually flash a partition via fastboot is “fastboot flash partition filename.img”. In the factory image that you extracted in Step 1, you will notice there is another ZIP file. Extract the contents of that ZIP file inside the ‘google’ folder.


Now, its time to manually flash the partitions to your Nexus device. We will first begin with the bootloader.

fastboot flash bootloader filename.img

Then, we will flash all other partitions. They don’t necessarily need to be in the same order as I have listed them below. The names of the image files in the factory image will clearly indicate the partition they are intended for as well.

fastboot flash boot filename.img

fastboot flash radio filename.img

fastboot flash recovery filename.img

fastboot flash userdata filename.img

fastboot flash system filename.img

If you want to relock the bootloader of your device after flashing the device, put the device back in fastboot mode. Then type in the following command in the Terminal or Command Window you had opened earlier -:

fastboot oem lock

This will re-lock the bootloader of your Nexus device, restoring your warranty and putting the device back to complete stock.

Like this post? Share it!
  • Josh Sevigny

    I am trying to do a clean install of Android 4.4 on a 2013 nexus 7 wifi model. Is there not an easier way to do a “clean install”? I have tried seemingly everything. By the way I am using a Mac.

    When I run ./ It says something like line 18 fastboot command not found.

    I have tried troubleshooting this for hours

    Thanks in advance.

    • Rajesh

      Ah. The flash-all script fails to work sometimes. You will need to extract all the image files from the ZIP file in the factory image, and then flash manually. This will be a bit tedious though.

      Make sure fastboot file is inside the same folder as the factory image files. I will update the guide in a few hours and include the steps to manually flash each partition.

      • Josh Sevigny

        Wow that was a fast response! Thanks so much!

        • Antonio Giammalvo

          i’m having the same problem with my nexus 4… help!!!

          • Josh

            Rajesh updated the guide. I haven’t tried it yet, but it looks promising.

          • sunil

            I am having nexus 7 wifi model and stuck at the black screen with Google..How much I should wait…?

          • SHASHIDHAR GA

            I’ve updated my Nexus 7 (2013) to Kitkat 4.4.2. I noticed slow loading of webpages. So now I want to restore to my factory image of Jelly Bean 4.3. My Nexus is 2013 edition LTE unlocked. Shall I follow the above procedure. Is it necessary to relock the bootloader after flashing.

          • rash

            try editing the file and put ./ before each fastboot command in for mac os. works for me

      • Josh

        That worked great!!! Clean start on KitKat!!!! I love learning new stuff like that.


    • Rajesh

      Updated the guide. You can flash the factory image manually now.

      • Josh

        Great! Thank you! I will try again later this evening.

  • friv 2 friv 3 friv 4

    Wow that was a fast response! Thanks so much!

  • p.menziesii

    It should be noted perhaps more strenuously: locking/unlocking the bootloader will wipe the sd card of the Nexus device. Additionally, flashing the userdata partition will aslo erase the sd card. It was mentioned in the article, but it’s a detail that could be quite easily missed by some folks. In the past, it has been entirely possible to flash back to stock without flashing the userdata partition, and if your device bootloader is already unlocked, there’s no real reason to re-lock it.

    • Rajesh

      If you want to go back to complete stock, like the way your device shipped from Google, re-locking the bootloader is neccessary. Also, for warranty claims.

  • matt

    Another thing to watch out for… depending on how you got into the situation, you may need to clear the cache before it will boot. In my case, [fastboot erase cache] was not good enough… had to boot into the stock recovery console and select from the menu. After that, first boot was successful after a minute or two. Previously, waited 10+ minutes (several times) with no successful boot.

    This was on a Nexus 4

    • Luis Paredes

      Mine is taking more than 15 minutes and doesn’t boot. Can you please be more specific on how to clear the cache?

    • Mara

      Hi Matt, I am having your same issue here. Keep loading and not boot. How did you ” boot into the stock recovery console and select from the menu” can you please guide me here, I am a newbie. Cheers

    • Matt

      Hi Mara and Luis,

      Once you have done the [fastboot flash recovery filename.img] you will have the stock recovery console, rather than something like TWRP (which you might have if you’ve ever rooted your phone.) To get to it, boot into the bootloader menu (as in Step 2 above,) and select the Recover Console. When it loads you will see an image that looks like a robot with its front cover over. You can open the menu from here with Power + Volume Up; there will be an option to clear the cache. Worked for me. Good luck!

  • ProbablyHittingOnYou

    After trying to sideload forever, this worked. Thanks!!

  • Parvath

    Good one Rajesh. May be you can also add that USB debugging needs to be enabled.

  • JIns

    Manual flashing worked fine! Thx a lot man!

  • ChrisT

    I have a problem….bootloader image cannot be installed ….device product is mako, update requires tilapia ?! what should I do ?!

  • Ran Shalmir

    Thanks!! Manged to fix my Nexus 7 after the 4.4 updated failed and it would stay stuck on the boot screen :)

  • Akeel

    I’ve followed the steps to manually flash on my Nexus 5. All the factory images loaded completely. But i the phone will not load now. I keep getting the “4 circles spinning” sign. Do i need to load the cache file as well?

  • Edmund Palmer

    Follows ur instructions to the t and now my 32 GB shows up as 16 GB. Any ideas?

    • newbee

      i ‘ve read somewhere you need to “restore to factory default” in your settings…afterwards maybe everything is ok again?

  • Ali

    first of all thanks for guid
    but I got into some problems and I would be appreciated if you help me to solve theme
    I have nexus 10, so I downloaded “4.4.2 (KOT49H)” from google but I don’t have “radio” image file, and I don’t know what should I do for these comments
    “””fastboot flash radio filename.img”””
    is it ok?

    • psyck

      you dont need the radio image if your device is just a wland device and has no umts built.
      worked for me perfectly on my nexus7

      fastboot flash bootloader
      fastboot reboot-bootloader
      fastboot flash system
      fastboot flash boot
      fastboot flash userdata
      fastboot reboot

  • Derrick Crasta

    Excellent worked for me, Thanks a million

  • hilmi

    i tried all the step above on for nxs4 on Mac, but failed.
    i cannot manually flash the partition.
    all the partition


    I downloaded the fastboot/adb and I do not have the flash-all.bat file in there help please. also my stock image is a .tgz file and i cannot see any files within to able to extract. there is no zip file. when i extracted it the file became a .tar file. What am I doing wrong?

  • Biggie

    finally ur method of using flash.bat works. my nexus 10 is fully working nw

  • Manuk

    THANK YOU SO MATCH!!!!!!!!!! It helps me Nexus 7 first generation.

  • HuShifang

    This procedure worked great for me. My Nexus 10 (unrooted, running stock 4.4.2) could only enter the bootloader – when I tried to get into recovery mode or boot regularly, it would get stuck on the “Google” screen. Using ADB and Fastboot 1.1 (downloaded from XDA) and following this procedure, I first flashed the cache partition; this got me to the “spotlight” boot screen, though not past it. When I used the flash-all.bat command, it worked like a charm, and my device was once again fully operational. (One thing not mentioned here – you can use ADB and Fastboot 1.1 to unlock your bootloader using the command “fastboot oem unlock”; ADB will actually prompt you to do this if you try flashing before unlocking.)