Fastboot is a powerful tool bundled with Google Android SDK and also an engineering protocol that helps to write data directly to your phone’s flash memory. It can start on your device even before Android OS loads, even under the scenario when Android isn’t installed at all. The phone needs to be booted into “Bootloader mode” to use the Fastboot commands. It enables access on all your device partitions. Hence, one can patch those partitions by flashing firmwares, recoveries, bootloader etc.

Fastboot is most commonly used for unlocking the bootloader of smartphones. If you are familiar with rooting and modding your android phone, you must have heard a lot about ADB and fastboot. If you are new to this scene, we’d recommend checking our beginners guide to rooting.

Popular Fastboot Commands

When you’re working on the bootloader mode, ADB commands will no longer work, as the device is not booted into Android OS. Hence, the Android debugging tools can’t communicate to the phone. As mentioned above, the Fastboot commands would work even if the OS isn’t booted, provided your device is booted into Bootloader/Fastboot mode. These are probably the most useful tools available which will come to rescue when you brick your device or when you want to replace your device partitions.

To execute the below mentioned commands, you’ll also need to have Fastboot installed on your computer system, You can follow our guide to install ADB and Fastboot for the installation. Now that you have Fastboot working on your system, you can check the below commands. To make it easier, we’ve added a short description, syntax and an example.

Before you begin executing the commands:

Fastboot devices command

Type Fastboot devices in the command prompt and result should be a serial number, similar to the adb devices command. If entering this command shows your device name with serial number, it implies that your phone is good to go for fastboot operations. However, if the result is empty then you might want to check the fastboot installation and drivers.

Syntax:

fastboot devices

Fastboot OEM unlock command

The Fastboot OEM unlock command is the most popular command, it is your key to unlock the bootloader of your device. Although, this command works with most of the devices, it won’t work for some brands. If your OEM enables fastboot mode, then you will be able to unlock your phone with this command.

Brands such as Google Pixel, Google Nexus, OnePlus, HTC, Motorola, and etc. usually support bootloader unlock with this command. If you own a different device, you’d have to follow separate guides to do the trick. Also, unlocking the bootloader voids the warranty for some brands, so only unlock if you are willing to risk your warranty.

Syntax:

fastboot oem unlock

PS: Running the unlock command in the command prompt will wipe your entire data on the phone. So please proceed carefully. We won’t be held responsible for your data loss!

Fastboot OEM lock command

The Fastboot OEM unlock command is opposite of the OEM unlock command. Using this command, you can lock your bootloader and go back to the stock factory mode.

Just for information: This command could help you with your warranty even after you’ve unlocked it. Because in most parts of the world, the representatives at service centers think that a locked bootloader means the device wasn’t unlocked. Although, there are ways to find out if a device was previously unlocked, but most of the service centers don’t got that far. But if they find out, don’t blame us!

Syntax:

fastboot oem lock

Fastboot Flash command

The Fastboot flash command would help you to flash ZIP files. Companies like OnePlus, release the flashable ZIP file of the upcoming firmware for their testers. So, one can simply download the ZIP file, place it in the folder on their PC, open Command window from that folder and flash the zip. Normally, fastboot images are flashed in this way.

Note: It is always recommended to place the zip files in the same folder of your ADB binaries so that you do not need to specify the path or you can alternatively open the command window from that particular folder.

Syntax:

fastboot flash %FILENAME.ZIP%

Example:

fastboot flash newfirmware.zip

Fastboot Flash Recovery command

The Fastboot flash recovery is a powerful fastboot command which is used to flash recovery images. This will patch your recovery partition with a new image. When we install a custom recovery such as TWRP on our device, this is the command we use. This would replace the stock recovery with the custom recovery.

Syntax:

fastboot flash recovery %FILENAME.IMG%

Example:

fastboot flash recovery twrp.img

Fastboot Flash Boot command

The boot image contains the kernel of your device. You can use the Fastboot Flash boot command to replace the stock kernel with a custom kernel of your choice. This command would replace the boot partition of your device. It might look simple, but could be risky if you flash a wrong boot image. There are chances that your device might not boot or might get stuck in a Bootloop. The only way to recover if you mess up with this would be flashing the stock boot image.

