LinuxCommandLibrary

fastboot

Flash images to Android devices

TLDR

Unlock the bootloader

$ fastboot oem unlock
copy

Relock the bootloader
$ fastboot oem lock
copy

Reboot the device from fastboot mode into fastboot mode again
$ fastboot reboot bootloader
copy

Flash a given image
$ fastboot flash [path/to/file.img]
copy

Flash a custom recovery image
$ fastboot flash recovery [path/to/file.img]
copy

List connected devices
$ fastboot devices
copy

Display all information of a device
$ fastboot getvar all
copy

SYNOPSIS

fastboot [options] command [arguments]

PARAMETERS

-h, --help
    Display help message

--help-all
    Show all available options

-s <serial>, -S <serial>[;<transport_id>]
    Specify device serial number or serial with transport ID

-w
    Wipe userdata and cache partitions before flashing

-a, --slot all
    Flash all slots (for A/B devices)

--slot <slot>
    Specify slot suffix (e.g., 'a' or 'b')

-c <cmdline>
    Override kernel commandline

-r, --reset
    Reset device after command

-n, --skip-reset
    Skip final device reset

-l, --legacy
    Use legacy mode without slot or super support

-p <product>
    Specify product name

--version
    Show fastboot version

devices [-l]
    List connected fastboot devices

flash <partition> <img>
    Flash image to partition

erase <partition>
    Erase specified partition

boot <kernel> [<ramdisk>]
    Boot kernel temporarily

reboot [<mode>]
    Reboot device (bootloader/recovery)

reboot-bootloader
    Reboot into bootloader

getvar <var>
    Get bootloader variable

flashing <unlock|lock|unlock_critical|lock_critical>
    Manage flashing lock state

oem <command>
    Execute OEM-specific command

set_active <slot>
    Set active boot slot

update <zip>
    Flash update package ZIP

DESCRIPTION

Fastboot is a command-line tool within the Android SDK Platform-Tools, used to communicate with Android devices in fastboot mode (bootloader). It enables flashing partitions, unlocking bootloaders, erasing data, booting kernels temporarily, and querying device variables. Devices enter fastboot mode via hardware keys or adb reboot bootloader.

Primarily for developers and OEMs, it flashes images like boot.img, system.img, or vendor.img to specific partitions. Safety features include bootloader locking states; many devices require unlocking first, which wipes data. It's cross-platform (Linux, Windows, macOS) but requires USB drivers and udev rules on Linux for non-root access.

Common workflow: fastboot devices to list, fastboot oem unlock or fastboot flashing unlock, then fastboot flash boot boot.img, and fastboot reboot. Supports A/B slot systems on modern devices with --slot or set_active. Risks include bricking if misused.

CAVEATS

Requires USB debugging and fastboot mode; risks bricking device or data loss. Linux needs udev rules for non-root. Not all devices support all commands; bootloader must often be unlocked first. Use official SDK tools.

LINUX SETUP

Install via platform-tools from Android SDK. Add udev rules: echo 'SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", MODE="0666", GROUP="plugdev"' > /etc/udev/rules.d/51-android.rules; reload with udevadm control --reload-rules.

COMMON ERRORS

waiting for device: Check USB cable/port, fastboot devices. FAILED (remote failure): Image mismatch or locked bootloader.

HISTORY

Introduced by Google in Android 1.0 (2008) as part of AOSP tools. Evolved with A/B updates (Android 7.0+), verified boot, and dynamic partitions (Android 10+). Maintained in platform-tools; version tied to SDK releases.

SEE ALSO

adb(1)

Copied to clipboard