Using the bmaptool to record disk images safely and quickly

The ability to store, manipulate, and copy files efficiently and safely is essential. There are several tools created for this purpose, with varying degrees of speed and security. In this article, we will talk about the bmaptool and its particularities, showing the reasons for its choice whenever possible.

Domarys Correa
O.S. Systems
3 min readNov 10, 2020

--

bmaptool is a tool that works with files of any size, creating and manipulating files in blocks and mapping them from one location to another, offering secure transfer, integrity checking using SHA256, use of authentication with the OpenPGP tool, and speed. The speed boost is mostly due to using a block map file (bmap), in XML format for easy inspection, which maps the data blocks and skips the empty spaces.

To have an idea about the level of performance we can get, we can compare it with the dd command, another very famous tool, in a machine with HD 320gb SATA II 3.0 GB 3.5in 5900RPM.

Below we show the time difference of transference operation between dd, bmaptool without bmap file and using:

Time of copy proccess between dd and bmaptool commands

The speed can be 7x bigger as it was analyzed by the Tizen IVI team in their recordings of projects and, more importantly, the security in running the bmaptool. The dd can be dangerous in case of wrong use, being able to delete permanently data or even destroy your HD. While the bmaptool does not allow the user to execute dangerous commands; for instance, the bmaptool doesn’t destroy a mounted partition if you specified the wrong destination path. Yeah, this saved me a few times ;-)

One of the nicest features of bmaptool is the support for using remote files, even when compressed. It does that by streaming the source file’s contents without the need to store them locally.

In case we already have the bmap file, we can use the bmaptool in copy mode, using:

sudo bmaptool copy --bmap image-file.bmap image-file dest

If the - - bmap option isn’t specified, the bmaptool tries to find automatically a bmap file.

Unfortunately, some images of generic Operating Systems do not offer the bmap files ready for use. But don’t worry, we can generate it very easily using:

sudo bmaptool create image-file > image-file.bmap

Or in the case where the bmap file is not present, we can :

sudo bmaptool copy --nobmap image.ext dest

Below you can see the copy process in a terminal:

Running bmaptool copy command in terminal

The bmaptool is a very useful tool to know about and have in your toolset. If you want to know more about it, the best place to go is the bmap-tools’ Github project.

--

--

Domarys Correa
O.S. Systems

I am a computer scientist, a geek, rock music fan, terror games and movies addict, chocolate lover and the crazy cat lady.