Syntax:

fastboot flash boot %FILENAME.IMG%

Example:

fastboot flash boot bootimage.img

Fastboot Erase command

Like the name says, this command would erase items from your device. By using the Fastboot erasecommand you’ll be able to wipe data from different partitions on your device. This command is generally used before flashing a new ROM, as it wipes the existing data and makes space for the new files to be written. This command deletes all your data from the partitions you’ve mentioned in the command, so it’s always a good idea to take a backup before you run it.

Syntax:

fastboot erase %PARTITION NAME%

Example:

#To erase system partition
fastboot erase system

#To erase boot partition
fastboot erase boot

#To erase cache partition
fastboot erase cache

#To erase user data partition
fastboot erase userdata

#To erase recovery partition
fastboot erase recovery

Fastboot Format command

If you want to completely format the flash partitions of your device, you can use Fastboot format command. This will allocate new blocks of data to your device partition and that makes it different from fastboot erase command. A full backup of device data is always recommended as it can wipe your entire data.

Syntax:

fastboot format %PARTITION NAME%

Example:

#To format system partition
fastboot format system

#To format boot partition
fastboot format boot

#To format cache partition
fastboot format cache

#To format user data partition
fastboot format userdata

#To format recovery partition
fastboot format recovery

Fastboot Reboot/reboot-bootloader commands

The Fastboot reboot command will help you to boot your device normally to OS. On entering the reboot command you’ll be booting the system partition of your device. Whereas the reboot-bootloader command will take you back to bootloader mode followed by a reboot.

Syntax:

#To reboot your device
fastboot reboot

#To reboot your device to fastboot mode
fastboot reboot-bootloader

Conclusion

Because of its powerful nature, OEMs do not enable fastboot mode for all phones. Although It’s enabled for most of the smartphones (Almost all). Some popular manufacturers which enable the fastboot mode for their devices are Google Pixel, Nexus, OnePlus, Motorola, HTC, Xiaomi, ASUS, Sony, Huawei, etc. The Android community developers also help you with ways to unlock it if there’s no official method available (for some devices.) With little knowledge about the commands and right hardware, Fastboot could be a great utility and knowing its commands could be helpful!

  • Taeif

    how to used command format boot ??????????????????
    …………………………………………………………..
    C:\Users\Piro\Downloads\HTC One M9>htc_fastboot devices
    FA55LYJ00130 fastboot
    htc_fastboot finished. total time: 0.500s

    C:\Users\Piro\Downloads\HTC One M9>htc_fastboot flash recovery twrp-2.8.7.0-hima
    .img
    htc_fastboot v3.0.7 (2015-03-30)
    target reported max download size of 536870912 bytes
    sending ‘recovery’ (36288 KB)…
    OKAY [ 1.469s]
    writing ‘recovery’…
    FAILED (remote: cannot flash this partition in s-on state)

    C:\Users\Piro\Downloads\HTC One M9>htc_fastboot format boot
    usage: htc_fastboot [-h] [-v] [-V] [-d] [-s ] …
    htc_fastboot: error: argument : invalid choice: ‘format’ (choose from ‘
    flash’, ‘erase’, ‘getvar’, ‘devices’, ‘reboot’, ‘reboot-bootloader’, ‘dump’, ‘oe
    m’)
    ………………………………………
    how to solved ” [-h] [-v] [-V] [-d] [-s ] … “

    • Subham

      Hey Taeif,

      You’re doing everything correctly. However, you’re supposed to use the commands when you are in download mode.

      You’ll need to boot your device into download mode from the bootloader. Also make sure that your bootloader is unlocked for the flashing to happen successfully.

      Check this thread of XDA: https://forum.xda-developers.com/htc-10/help/help-flash-twrp-s-t3396496

  • Neil D’souza

    This is very informative! I appreciate this post, Subham! Your site is the only site which is ad-free and focused on information. I love the way your writing style! Respect earned mate!