System Administration

Essential System Tools: f3 – detect and fix counterfeit flash storage

Last Updated on May 28, 2022

This is the latest in our series of articles highlighting essential system tools. These are small, indispensable utilities, useful for system administrators as well as regular users of Linux based systems. The series examines both graphical and text based open source utilities. For this article, we’ll look at f3, a free and open source set of tools for flash storage. For details of all tools in this series, please check the table at the summary page of this article.

Despite the efforts of government agencies, there are many fake and counterfeit products around. Many counterfeit goods are sold at car boot sales, pubs, markets, and fairs. This makes it difficult to trace the fraudster once you’ve bought from them. Fake goods are also sold online, although auction sites such as eBay try to clamp down on counterfeiting and piracy.

In the computer world, flash memory stage is particularly susceptible to counterfeiting. The most commonly affected devices are USB flash drives, but SD/CF and even SSD are affected.

There are various ways you can protect yourself. If the price of the flash drive seems too good to be true, it probably is. If you’re buying online, it’s impossible to be certain the flash storage is legit, and it’s unlikely checking the device’s label or printed logo is going to resolve any concerns. It’s worth buying from well-established and trusted retailers, but even they can be a victim.

We recommend you always verify and validate your flash storage to ensure you don’t lose data in the future. It’s not sufficient to simply trust what df, for example, reports as the disk size. This simply relays what the drive reports (which can be fake). And neither is using dd to write data a good test to verify the legitimacy of the drive.

Bearing this in mind, there are various tools that identify if the drive is counterfeit. f3 is a set of 5 open source utilities that detect and repair counterfeit flash storage. It achieves this by testing the media’s capacity and performance. It tests the real size and compares it to what the drive says.

f3 is an open source implementation of the algorithm used by H2testw.

f3 stands for Fight Flash Fraud, or Fight Fake Flash.

Installation

Let’s start with compiling the software. Clone the project’s repository.

$ git clone https://github.com/AltraMayor/f3.git

To compile f3write and f3read, type at a shell:

$ make

The next make command installs the f3write and f3read binaries to /usr/local/bin/. And it installs the man pages to /usr/local/share/man/man1/.

$ make install

f3probe and f3brew require version 1 of the library libudev, and f3fix requires version 0 of the library libparted to compile. On my systems, these libraries are already installed.

To compile and install f3probe, f3fix, and f3brew, type:

$ make extra

And to install them to /usr/local/bin, type:

$ sudo make install-extra

There are no manual pages for f3probe, f3fix, or f3brew.

If you want to change the location of the installed binaries, edit the Makefile.

The developer does not provide any packages for any distributions, and there’s no cross-packages (AppImage, snap, or Flatpak). But some Linux distributions provide their own package. For example, the Arch User Repository includes f3.

Next page: Page 2 – In Operation

Pages in this article:
Page 1 – Introduction / Installation
Page 2 – In Operation
Page 3 – f3-qt – GUI frontend to f3
Page 4 – Summary