How to recover a corrupted flash memory using F3 tools under Linux

So what is F3?

F3 (Fight Flash Fraud or Fight Fake Flash) tests the full capacity of a flash card (flash drive, flash disk, pen drive).

F3 writes to the card and then checks if can read it. It will assure you have not been bought a card with a smaller capacity than stated. Note that the main goal of F3 is not to fix your removable media. However, there are resources to mark the invalid areas.

This package provides these executables: f3write, f3read, f3brew, f3fix and f3probe.

sudo apt-get install f3

Test the flash

f3write /media/user/mounted_flash
f3read /media/user/mounted_flash

Fix attempt

SECTORS      ok/corrupted/changed/overwritten
Validating file 1.h2w ... 1021326/ 991976/ 0/ 2
Data OK: 498.69 MB (1021326 sectors)
Data LOST: 484.36 MB (991978 sectors)
Corrupted: 484.36 MB (991976 sectors)
Slightly changed: 0.00 Byte (0 sectors)
Overwritten: 1.00 KB (2 sectors)
Average reading speed: 21.21 MB/s
> lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sr0 11:0 1 1024M 0 rom
sdc 8:32 1 986M 0 disk
└─sdc1 8:33 1 985M 0 part
...
f3 probe 6.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.Probe finished, recovering blocks... DoneBad news: The device `/dev/sdc' is a counterfeit of type limboYou can "fix" this device using the following command:
f3fix --last-sec=1015872 /dev/sdc
Device geometry:
*Usable* size: 496.03 MB (1015873 blocks)
Announced size: 986.00 MB (2019328 blocks)
Module: 1.00 GB (2^30 Bytes)
Approximate cache size: 0.00 Byte (0 blocks), need-reset=yes
Physical block size: 512.00 Byte (2^9 Bytes)
Probe time: 16.10s
# sudo ./f3fix --last-sec=1015872 /dev/sdc
F3 fix 6.0
Copyright (C) 2010 Digirati Internet LTDA.
This is free software; see the source for copying conditions.
Drive `/dev/sdc' was successfully fixed

If you get some sectors corrupted, repeat the f3write/f3read test. Some drives recover from these failures on a second full write cycle. However, if the corrupted sectors persist, the drive is junk because not only is it a fake drive, but its real memory is already failing

SECTORS      ok/corrupted/changed/overwritten
Validating file 1.h2w ... 1013280/ 0/ 0/ 0
Data OK: 494.77 MB (1013280 sectors)
Data LOST: 0.00 Byte (0 sectors)
Corrupted: 0.00 Byte (0 sectors)
Slightly changed: 0.00 Byte (0 sectors)
Overwritten: 0.00 Byte (0 sectors)
Average reading speed: 15.32 MB/s

 by the author.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store