Checking USB flash drives and flash memory cards for correct functionality
Test Run
USB memory sticks and flash memory cards are part of the equipment of almost every mobile IT user today, but media defects can cause data loss. A small tool by the name of F3 helps.
USB sticks and flash memory cards are small, lightweight, and available in a variety of storage capacities, but even though they have no mechanical components, and some sticks even have a metal housing, the memory is not completely wear-free. Some flash storage media, often offered for low prices online, can fail to reach the advertised capacity. This shortcoming is really annoying when your important data is suddenly gone or you can no longer access the medium because of memory cell failure.
To spare yourself this mishap, you need only two things: Linux and the F3 program. F3 uses a read and write test to verify the integrity of the memory cells of your flash media and thus prevent unpleasant surprises.
Get Started
The program, which hails from Brazil, is available from a no-frills website as a source code archive [1]. Start by downloading the ZIP archive and unpacking it in a directory of your choice. Next, change to the newly created f3-2.2
subdirectory and compile the software in a terminal using the make linux
command.
If you see an Error 127 message initially, you need to install make
and the gcc
collection from your distribution's repositories. When successfully compiled, the routine generates two executable programs: f3write
and f3read
[2]. These two command-line tools test your flash medium with read and write accesses to determine the actual available capacity, and they help you track down defective memory cells and placebo storage quickly and reliably.
Test
I tested the software with an Intenso stick [3] and a no-name USB stick – both of which claimed to have 4GB of capacity – as well as an SD card. To use F3, you first need to make sure you have backed up all the important data on the storage medium to be tested before emptying the medium. F3write writes 1GB files with an extension of .fff
to the medium; depending on the capacity, the last file to be written can be smaller.
Because f3write does not overwrite any existing data, the medium should be completely free of old data to ensure reliable writes by f3write. To start the software, you simply enter the following command in a terminal:
./f3write /media/<drive-UUID>
Or, in distributions that use udisks2, enter:
./f3write /run/media/<username>/<drive-UUID>
The software generates the files and displays its progress in the terminal (Figure 1).
Depending on the capacity and memory blocks used, the write process can take quite a long time – even for smaller media, because they often reach their limits at speeds of 2 to 4MBps. Premium storage hardware, however, will also impress with higher write rates.
After successfully completing the write operation, enter the following in the terminal:
./f3read /media/<drive-UUID>
or
./f3read /run/media/<Username>/<drive-UUID>
F3read now reads the newly generated files. If any problems occur, or the tool cannot read some sectors, you will immediately see this reported in the terminal. After completing the read operation, the read speed is also visualized (Figure 2).
On the basis of the value detected when reading the storage medium, you can see the true capacity of your flash memory device. If the memory size differs compared with the capacity from the write operation and, in particular, if Corrupted shows a value other than 0, your flash memory is defective.
Independent
To test the reliability of F3 for storage media using various platforms, I formatted the test objects with different filesystems and then told F3 to read and write to the drives. I discovered that the software worked fine with USB memory sticks and memory cards using the typical FAT32 filesystem, as well as with media using the popular Linux ext2 filesystem. Additionally, F3 had no problems with the FAT16 filesystem designed for smaller disks. The write and read speeds are similar, independent of the filesystem used.
Buy this article as PDF
(incl. VAT)
Buy Linux Magazine
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters
Support Our Work
Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.
News
-
There's a New Open Source Terminal App in Town
Ghostty is a new Linux terminal app that's fast, feature-rich, and offers a platform-native GUI while remaining cross-platform.
-
Fedora Asahi Remix 41 Available for Apple Silicon
If you have an Apple Silicon Mac and you're hoping to install Fedora, you're in luck because the latest release supports the M1 and M2 chips.
-
Systemd Fixes Bug While Facing New Challenger in GNU Shepherd
The systemd developers have fixed a really nasty bug amid the release of the new GNU Shepherd init system.
-
AlmaLinux 10.0 Beta Released
The AlmaLinux OS Foundation has announced the availability of AlmaLinux 10.0 Beta ("Purple Lion") for all supported devices with significant changes.
-
Gnome 47.2 Now Available
Gnome 47.2 is now available for general use but don't expect much in the way of newness, as this is all about improvements and bug fixes.
-
Latest Cinnamon Desktop Releases with a Bold New Look
Just in time for the holidays, the developer of the Cinnamon desktop has shipped a new release to help spice up your eggnog with new features and a new look.
-
Armbian 24.11 Released with Expanded Hardware Support
If you've been waiting for Armbian to support OrangePi 5 Max and Radxa ROCK 5B+, the wait is over.
-
SUSE Renames Several Products for Better Name Recognition
SUSE has been a very powerful player in the European market, but it knows it must branch out to gain serious traction. Will a name change do the trick?
-
ESET Discovers New Linux Malware
WolfsBane is an all-in-one malware that has hit the Linux operating system and includes a dropper, a launcher, and a backdoor.
-
New Linux Kernel Patch Allows Forcing a CPU Mitigation
Even when CPU mitigations can consume precious CPU cycles, it might not be a bad idea to allow users to enable them, even if your machine isn't vulnerable.