[Nexus 9 General] jd1639:
This guide will help you unlock your bootloader, flash a factory image, and return you to a stock device. It is wriiten assuming you have a windows PC (MAC users, see post 2). This can be helpful if you need to RMA your device or if you are getting erratic behavior or messed something up.

Tools and Files You’ll Need

If you don’t have adb and fastboot installed on your PC go here for a quick install of the necessary files, thanks to [MENTION=4638083]Snoop05[/MENTION], http://xdaforums.com/showthread.php?t=2588979

For MAC users go here. http://xdaforums.com/showthread.php?p=32305619

For Linux users, http://xdaforums.com/showthread.php?p=10746225

For the factory image go here, https://developers.google.com/android/nexus/images You’ll download a .tgz file. Use winrar or 7-zip to extract the file to its own directory and remember where that directory is. Inside is another zip file, extract that too. You’ll need those image files if you use the long method to install the factory image. It’s also good to know where they are as they come in handy as you get more familiar with fastboot and what you can do with it.

How To Unlock the Bootloader

If you don’t have developer options enabled on your device go to settings, about device and tap on the build number 7 times.

In settings, developer options enable oem unlock

Now you get to use fastboot! Boot you device into the bootloader, vol up + power with your device shut off. Once booted into the bootloader connect it to your PC with the usb cable and open a command window on your PC. Once connected type the following command in the cmd window:

fastboot devices (Your device serial number should show up and this will ensure fastboot is working properly)

​

Then type:

​

fastboot oem unlock (This will unlock the bootloader and you’re now good to go)​

NOTE, UNLOCKING THE BOOTLOADER DOES WIPE YOUR DEVICE SO BACKUP OFF YOUR DEVICE FIRST

How To Flash the Factory Image, SHORT METHOD

Open a command window on your PC in the same directory as you extracted the factory image. In that directory shift, right click in an open area and use “Open a command window here”

Boot your device into the bootloader and connect it to your PC. Then simply double click on the flash-all batch file. Note that there are batch files in there that will work for Windows as well as Linux machines

Let the batch file run and when it’s done you’ll be back to stock.

NOTE THAT FLASHING BY THIS METHOD DOES WIPE YOUR DEVICE SO MAKE SURE YOU BACKUP OFF YOUR DEVICE FIRST.

How To Flash the Factory Image, LONG METHOD

In this method each factory image is flashed separately. This should be used if you have problems with the short method and as you get more familiar with fastboot you’ll be able to flash only the images that you need for your specific requirement. For instance, you might want to only flash the stock recovery if you’re trying to take an ota and you’ve installed a custom recovery. The order that you flash the images is not important.

In the folder you extracted the factory image it’s easiest if you re-name the bootloader image file to simply bootloader and radio. Then open a Windows command window in that folder and use the fastboot commands:

fastboot flash bootloader bootloader.img

fastboot reboot-bootloader

fastboot –w (NOTE, this command does wipe your device. It’s possible to flash the factory image without this command but if you’re going from different revision numbers of android it’s highly recommend to wipe the device)

Now open a Windows command window in the same folder that you extracted the zip file in, the one where you find recovery, system, etc. Then run the fastboot commands:

fastboot flash boot boot.img

fastboot flash cache cache.img

fastboot flash recovery recovery.img

fastboot flash system system.img [Note, flashing system takes a long time, so let it do it's thing]

fastboot flash vendor vendor.img

Congratulations, you’ve now flashed a factory image and learned how to use fastboot!