Testing SD card capacity and speed – in Linux
SD cards are getting cheaper and cheaper. They are also growing larger and larger. Unfortunately, it also causes some sellers to sell fake SD cards – they are introduced as 32GB or 64GB but in fact, they are much smaller – 8GB, 4GB. If you try to use them, files will be written “properly” (without errors), but some of them will be corrupted when you will try to read them back. In reality, they were overwritten by the data saved later.
How to check if the card you are using (or just bought) is working properly or not? You can fill the whole card with the data and read it back – checking if the data read is the same you wrote. Of course, there is an app for this 🙂
Introducing F3
F3 stands for Fight Flash Fraud. This is the main role of the tool. It is available on GitHub but you can also install it as many other Linux apps:
sudo apt install f3
Once installed, you should insert your SD card into the reader, mount it (if it is not mounted automatically) and start writing the data to the card:
f3write /place/where/the/card/is/mounted This will take some time. For the slow cards and slow readers, it can take even a few hours. The tool is writing files to the card, filling them with pseudo-random data. The messages displayed by the tool looks as follows:
The tool is informing about the progress – in percentage and time left. There is also a write speed displayed.
Once the writing is done, you can immediately test it with f3read. In my case, I prefer to unmount the drive and mount it again. Just in case. The command syntax is also straight forward:
f3read /place/where/the/card/is/mounted
The tool is reading files one by one, checking if the data matches what was written. The output looks like this:
In my case, all files are OK, there are zeros in corrupted/changed/overwritten columns, which means that the files are filled with proper data. Once the reading is finished, you will see the summary:
Again – in my case everything is fine. In the summary, you can also see the average reading speed. The same is displayed on the f3write summary – the average writing speed. This gives you information about the performance you may expect.
Quick testing and fixing the card
There is also a way to quickly test the card and fix its capacity. Please note that this method is destructive and will erase all information on the card. To test the card simply use:
sudo f3probe --destructive --time-ops /dev/[device name]
Please note that this time we are not using the mount point, but the device handler itself. Also, it needs to be executed as a privileged user. Unfortunately, I have no “fake” card right now, so my test went just fine. Below you can see the results displayed by f3probe:
If the probe will show that there are errors and will display the last good sector, you can use one more tool to fix the issue:
sudo f3fix --last-sec=1234543 /dev/[device name]
This way, the partition of the proper size will be created. This will not increase the actual size of the card nor fix it, but it will prevent the operating system from writing the data in corrupted area.
I wish you that all your cards went through this test just fine 🙂
Such a useful tip! Thank you!
Thanks 🙂