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 flashed, your device will automatically reboot. Keep in mind that the first boot might take some time so please be patient.

If the script gives you a fastboot not found error on your Mac, open up the file in Text Edit and add a “./” before every fastboot command.

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.

Update: You can find the steps to flash the Android 6.0 Marshmallow factory image on your Nexus 5, Nexus 6, Nexus 7, and Nexus 9 here.

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

          • AlRegals

            That gave me No such file or directory

      • 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.

  • 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!

      • patrissimo

        Note: I had the same problem, I cleared the cache w/ your instructins, and it didn’t help. I tried 4.4 and 4.3, only difference is whether the boot screen it gets stuck on is an X (4.3) or 4 colored balls (4.4).

        What worked was doing a factory data reset from the same menu as clearing the cache.

  • 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 ?!

    • JOJO

      You just use” Nexus Root Toolkit” advanced option

  • 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?

    • Jeff Jacob

      A tar file is like a zip file but with no compression. Use 7zip to extract it.

    • JOJO

      Just once again the.tar file you will find all files mentioned above.

  • 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.)

  • Christopher Ohlsen

    This worked for me. Flash-all did not work but individually flashing each partition manually did. Soft Bricked Nexus 10 on unroot (Wanted newest update 4.4.2) attempt with faulty cable. Got new cable, followed instructions, and Voila:) Thanks!

  • Adrian

    Managed to recover a friend’s Nexus 7 using this guide. Many thanks!

  • tomtom

    Sorry but your package download link gives me a dropbox warning. Do you have an alternate dl for me? Thanks

  • Bryan Vazquez

    If you are on a Mac, edit the Inside there will be some commands:

    fastboot flash bootloader bootloader-flo-flo-04.02.img

    fastboot reboot-bootloader

    sleep 5

    fastboot -w update

    Edit them, so they look like this.

    ./fastboot flash bootloader bootloader-flo-flo-04.02.img

    ./fastboot reboot-bootloader

    sleep 5

    ./fastboot -w update

    Now, on the command app, try the ./

    It should be working!!!

    • Claudio Marcello

      what’s “sleep 5” for?

  • reframmellator

    First “definitive” guide I found (and I tried more thanm 10) that got me around a balky USB handshake, showed me how to flash manually, and restored my soft bricked CM modded Nexus 7 2013 to pristine newness. Others leave stuff out. Yours is step-by-step, everything needed and nothing unnecessary. Many, many thanks!





    • John Mason

      Buddy, it does not work for everyone, the first time i tried to fix it, it took me 11 days and idk how many sites i went through. it is a great post but it might not work for everyone

  • John Mason

    For anyone who is having problems visit this site:

    I did not need that site because i did it before. Here’s what to do:

    – Downloaded the file file before, now the link doesn’t work so i’ll upload it somewhere soon and give the link.
    ^ Should be the replacment if not please inform me

    – Then extract the zip file you just downloaded and in that folder there is another zip called image-nakasi-jrn84d

    – Extract that zip and Copy all the files in the newly extracted folder to the N7_restore folder

    – in the N7_restore folder open a cmd by pressing shift and right clicking together and then clicking open command window here

    – Then type/copy without the quotes “fastboot flash bootloader bootloader-grouper-3.34.img”

    Do not go to the next step until it says the flashing is successful or it will be a waste of time.

    – Next type/copy without the quotes “fastboot flash boot boot.img”

    – Next type/copy without the quotes “fastboot flash recovery recovery.img”

    – Next type/copy without the quotes “fastboot flash userdata userdata.img”

    – Next type/copy without the quotes “fastboot flash system system.img”

    If you want to Lock the bootloader

    – type/copy without the quotes “fastboot oem lock”
    That’s it. It worked for me twice and should work for you

    P:S: The direct link to the image i put above is not the original but a substitute i will try to give you the original one asap.

  • Mikey

    This was awesome!! Just used it to install 4.4.3 on my Nexus 5!!

  • AlRegals

    the didn’t work so I tried the next method and I’m stuck on the first step. Keeps telling me it can’t open the bootloader file and I don’t know why.

  • jay

    worked for me! refer to brian vazquez’s comment if you are using mac, that stuff is not in the guide

  • Ro0dman

    I download the 4.4.3 Factory Imag from the Google site and fully extract it however, I do not get the.img files that you have in this article

  • Corey

    Thank you so much for this! I could not figure out how to get it installed, and I realized (after reading your article) that I had to install each .img file one, by one. My Nexus 5 is booting up now. THANK YOU!

  • krash

    ried and got
    failed to allocate 699970328 bytes
    error : update package missing system.img

    • krash


  • BillyBalowski

    Thank you very much for this. I stupidly deleted my OS while attempting to flash a custom ROM before loading the new OS onto the internal SD card of my Nexus 10. I was almost certain I had killed my tablet. After a few hours of trying everything I could, this helped me get back up and running. Cheers to you!

  • benny

    I was totally desperate. Thanks for this easy free guide, top.

  • Sravan

    Worked for me!! Flashed my Nexus 4 back.. Thank You!

  • Biniam

    Excellent ! I got rid of Cyanogenmod. Thanks.

  • Abdul Wahid

    all mac users make these changes in the and you will have no problem install it

    fastboot flash bootloader bootloader-maguro-primemd04.img
    fastboot reboot-bootloader
    sleep 5
    fastboot flash radio radio-maguro-i9250xxlj1.img
    fastboot reboot-bootloader
    sleep 5
    fastboot -w update

    ./fastboot flash bootloader bootloader-maguro-primemd04.img
    ./fastboot reboot-bootloader
    sleep 5
    ./fastboot flash radio radio-maguro-i9250xxlj1.img
    ./fastboot reboot-bootloader
    sleep 5
    ./fastboot -w update

  • Rodney M. Altamera

    Success!!! Was able to revert back to my Google Nexus 7 Android Kitkat stock rom. Now working and in good condition. This guide is exact to the spot! Keep up the good work! Nice 🙂

  • T. Conrad Flamell

    Just finished flashing 5.0 on my Nexus 7 2012 according to your precise, orderly instructions. Was sweating initial boot (which I realize takes an inordinate amount of time). This one just “felt” significantly longer. Still getting updates on my apps including Multirom manager. I wiped & flashed Lollipop with both PA 4.4.4 and Validus 6.1 ROMs installed on this tablet. So I figure I tested the very limits of the device (and perhaps the software). Will be curious to see how N7 behaves based on the many negative comments I’ve seen. Still waiting on 5.0 for both my N7 2013 and my LG G Pad 8.3 GPE but have decided to wait on ota updates on these. Thanks again for the excellent instructions!

  • rakesh

    i get the following error message when i do flash all…could you please help? i cant get this thing to start now. its says booting failed.

    C:Nexus>cd nakasi-krt16s

    C:Nexusnakasi-krt16s>.fastboot devices
    015d21d9101ffa14 fastboot

    C:Nexusnakasi-krt16s>.fastboot oem unlock

    (bootloader) Bootloader is already unlocked
    OKAY [ 0.020s]
    finished. total time: 0.021s


    (bootloader) Bootloader is already unlocked
    OKAY [ 0.020s]
    finished. total time: 0.021s
    erasing ‘boot’…
    OKAY [ 0.017s]
    finished. total time: 0.019s
    ******** Did you mean to fastboot format this partition?
    erasing ‘cache’…
    OKAY [ 0.040s]
    finished. total time: 0.041s
    erasing ‘recovery’…
    OKAY [ 0.018s]
    finished. total time: 0.020s
    ******** Did you mean to fastboot format this partition?
    erasing ‘system’…
    OKAY [ 0.044s]
    finished. total time: 0.045s
    ******** Did you mean to fastboot format this partition?
    erasing ‘userdata’…
    OKAY [ 0.955s]
    finished. total time: 0.956s
    sending ‘bootloader’ (2100 KB)…
    FAILED (data transfer failure (Too many links))
    finished. total time: 11.248s
    rebooting into bootloader…
    FAILED (command write failed (Unknown error))
    finished. total time: 0.643s
    archive does not contain ‘boot.sig’
    archive does not contain ‘recovery.sig’
    archive does not contain ‘system.sig’
    getvar:version-bootloader FAILED (command write failed (No such device or addres
    finished. total time: 0.089s
    Press any key to exit…

  • Keiner Rangel

    love this fucking website . had my nexus 7 2012 bricked and not even booting up pass the bootloader came here and worked thank you guys so much

    • Gautam

      Great, glad it worked.

    • Glad it worked.

  • orangeworx

    i’m running into some issues, flash-all isn’t an option as i’m trying to save my user data, so i went manual and the problem i’m having is when i’m trying to push the system.img; basically a few seconds into the process it fails with an unknown error then says too many links open, wtv the heck that means… sure be interesting to know

  • Rahul

    worked perfectly

    • Gautam

      Glad it worked. Hope to see you here more often.

  • Michael Perry

    First, thanks for this guide. It worked perfectly for me using the bat file.

    A few things to note – which I found eventually in the comments but you may wish to add them to the main article for some clarity.

    Item 1. The Google supplied OEM image contains the flash-all.bat file. I got stumped on this when I did not see it initially until I read through the comments and discovered that it was included in the Google OEM image compressed file. As well, the file I got from Google was a tar file inside of a tgz file. Windows users need to know that they should use 7zip or similar third party program to uncompress the tgz file first, then again to uncompress the tar file and THEN copy those resulting set of files to the same directory where the user extracted your ZIP file contents.

    So if you change Step 1 to include the following:

    1.a: Download and extract Fastboot/ADB ZIP file contents to a new file called “Google” on your computer. The folder name “Google” is suggested, but feel free to name it as you wish.
    1.b: If you do not already have the USB drivers installed on your computer then install them from the Google/Drivers folder or download the latest version from Google and install them (I strongly suggest the latest drivers, especially for Windows 7 and newer versions).
    1.c: Download the OEM image you wish to use from Google. This file will be in TGZ format and you will need to decompress it using 7zip or some other third party compression program (WinZip, PowerDeskPro, etc.). The contents of the TGZ file will be a TAR file, this also will need to be decompressed and the contents of the TAR file now should be copied to the same folder you extracted the Fastboot/ADB ZIP file to in step 1.a above.

    Item 2. My computer doesn’t seem to like the ADB drivers very well. Fastboot would show my device with the command “Fastboot Devices” but ADB would not should any devices with the command “ADB Devices” and as well, when I tried to run “ADB Shell” I would get a “No Devices Found.” However, this did not prevent Flash-all.bat from doing it’s thing and it worked successfully like a charm once I solved the ADB driver issue below.

    I discovered that the device ID, once you put the Nexus 7 into Fastboot mode, would change on a rooted device and the driver would get confused. The solution for this involves modifying the driver’s INF file with the following:

    For 32 bit versions of Windows, under the [Google.NTx86] section locate the part that is commented “;Google Nexus 7” and all the following two lines to the bottom of that section if they are not already there:

    %CompositeAdbInterface% = USB_Install, USBVID_18D1&PID_D001
    %CompositeAdbInterface% = USB_Install, USBVID_18D1&PID_4EE0

    For 64 bit versions of Windows you would add these lines to the section under the [Google.NTamd64] header.

    The first line is for rooted devices, and the second is for unrooted devices.

    Your article is a life-saver, however it does assume a certain degree of tech savvy of the user so breaking down the steps, as well as providing a list of pre-requisites the user needs to accomplish first might be really helpful for those just starting out.

    • Gautam

      Thanks for the feedback. We’ll incorporate the suggestions in the article.

  • Renaldo Gordon

    I am getting the following error: “failed to load ‘’: No error”. any asistance on resolving this would be greatly appreciated.