LinuxCommandLibrary

bmaptool

Copy block devices to other storage efficiently

TLDR

Output a blockmap file from image file

$ bmaptool create [[-o|--output]] [blockmap.bmap] [source.img]
copy

Copy an image file into sdb
$ bmaptool copy --bmap [blockmap.bmap] [source.img] [/dev/sdb]
copy

Copy a compressed image file into sdb
$ bmaptool copy --bmap [blockmap.bmap] [source.img.gz] [/dev/sdb]
copy

Copy an image file into sdb without using a blockmap
$ bmaptool copy --nobmap [source.img] [/dev/sdb]
copy

SYNOPSIS

bmaptool copy [options...] [--image IMAGE] [--bmap BMAP] [DEVICE]
bmaptool create [options...] [IMAGE]
bmaptool info [options...] IMAGE|BMAP
bmaptool validate [options...] [--image IMAGE] [--bmap BMAP]

PARAMETERS

--help, -h
    Show help message and exit

--version
    Show version number and exit

--debug
    Print verbose debug messages

--image IMAGE, -i IMAGE
    Path to input image file (auto-guessed or stdin)

--bmap BMAP, -b BMAP
    Path to bmap file (auto-guessed from image name)

--nobmap, -N
    Copy entire image sequentially, ignoring bmap/holes (like dd)

--noverify, -n
    Skip verification of written blocks

--dry-run
    Simulate copy without writing to device

--force, -f
    Force write, ignore read-only warnings or size mismatches

--syslog
    Log messages to syslog in addition to stderr

--offset OFFSET, -o OFFSET
    Start writing at byte offset on device

--block-size BYTES, -B BYTES
    Block size for bmap (default 4096, for create/info)

--human, -h
    Human-readable output sizes (for info)

DESCRIPTION

bmaptool is a command-line utility for copying sparse files, such as disk images, to block devices much faster than dd. It uses bmap (block map) files, which are compact bitmaps describing exactly which blocks in the source file contain data versus zero-filled holes. By skipping unused blocks, it reduces copy time from hours to minutes for large images common in embedded Linux, Android OTA updates, and IoT devices.

Key features include creating bmaps from images, displaying bmap info, validating data integrity post-copy via checksums, and fallback to full copy mode. It auto-detects bmap and device paths from filenames (e.g., image.img implies image.img.bmap and /dev/sdX). Supports offsets for partitioned copies, dry-runs, and forcing writes.

Ideal for flashing Raspberry Pi, BeagleBone, or phone firmware to SD/eMMC/USB. Requires root privileges for devices; verifies written blocks by default for reliability.

CAVEATS

Requires root/sudo for block devices. Target must not be mounted. Device smaller than image truncates; larger pads with zeros. Embedded checksums needed for verification.

EXAMPLE USAGE

bmaptool copy image.img.bmap /dev/sdb
Copies image to SD card using bmap.

bmaptool create --bmap myimage.bmap myimage.img
Generates bmap file.

bmaptool info image.img.bmap
Shows block map details.

HISTORY

Developed by Mikhail Orlov at Intel for Yocto Project in 2014. Integrated into major distros like Fedora, Ubuntu, Debian via bmap-tools package. Evolved to support bmap v1.1+ for compressed images.

SEE ALSO

dd(1), losetup(8), mkfs(8)

Copied to clipboard