What you're installing and why it matters
A factory image is the complete, original software that Google shipped on the Nexus 5 when it was new. Installing one replaces whatever is currently on your phone — including custom ROMs, modifications, or older Android versions — with a clean copy of the operating system, bootloader, and recovery partition. This is different from a regular app install: you're rewriting the phone's core software, not adding a program on top of it.
People install factory images for three main reasons. First, to go back to stock Android after running a custom ROM. Second, to recover a phone that won't boot or is stuck in a boot loop. Third, to start fresh before selling the phone or giving it away. The process wipes all data on the device, so back up anything you want to keep before you begin.
The Nexus 5 reached end of support in 2015, so no new factory images are being released. The last version available is Android 6.0.1 (Marshmallow). If you're running something older and want the latest available for this phone, this is how you get there.
Key Takeaways
- Factory images come directly from Google's servers and contain the exact software the Nexus 5 shipped with, including the bootloader and recovery partition.
- The installation process requires a computer, a USB cable, and the Android SDK Platform Tools, which you can download free from Google.
- Your phone must be in bootloader mode before you start, which you enter by powering off, then holding Volume Down and Power together.
- The fastboot command runs on your computer and communicates with the phone to write each partition; the process takes 5 to 15 minutes and erases all data.
- After installation completes, the phone boots into stock Android and you can set it up as new or restore from a backup.
Getting the factory image file
Google hosts factory images for all Nexus devices on a single download page. Go to developers.google.com/android/images in your web browser. Scroll down to find the Nexus 5 section — it's labeled "hammerhead," which is the internal code name for the Nexus 5. You'll see several download links, each one a different Android version.
The latest available is Android 6.0.1 (Marshmallow). Click the download link for that version. The file is about 300 MB and will be named something like hammerhead-m4b30z-factory-[hash].zip. Save it to a folder on your computer where you can find it easily — your Downloads folder works fine.
Do not extract the ZIP file yet. The fastboot tool needs the file in its original compressed form.
Installing Android SDK Platform Tools on your computer
Platform Tools is a package from Google that includes fastboot, the command-line program that communicates with your phone and writes the factory image. You need this on your computer before you can proceed.
Go to developer.android.com/tools/releases/platform-tools. Download the version for your operating system — Windows, Mac, or Linux. The file is about 50 MB. Extract the ZIP file to a location you'll remember, such as your Documents folder or Desktop. Inside, you'll find a folder called platform-tools containing fastboot and other tools.
On Windows, you may also need to install USB drivers so your computer recognizes the Nexus 5. Go to developer.android.com/studio/run/win-usb and follow the instructions for your phone model. Mac and Linux typically recognize the phone without extra drivers.
Preparing your Nexus 5 and entering bootloader mode
Back up any data you want to keep. The factory image installation erases everything on the phone — contacts, photos, messages, apps, settings, all of it. If you have a Google account signed in, some data like contacts and photos may restore afterward, but don't count on it.
Power off the Nexus 5 completely. Once it's off, hold down the Volume Down button and the Power button at the same time. Keep holding both for about 10 seconds. The phone will vibrate and show a bootloader menu with white text on a black screen. You're now in bootloader mode.
Plug the phone into your computer with a USB cable. The bootloader menu should show "FASTBOOT MODE" at the top. If it shows "FASTBOOT USB" instead, the connection is working. If the phone shows nothing or goes to the home screen, you didn't enter bootloader mode correctly — power off and try again.
Running fastboot commands to install the factory image
On your computer, open a command prompt or terminal window. Navigate to the platform-tools folder you extracted earlier. On Windows, you can do this by opening File Explorer, going to the platform-tools folder, holding Shift, right-clicking in the empty space, and selecting "Open PowerShell window here." On Mac or Linux, open Terminal and use the cd command to navigate to the folder.
Type this command to check that your phone is connected:
fastboot devices
If your phone is connected correctly, you'll see a serial number and the word "fastboot" printed below the command. If you see nothing, the USB connection isn't working — try a different cable or USB port, or reinstall the drivers.
Move the factory image ZIP file into the platform-tools folder. Then type:
fastboot flashall -w
The -w flag tells fastboot to wipe all data. Press Enter. Fastboot will extract the factory image and begin writing each partition to the phone. You'll see progress messages for bootloader, baseband, system, and recovery. This takes 5 to 15 minutes depending on your computer and USB connection. Do not unplug the phone or close the command window.
When fastboot finishes, it prints "Finished" and the phone automatically reboots into stock Android. The first boot takes a few minutes as the system initializes. You'll see the Android setup screen.
What to do after installation completes
Once the phone boots into stock Android, you can set it up as a new device or sign in with a Google account to restore backed-up data. If you backed up contacts, photos, or app data to Google Drive or Google Photos before the installation, signing in with that account will restore most of it.
The phone is now running the factory image with no modifications. If you want to install custom ROMs or make other changes, you'll need to unlock the bootloader again and install a custom recovery. For now, the phone is in its original state.
If something went wrong during installation and the phone won't boot, you can repeat this process. The factory image installation is safe to run multiple times.
Troubleshooting common problems
Fastboot doesn't recognize the phone. Make sure you're in bootloader mode — the screen should show "FASTBOOT MODE" in white text. Try a different USB cable and a different USB port on your computer. On Windows, reinstall the USB drivers from the link above. On Mac, try unplugging and replugging the phone after opening the fastboot command window.
The command window says "device not found" or "no devices." This is a USB connection problem. Close the command window, unplug the phone, wait 10 seconds, and plug it back in. Then open a new command window and try fastboot devices again. If it still doesn't work, try a different USB port on your computer — some ports may not provide enough power.
Fastboot starts but stops with an error about a missing file. Make sure the factory image ZIP file is in the same folder as fastboot, and that you haven't extracted it. The command needs the compressed file, not the extracted contents.
The phone reboots but gets stuck on the Google logo or bootloader screen. Let it sit for 5 minutes — the first boot after a factory install can take a long time. If it's still stuck after that, go back into bootloader mode and run fastboot flashall -w again.
Frequently Asked Questions
Can I install a factory image without a computer?
No. Fastboot only runs on a computer and communicates with the phone over USB. There's no way to install a factory image using only the phone itself.
Will installing a factory image remove the lock on my bootloader?
No. If your bootloader was locked before, it will still be locked after. If it was unlocked, it will still be unlocked. The factory image doesn't change the bootloader lock state.
What if I want to go back to an older version of Android?
The download page at developers.google.com/android/images shows all available versions for the Nexus 5. You can install any of them using the same fastboot process. Older versions are still available even though the Nexus 5 is no longer supported.
Can I stop the fastboot process once it starts?
You can close the command window, but this will leave the phone in an incomplete state and it may not boot. If you need to stop, let it finish or restart the process from bootloader mode. Don't unplug the phone while fastboot is running.
Do I need to unlock the bootloader before installing a factory image?
No. Factory images can be installed whether the bootloader is locked or unlocked. Unlocking is only necessary if you want to install custom ROMs or a custom recovery afterward.