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

So what is F3?

F3 is an open source command line utility created by Michel Machado. You can find the package in the official Debian repositories and probably in your distrubtion repositories. The package description says:

sudo apt-get install f3

Test the flash

First, we will test the flash thoroughly. We will fill it with data, then check this data for errors. Format the flash, mount it, then pass the mount folder to f3write to start filling it:

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

Fix attempt

I had an old 1GB flash which had a defected part from the time I got it. Here is the result I had from testing it using f3write and f3read:

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

Gparted screenshot of the fixed flash

The green rectangle is the newly created partition that f3fix created. The rest is the fake part which is now left without partitioning. It is clear that this is not a permanent fix, you can recreate partitions anytime, that’s what I did for the purpose of this tutorial. But if you left the partition table as f3fix did, you should be able to format this partition and use it without a problem.

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
Ahmed Essam

Ahmed Essam

Web developer, Arabic Native, open-source enthusiastic, trying to do things the right way.