Your Nexus 5 Feels Sluggish or Unstable
You’ve been tinkering with custom ROMs, or perhaps an update went wrong. Now your trusty Nexus 5 is stuck in a boot loop, plagued by mysterious bugs, or just doesn’t feel like the snappy, reliable phone it once was. The solution isn’t a new phone—it’s a fresh start.
Installing factory content, often called flashing the factory image or stock firmware, is the digital equivalent of a factory reset on steroids. It wipes everything—the operating system, kernel, and system apps—and replaces it with the exact software your device left the Google factory with. This guide walks you through the complete, safe process.
Understanding Factory Images and Your Nexus 5
Before diving in, it’s crucial to know what you’re working with. A factory image is a complete software package officially released by Google for Nexus and Pixel devices. It contains every partition needed for the phone to function: the bootloader, radio, boot, recovery, and system images.
Flashing this package returns your Nexus 5 to a pristine, out-of-the-box state. It’s the definitive fix for persistent software issues, the essential step before selling your device, and the required foundation if you ever want to receive official Over-The-Air (OTA) updates again.
What You Will Need to Begin
Gathering the right tools is half the battle. You’ll need a few things before you start the installation process.
– A Google Nexus 5 (model LG-D820 or LG-D821).
– The original USB cable that came with the phone, or a high-quality data-sync cable. Cheap charging cables often fail during data transfer.
– A Windows, macOS, or Linux computer with a USB port.
– At least 50% battery charge on your Nexus 5. The process can take 10-15 minutes, and a dead battery mid-flash can brick your device.
– A backup of all your personal data. This process will erase everything on the device—photos, messages, app data, and settings. Use Google’s backup or copy files manually to your computer.
Step-by-Step Guide to Installing Factory Content
This process involves unlocking the bootloader, which will erase your data, and then flashing the factory image files. Follow each step carefully.
Step 1: Prepare Your Computer and Phone
First, enable Developer Options on your Nexus 5. Go to Settings > About phone and tap “Build number” seven times. You’ll see a message confirming you are now a developer.
Go back to Settings, enter Developer Options, and enable “USB debugging.” This allows your computer to send advanced commands to the phone. Also, enable “OEM unlocking” if the option is present. This is critical for the next step.
On your computer, you need the Android SDK Platform-Tools. This is a small package containing the essential command-line tools: `adb` and `fastboot`. Download it directly from the official Android developer website. Extract the ZIP file to a convenient folder on your computer, like `C:\platform-tools` or `~/platform-tools`.
Step 2: Unlock the Bootloader
Connect your Nexus 5 to the computer with the USB cable. On the phone, if you see a prompt asking to “Allow USB debugging,” check “Always allow from this computer” and tap OK.
Open a command prompt (Windows) or terminal (macOS/Linux) and navigate to the folder where you extracted the platform-tools. Type the following command and press Enter:
`adb devices`
You should see your device listed with a serial number. This confirms the connection is working. Now, reboot the phone into the bootloader mode with this command:
`adb reboot bootloader`
Your phone will restart and show a screen with an open Android robot. This is the fastboot mode. To unlock the bootloader, which is necessary to flash factory images, use this command:
`fastboot oem unlock`
On your phone’s screen, you will see a warning. Use the volume keys to highlight “Yes” and the power button to select it. The phone will wipe all user data and reboot back into the bootloader. The bootloader screen will now show “UNLOCKED” at the top.
Step 3: Download and Extract the Correct Factory Image
Do not close the terminal or disconnect the phone. On your computer, open a web browser and go to the official Google Nexus factory images page. Find the section for “hammerhead,” which is the codename for the Nexus 5.
Download the latest factory image package for your device. The filename will look something like `hammerhead-lmy48i-factory-xxxxxx.tgz`. Extract this downloaded archive file. Inside, you will find another ZIP file (e.g., `image-hammerhead-lmy48i.zip`). Extract this ZIP file as well. You should now have a folder containing the actual `.img` files like `boot.img`, `system.img`, `recovery.img`, and a flash-all script.
Copy all the extracted `.img` files and the `flash-all` script into your platform-tools folder. This keeps everything in one place for the next step.
Step 4: Execute the Flash Script
Ensure your phone is still in fastboot mode (the screen with the open Android). In your terminal, make sure you are in the platform-tools directory containing the factory image files.
For Windows, double-click the `flash-all.bat` file. For macOS or Linux, open a terminal in that folder and run the command:
`./flash-all.sh`
The script will run automatically. It will flash each partition in sequence: bootloader, radio, boot, recovery, and system. You will see progress text in your terminal. Do not touch the phone or the cable during this process. The phone will reboot several times; this is normal.
When the script finishes, the phone will reboot into the fresh Android setup wizard. The process is complete. You can now disconnect the USB cable.
Common Issues and Troubleshooting Steps
Even with careful preparation, you might hit a snag. Here’s how to solve the most common problems.
The Flash-All Script Fails or Hangs
If the script fails partway through, don’t panic. First, check that you have the latest platform-tools. Old versions can be incompatible. Second, try a different USB port on your computer, preferably a USB 2.0 port instead of a blue USB 3.0 port, as some devices have compatibility issues.
If the script still fails, you can flash each partition manually. With the phone in fastboot mode, run these commands one by one from the platform-tools folder (replace `filename` with the exact name of each file):
`fastboot flash bootloader bootloader-filename.img`
`fastboot reboot-bootloader`
`fastboot flash radio radio-filename.img`
`fastboot reboot-bootloader`
`fastboot flash boot boot.img`
`fastboot flash recovery recovery.img`
`fastboot flash system system.img`
`fastboot flash cache cache.img`
`fastboot flash userdata userdata.img`
`fastboot reboot`
Device Not Recognized in Fastboot Mode
If `fastboot devices` returns nothing, you likely need a driver. On Windows, the simplest solution is to install the universal Google USB Driver from the Android SDK Manager or download it separately. On macOS and Linux, it usually works out of the box, but you may need to configure USB permissions or try a different cable.
Forgot to Enable OEM Unlocking
If your phone’s bootloader is already locked and you didn’t enable “OEM unlocking” in Developer Options, the `fastboot oem unlock` command will fail. You must boot into Android normally, enable the setting, and then start the process again from the beginning.
After the Installation: Next Steps and Verification
Once your Nexus 5 boots into the setup screen, proceed through the Android setup. You can restore your apps and settings from a Google backup if you created one earlier.
To verify the installation was successful, go to Settings > About phone. Check the “Android version” and “Build number.” They should match the version of the factory image you flashed. Your device should now feel responsive and stable.
If you plan to keep the phone stock, you can now relock the bootloader for added security, though this is optional. To relock, reboot to fastboot mode again and run `fastboot oem lock`. Be warned: this will trigger another full data wipe.
Maintaining Your Restored Nexus 5
With a clean factory image installed, your Nexus 5 is back to its original software state. From here, you can choose to keep it completely stock and receive the final official OTA updates Google released for the device. Alternatively, this clean slate is the perfect foundation if you wish to explore custom recoveries like TWRP or try other custom ROMs, as you know you can always return to this known-good state.
The process might seem technical, but it’s a powerful skill that breathes new life into older hardware. By following these steps precisely, you’ve not only solved an immediate problem but also gained full control over your device’s software, ensuring it runs exactly as intended for years to come.