Detecting Fake Flash Drives and SD cards

Linux ยท

Updated on

It’s not uncommon to see myriads of suspiciously cheap SD cards on Amazon or AliExpress and most of those listings are scams. Their capacity and/or performance claims are lies and they lure their victims by offering lower prices. Low price is a huge red flag but even adequately priced SD cards and flash drives might be fake or disfunctional and it’s always a good idea to check them before you start to rely on them for storing your data. Luckily for us, it’s very easy to test any SD card right from the Linux terminal.

SD card (post illustration)

Photo by Tom Pumford

Fraud is Everywhere

Fake flash drives are still plentiful and major online retailers such as Amazon shamelessly advertise them on their web sites:

Fake SD card

Fake USB flash drive

Fight Flash Fraud

Fight Flash Fraud (F3) is a popular open source set of utilities that can check any flash drive. It’s author was inspired by a blog named Fight Flash Fraud so I guess that’s where this name came from.

Installing F3

F3 is easy to install on most of the Linux distributions but the exact installation instructions can be different. It’s better to check the official package repos that come with your particular distro. I use Debian, so https://packages.debian.org is a good first place to check for this tool. Here is it. Alternatively, it can be found with the use of apt command line tool. Now that we know the package name, it’s time to install it:

sudo apt install f3

Using F3

The most powerful utility of the F3 pack is f3probe. It allows us to check the flash drives for almost every possible kind of fraud and it can also measure sequencial read and write speed. Here is how f3probe can be used to perform all of the basic tests:

Make sure that the data on your flash drive is backed up because some of the tests might destroy any data remaining on your flash drive.

sudo f3probe /dev/mmcblk0

Please note that /dev/mmcblk0 is the identifier of your device that is assigned by Linux when you connect it to your system. In my case, it’s an SD card inserted in an SD card reader and such devices have a prefix mmcblk. Other devices, such as pen drives, usually have a prefix sd. You should locate your device first and use it’s location as an input to f3probe (the easiest way to do that is to run lsblk before and after you insert your flash drive, which allows you to quickly find the location of your flash drive).

Hopefully, you should see a message like this:

Good news: The device `/dev/mmcblk0' is the real thing

Other nice feature of f3 suite is it’s ability to measure read and write speeds under load. In order to do that in a clean way, it’s better to partinion the SD card first:

sudo fdisk /dev/mmcblk0

The fdisk utility will ask for your input. If your card has no partitions, just enter n (which means “new partition”), then you may choose to agree with the defaults and, finally, enter w command in order to save changes. If you already have a partition of the size of the whole card, you can keep it and ignore this command, or you can press d to delete that partition and then create the new one from scratch.

Now, it’s time to create a file system for our new partition:

sudo mkfs.ext4 /dev/mmcblk0p1

Finally, we can mount the new partition we just created to to the /mount/sd/ directory

sudo mkdir -p /mnt/sd
sudo mount /dev/mmcblk0p1 /mnt/sd

Now we’re ready to do some benchmarking. Let’s start with measuring writing speed:

sudo f3write /mnt/sd/

Here is an example output:

Average writing speed: 34.66 MB/s

Now that we have a bunch of files written on SD card, we can ask f3read to read them all and measure the average reading speed:

sudo f3read /mnt/sd/

It should output something like that:

Average reading speed: 66.14 MB/s

Testing different SD cards

I tested a few of my SD cards and here is what I found:

Card 1: SanDisk Ultra C10 16 GB (2012)

  • Genuine
  • Read: 39.72 MB/s
  • Write: 5.91 MB/s
cd /sys/block/mmcblk0/device/ \
    && echo "Device Manufacturer: $(cat manfid)" \
    && echo "Device Name: $(cat name)" \
    && echo "Hardware Revision: $(cat hwrev)" \
    && echo "Firmware Revision: $(cat fwrev)" \
    && echo "Manufacture Date: $(cat date)"
  • Device Manufacturer: 0x000003
  • Device Name: SU16G
  • Hardware Revision: 0x8
  • Firmware Revision: 0x0
  • Manufacture Date: 12/2012

This card has C10 speed class which means that it should be capable to write data at the speed of at least 10 MB/s and, as we can see, it fails to do that. That’s probably my fault because this card was exposed to water a few times and some of it’s connectors look damaged and rusty.

Card 2: SanDisk Ultra C10 16 GB (2015)

  • Genuine
  • Read: 40.15 MB/s
  • Write: 11.65 MB/s
  • Device Manufacturer: 0x000003
  • Device Name: SL16G
  • Hardware Revision: 0x8
  • Firmware Revision: 0x0
  • Manufacture Date: 03/2015

This card has C10 speed class which means 10 MB/s, and it delivers on it’s promise.

Card 3: Samsung EVO Plus U3 128 GB (2017)

  • Genuine
  • Read: 66.14 MB/s
  • Write: 34.66 MB/s
  • Device Manufacturer: 0x00001b
  • Device Name: ED4QT
  • Hardware Revision: 0x3
  • Firmware Revision: 0x0
  • Manufacture Date: 07/2017

This card has U3 speed class which means that it should be capable to write data at the speed of at least 30 MB/s, which it does.

Card 4: SanDisk EDGE C10 A1 16 GB (Raspberry Pi 4 Desktop Kit Default, 2019)

  • Genuine
  • Read: 71.80 MB/s
  • Write: 16.83 MB/s
cd /mnt/sd
sudo fio \ 
    --name=test \
    --filename=io-test-file \
    --size=4G \
    --ioengine=libaio \
    --direct=1 \
    --readwrite=randrw \
    --rwmixread=75
  • Random Read: 2064kB/s, 503 IOPS
  • Random Write: 690kB/s, 168 IOPS

  • Device Manufacturer: 0x000003

  • Device Name: SC16G

  • Hardware Revision: 0x8

  • Firmware Revision: 0x0

  • Manufacture Date: 05/2019

Card 5: SanDisk Ultra C10 A1 64 GB (2019)

  • Genuine
  • Read: 75.63 MB/s
  • Write: 31.92 MB/s
  • Random Read: 1831kB/s, 447 IOPS
  • Random Write: 612kB/s, 149 IOPS
  • Device Manufacturer: 0x000003
  • Device Name: SC64G
  • Hardware Revision: 0x8
  • Firmware Revision: 0x0
  • Manufacture Date: 09/2019

Interestingly, this card scored above V30 minimal requirement but it is marked as C10 (3 times slower). I have no idea why SanDisk don’t mark those cards as being able to write data at 30+ MB/s.

Conclusion

It’s always a good idea to test your flash drives before using them, especially if you just bought a new flash drive and you have a limited time to return it in case it fails to deliver on it’s promises. F3 is a great set of tools aimed to detect fraud and make some basic performance metrics.

Please note that it shows sequential read and write speed and not a random read/write speed, which is fine for the most of the use cases such as storing relatively large files or using your flash drive with a digital camera. Random speeds are more important for the tasks like running an operating system from your SD card. Some boards such as Raspberry Pi do excatly that so you should also measure random read/write speed in order to find the best SD card for your board.

This site doesn't have ads and the reasons are simple:

  • Most people don't want to see ads, that's not what they look for when they open web pages.
  • Ad scripts can track visitors, exposing private data to third parties.

If you find this post valuable and you wish to leave a tip, you can do it with Bitcoin:

34CXtg7c4Vbw8DZjAwFQVsrbu9eDEbTzbA