A Weird Imagination

Testing cheap flash drives

Posted in

The problem#

USB flash drives have gotten very cheap, especially if you don't care too much about the speed or capacity. It's convenient to buy multiple for no more than a few dollars each to always have one available or even to just give away. But sometimes very cheap hardware is non-functional or even counterfeit, claiming to be able to store more data than it really can, so when you try to read that data it will be corrupted or missing.

The solution#

f3 ("Fight Flash Fraud") is a tool for testing flash drives (including SSDs). The basic usage is

( f3write '/mnt/usb/' && f3read '/mnt/usb/' ) | tee f3-log

Replacing /mnt/usb/ with the directory your flash drive is mounted at. If you're testing multiple drives, give the log file a descriptive name to identify which drive the test is for.

(Or use the log-f3wr helper script included with f3 which does basically the same thing.)

That will write files to fill the flash drive and then read them back and verify they contain the same data that was written. This both checks for counterfeit drives as well as failing (or dead-on-arrival) drives. In addition to reporting if the drive is in fact capable of storing as much data as it claims, it will report the average write/read speeds while performing those operations, so it doubles as a simple benchmark.

You should always test new drives before trusting them with real data.

The details#

Which USB port#

If a drive appears to be failing, before you blame the drive, make sure you've attached it to a USB port that is actually delivering enough power. Underpowered USB devices may fail in weird ways. A powered USB hub is best, although plugging directly into your computer should also work fine. Just avoid unpowered hubs.

Other devices#

Unfortunately, USB flash drives are not the only counterfeits found in the wild. Counterfeit SSDs and SD cards have also been reported, so those should also be tested, especially if you got a suspiciously good deal.

Faster testing#

The test given above writes the entire drive, which may take a long time. For a set of cheap 64GB flash drives I bought recently, filling one with f3write took two hours each; luckily the read speed was much faster. If you're wanting to verify the whole drive works, that's necessary, but if you're just trying to make sure it's not counterfeit, you can take shortcuts.

One way is to use f3probe, which has its own faster algorithm for selecting exactly where to write and read to decide is a drive is lying about its capacity without needing to fill the entire drive.

Another option is to use f3write/f3read but give f3write the --end-at argument to have it write only that many gigabytes1 instead of filling up the drive. This FAQ points out that for determining if a drive is counterfeit, it's generally sufficient to check just past one quarter capacity as if it's half of the claimed capacity, that's probably not enough cheaper to make the scam profitable.


  1. The documentation says that option controls how many files to write, but it normally writes 1 gigabyte files. 

Comments

Have something to add? Post a comment by sending an email to comments@aweirdimagination.net. You may use Markdown for formatting.

There are no comments yet.