Skip to main content

How to install Android 6.0 Marshmallow factory images on Nexus 5, Nexus 6, Nexus 7, Nexus 9, and Nexus Player


Google has now released the latest version of Android, dubbed Android Marshmallow, which the company first previewed earlier this year at Google I/O in San Francisco. And while Google will most certainly be rolling out the update (and subsequent updates) over-the-air with no work required on your part, many who aren’t as familiar with how to flash factory images might want to install the latest build manually.

That’s why we made this guide. If you have the Nexus 5, Nexus 6, Nexus 7 (2013) Nexus 9, or Nexus Player, there’s a build of Android 6.0 Marshmallow available right now for you to install on your device. Be warned however, that this process isn’t something that most regular users should attempt. If you do have a little bit of command line knowledge (or you think you want to take the time to learn), keep reading…

Note: This guide assumes you already have the ADB tools installed on your computer. If you need the ADB tools, head over and download the Android SDK.

Before we get started, we need to make sure that your device is visible to your computer. Open up Terminal and type the command “adb devices” and press enter. If you see your device listed, you’re good to go. If not, make sure your device has USB debugging turned on in the Settings app. Head to Settings -> About phone -> tap the “Build number” several times -> Press the back button -> Developer options. Here you will see a “USB debugging” option.

Unlock the bootloader

screenshot_2015-06-01-07-16-10If you know that your device is already unlocked, feel free to skip this section and keep reading. Otherwise, you need to make sure your phone’s bootloader is unlocked before you can flash a factory image.

Bootloader locking is a security feature that requires that your device be completely wiped when going from a “locked” state to an “unlocked” state. For this reason, there’s no way to keep your data if your bootloader is locked.

First, go to the Settings app and head to the “Developer options” (if you don’t see Developer options, go to the “About” page and tap the Android build number several times). Make sure that “OEM unlocking” is checked.

Next, Use the command “adb reboot bootloader” to go to the device’s bootloader and check if your device is in the locked state. If the bootloader on your Nexus device is locked, make sure your device is at the bootloader screen and use the “fastboot oem unlock” command.

After this, you should see some prompts on your device to confirm that you do indeed want to unlock your bootloader. After you confirm this, your device is going to be completely wiped and you’ll be ready to move on with this guide.

Download and prepare the factory image

If you haven’t already, grab the latest build of Android Marshmallow from Google’s factory image page. Once you’ve downloaded the .tgz file, extract it. Inside the extracted .tgz file there will be a .zip file titled something like “” (Nexus 6), and after you extract that file, you’ll find the boot loader, OS image, vendor image, and a radio image (depending on your device).

Factory Images for Nexus Devices  |  Nexus Files for Developers  |  Google Developers 2015-10-05 11-57-10

Modify the “flash-all” script to save your data

Note: You only need to follow these instructions if you want to keep your data, otherwise the flash will format your device and all data will be lost.

Note 2: If your bootloader is locked, your data will have to be wiped anyway as described above. If you don’t want to lose your data in this case, you need to restart your device and back it up manually.

Note 3: Generally, it’s probably a good idea to avoid keeping your data if possible. There’s a reason that the flash-all script doesn’t do this by default, and it’s generally good practice to start completely fresh when possible.

The “flash-all” script contains all of the commands necessary to flash the factory image onto your device. Before running it from the command line, we want to remove the flag that wipes your data.

In the file you extracted you’ll find two flash-all scripts as mentioned above. The flash-all script with the .bat extension works with the Windows command line while the .sh extension works with the Unix command line (OSX, Linux, etc). Open up the proper flash-all script with your favorite text editor and remove the “-w” from the file. “-w” is an ADB flag which wipes all of the user data (the stuff we want to keep).

Once you’ve made the change, save your file, and open up a command line program.

Run the script and install Android Marshmallow

As we did earlier to check unlock status, you need to boot into your bootloader to flash the factory image. Run the command “adb reboot bootloader” again to get there if needed. Alternatively, you could start up the device while holding the volume down and power keys simultaneously to boot into the bootloader.

Now point your command line to the file directory with the flash-all script. (Ex: cd /Users/<yourusername>/Downloads/hammerhead-lrx21o). For more help on using the command line, see this cheat sheet.

Once you’ve pointed to the correct directory, run your script.

  • On Unix, run “./”
  • On Windows, run “flash-all.bat”

Now you should see the script running in your Terminal or command line window. It will take a little over five minutes for the image to install. Once the image is installed, the script will automatically reboot your phone. The first boot usually takes a while, so wait about 10 minutes before assuming you’ve entered a bootloop.

Some users have had issues with the flash-all script not working on the Nexus 5, 7, and other devices. If that’s the case with you, you’re going to need to flash all of the images manually. It’s not a hard process, though, and only requires a few extra steps. Make sure your device is in the proper bootloader state, and then follow these instructions:

First, flash the bootloader and the radio, and then reboot the bootloader (radio only applies to some devices):

fastboot flash bootloader <bootloader file name here>.img
fastboot flash radio <radio file name here>.img

fastboot reboot-bootloader

Flash the recovery, boot, system, and vendor images (vendor only applies to some devices):

fastboot flash recovery recovery.img
fastboot flash boot boot.img
fastboot flash system system.img
fastboot flash vendor vendor.img

Recommended: For a full wipe, flash cache and userdata as well (userdata only applies to some devices):

fastboot flash cache cache.img
fastboot flash userdata userdata.img

Reboot your device:

fastboot reboot

After the phone boots, you should have Android 6.0 Marshmallow and, if you opted to modify the flash-all script, all of your data should be intact.

FTC: We use income earning auto affiliate links. More.

You’re reading 9to5Google — experts who break news about Google and its surrounding ecosystem, day after day. Be sure to check out our homepage for all the latest news, and follow 9to5Google on Twitter, Facebook, and LinkedIn to stay in the loop. Don’t know where to start? Check out our exclusive stories, reviews, how-tos, and subscribe to our YouTube channel



Avatar for Stephen Hall Stephen Hall

Stephen is Growth Director at 9to5. If you want to get in touch, follow me on Twitter. Or, email at stephen (at) 9to5mac (dot) com, or an encrypted email at hallstephenj (at) protonmail (dot) com.