Skip to content

Instantly share code, notes, and snippets.

@mqu
Last active February 6, 2020 18:51
Show Gist options
  • Save mqu/cc6f2c3a21d8daebf9b2682c575a3911 to your computer and use it in GitHub Desktop.
Save mqu/cc6f2c3a21d8daebf9b2682c575a3911 to your computer and use it in GitHub Desktop.
quick and dirty sdcard (microsd) flash test script (and links). Comments are welcome.
F3(1) test real flash memory capacity F3(1)
NAME
f3write, f3read - test real flash memory capacity
SYNOPSIS
f3write [--start-at=NUM] [--end-at=NUM] <PATH>
f3read [--start-at=NUM] [--end-at=NUM] <PATH>
DESCRIPTION
F3 (Fight Flash Fraud or Fight Fake Flash) tests the full capacity of a flash
card (flash drive, flash disk, pendrive). It writes to the card and then checks
if can read it. It will assure you haven't been sold a card with a smaller capac‐
ity than stated.
When writing to flash drive, f3write fills the filesystem with 1GB files named
N.h2w, where N is a number (i.e. /[0-9]+/).
WARNING: all data on the tested disk might be lost!
OPTIONS
--start-at=NUM
Initial number of file names. Default value is 1.
--end-at=NUM
Final number of file names. Default value is "infinity".
EXAMPLE
To write over a flash drive mounted at /media/TEST:
$ f3write /media/TEST
To read this flash drive:
$ f3read /media/TEST
SEE ALSO
For detailed information about the F3 tools, see:
http://oss.digirati.com.br/f3/
AUTHOR
F3 was written by Michel Machado <michel@digirati.com.br>. This manual page was
first written by Joao Eriberto Mota Filho <eriberto@eriberto.pro.br>.
#!/bin/bash
# SDCARD test script
# autor Marc Quinton / august 2017
# usefull links :
# - f3 : http://oss.digirati.com.br/f3 (sdcard test program) ; https://linuxreviews.org/HOWTO_test_SD_cards_and_identify_fake_ones_(mostly_sold_on_ebay)
# - scanflash : https://github.com/Malvineous/scanflash
dd if=/dev/urandom bs=1M count=512 of=data
# mount your SDCARD and go to directory
# create 1 random data file
# then duplicate this file until no space left on SDCARD.
# when disk is full, for loop will exit.
for i in $(seq 130) ; do
f=$(printf "%02d" $i)
echo $f
cp data $f || break
sync
done
# flush buffer and empty system buffers
sync ; sync; sync
echo 3 > /proc/sys/vm/drop_caches
# compute MD5SUM for each files
md5sum data ??
# how much data as been writen on disk :
du -sm .
# is there any free disk space;
# many times, "fake sdcards claims to have more space than real
df -H
@mqu
Copy link
Author

mqu commented Feb 6, 2020

install f3 (Fight Flash Fraud) on debian (ubuntu) : apt install f3

  • usage : man f3write.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment