Fastboot

How to Flash a Stock ROM with Fastboot on Android

Published: June 25, 2026 Applies to: Windows 10/11, macOS, Linux — Pixel, Nexus, and unlocked Android devices

Flashing a stock ROM via Fastboot is the standard method Google provides for restoring a Pixel or Nexus device to factory state. It is faster and more thorough than an OTA update and is the preferred approach after modifying the device, encountering a bootloop, or preparing a device for resale. This guide covers the complete process from downloading the factory image to confirming the device boots correctly.

What You Need

Before starting, gather the following:

Entering Fastboot Mode

With the phone powered on and USB Debugging enabled, the quickest method is:

adb reboot bootloader

Alternatively, power the phone completely off, then hold the hardware key combination for your device model. On Google Pixel phones this is Volume Down + Power. The bootloader screen shows the current build, bootloader lock status, and navigation instructions.

Confirm the PC sees the device in Fastboot mode:

fastboot devices

The output should show the device serial number followed by fastboot. If nothing appears, the Fastboot USB driver is not loaded — open Device Manager, look for an unknown device entry that appeared when the phone was connected in bootloader mode, and assign the Google USB Driver or your manufacturer's driver to it.

Unlocking the Bootloader

If the bootloader is locked (most out-of-the-box consumer devices are locked), you must unlock it before flashing. Unlocking performs a factory wipe — all user data, accounts, and apps are deleted. This is a security measure and cannot be skipped.

On Google Pixel devices, first enable OEM unlocking in Developer Options (Settings > Developer Options > OEM Unlocking). Then, with the device in Fastboot mode:

fastboot flashing unlock

A confirmation screen appears on the phone. Use Volume keys to navigate to "Unlock the bootloader" and press Power to confirm. The device wipes and reboots into the setup wizard with an unlocked bootloader. After completing or skipping setup, re-enable Developer Options and USB Debugging before proceeding with flashing.

On older Nexus devices, the command was fastboot oem unlock instead. Motorola, Sony, and Nokia each have brand-specific unlock processes — refer to their respective USB driver guides for details.

Using the flash-all Script

Google Pixel and Nexus factory images include a flash-all script (flash-all.bat on Windows, flash-all.sh on macOS/Linux) that automates the entire flashing process. This script flashes all partitions: bootloader, baseband/radio, boot, system, vendor, and more, then reboots the device.

Steps to use the script:

  1. Extract the factory image ZIP to a local folder.
  2. Open a terminal and navigate to the extracted folder.
  3. Ensure the phone is in Fastboot mode and recognized by fastboot devices.
  4. On Windows, run flash-all.bat. On macOS/Linux, run ./flash-all.sh (you may need to chmod +x flash-all.sh first).
  5. Do not disconnect the USB cable or interact with the device until the script finishes and the device reboots.

By default, the flash-all script wipes userdata. To preserve data (for example, when downgrading for testing without losing data), open the script in a text editor and remove the -w flag from the fastboot commands. Note that -w is required for major Android version changes — skipping it when upgrading across major versions may cause boot failures.

Manual Partition Flashing

If you need to flash specific partitions rather than the whole factory image — for example, to update only the bootloader or to flash a custom boot image — use individual fastboot flash commands.

Common partition names and their files:

After flashing the bootloader or radio, always reboot to bootloader before flashing further partitions:

fastboot reboot bootloader

This ensures the new bootloader is active before subsequent flash operations that depend on it. Skipping this step is a common cause of flashing failures on Pixel devices.

Verifying the Flash and Re-locking

After flashing completes and the device reboots, go through the initial setup and confirm the build number in Settings > About Phone matches the factory image you flashed. The first boot after a flash can take 5–15 minutes because Android optimizes apps (the "Android is starting..." or "Optimizing apps" screen).

If you want to re-lock the bootloader after flashing stock (for security or warranty purposes), boot back into Fastboot mode and run:

fastboot flashing lock

Re-locking also performs a factory wipe. Ensure you have completed setup and backed up any data before re-locking. On a locked bootloader with official stock firmware, Android's verified boot chain is active and the device is in the same security state as from the factory.

Common Fastboot Flashing Errors

"FAILED (remote: 'Partition not found')": The partition name in the command does not exist on this device model. Factory image scripts are device-specific. Do not use a factory image from a different model even if the hardware looks identical — partition layouts differ.

"FAILED (remote: 'Command not allowed')" on flash operations: The bootloader is still locked. Run fastboot flashing unlock and confirm the wipe prompt on-device before attempting to flash.

Flash-all script exits immediately with "< waiting for any device >": The device is not recognized in Fastboot mode. The fastboot PATH in the script may not point to your installed platform-tools. Either copy the platform-tools binaries into the factory image folder or edit the script to use the absolute path to fastboot.

Device freezes at bootloader screen after flashing: A partial flash (for example, new system with old bootloader) can cause this. Re-enter Fastboot mode by holding the hardware key combination and run the complete flash-all script rather than individual partition commands.