Once a USB flash drive or an SD card is purchased, it is a good idea to check if the announced capacity of a device is real or fake (as a system may show a wrong size).
Linux and MacOS users can do this from the command line using the f3
– a set of tools for testing for fake USB flash drives and SD cards by measuring their real capacity and READ/WRITE speed.
In this note i will show how to find out the actual size of USB flash drives and SD cards, how to fix drives with fake capacity and how to measure the real READ/WRITE performance.
Cool Tip: Test performance of HDD, SSD, USB Flash Drive, SD card! Read more →
Fake Flash Test
Install f3
(Fight Fake Flash), a simple tool that tests capacity and performance of USB flash drives and SD cards:
Ubuntu:
$ sudo apt install f3
MacOS:
$ brew install f3
CentOS:
$ sudo yum install epel-release $ sudo yum install f3
Insert the USB thumb drive or SD card which real size you want to find out.
List block devices and search for the name of the device you want to test:
$ lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 115,5G 0 disk └─sda1 8:1 0 115,5G 0 part ├─mint--vg-root 253:0 0 114,5G 0 lvm / └─mint--vg-swap_1 253:1 0 980M 0 lvm [SWAP] sdb 8:16 1 28,9G 0 disk └─sdb1 8:17 1 28,9G 0 part /media/user/USB Drive mmcblk0 179:0 0 29,7G 0 disk └─mmcblk0p1 179:1 0 29,7G 0 part /media/user/3264-3234
In the example above, sdb
device name corresponds to my 32GB USB Flash Drive and mmcblk0
is a 32GB Micro SD Card.
Check Real Size of USB Flash Drive
Check the real size of the USB flash drive:
$ sudo f3probe --destructive --time-ops /dev/sdb F3 probe 7.0 Copyright (C) 2010 Digirati Internet LTDA. This is free software; see the source for copying conditions. WARNING: Probing normally takes from a few seconds to 15 minutes, but it can take longer. Please be patient. Good news: The device `/dev/sdb' is the real thing Device geometry: *Usable* size: 28.88 GB (60555264 blocks) Announced size: 28.88 GB (60555264 blocks) Module: 32.00 GB (2^35 Bytes) Approximate cache size: 0.00 Byte (0 blocks), need-reset=no Physical block size: 512.00 Byte (2^9 Bytes) Probe time: 8'26" Operation: total time / count = avg time Read: 965.1ms / 4815 = 200us Write: 8'24" / 4192321 = 120us Reset: 279.4ms / 1 = 279.4ms
Options:
Option | Description |
---|---|
-n , --destructive |
Do not restore blocks of the device after probing it |
-t , --time-ops |
Time reads, writes, and resets |
Fix Fake SD Card
Check the actual capacity of the SD card:
$ sudo f3probe --destructive --time-ops /dev/mmcblk0 F3 probe 7.0 Copyright (C) 2010 Digirati Internet LTDA. This is free software; see the source for copying conditions. WARNING: Probing normally takes from a few seconds to 15 minutes, but it can take longer. Please be patient. Bad news: The device `/dev/mmcblk0' is a counterfeit of type limbo You can "fix" this device using the following command: f3fix --last-sec=1015872 /dev/mmcblk0 Device geometry: *Usable* size: 496.03 MB (1015873 blocks) Announced size: 29.72 GB (62333952 blocks) Module: 32.00 GB (2^35 Bytes) Approximate cache size: 0.00 Byte (0 blocks), need-reset=no Physical block size: 512.00 Byte (2^9 Bytes) Probe time: 1'14" Operation: total time / count = avg time Read: 853.7ms / 4815 = 177us Write: 1'11" / 4192321 = 17us Reset: 197.7ms / 1 = 197.7ms
As you can see, the real actual size of 32GB Micro SD Card is much lower.
Warning: The f3fix
command will destroy any previously stored data on your disk!
Correct capacity of SD card to actual size:
$ sudo f3fix --last-sec=1015872 /dev/mmcblk0
f3fix
creates a partition that fits the actual size of the fake drive (use f3probe
’s output to determine the parameters for f3fix
).
Test READ/WRITE Speed
f3
tools you can test performance of USB flash drives and SD cards.
f3write
fills unused part of a filesystem with files NNNN.fff
with known content, and f3read
analyzes these files to determine whether the contents are corrupted, as happens with fake flash.
At the end of the tests, both utilities report an average READ/WRITE speed.
Test the READ speed of the SD card mounted at /media/user/3264-3234
:
$ f3read /media/user/3264-3234
Test the WRITE speed:
$ f3write /media/user/3264-3234
Good sharing! It did save my data & fight profiteers
Worked as advertised, found counterfeit SDHC. Thanks!