Verifying SD-card size/capacity on Mac OS X
October 15, 2017
Being somewhat familiar with the fact that there are a number of counterfeit SD-cards on Amazon that claim a capacity, but exhibit write errors or "looping back around" behavior when you try to actually use the full claimed capacity of the card, I wanted to verify that new SD cards I buy actually are their claimed size. More than that, I want proof that if I put a unique set of data on there that uses up the full capacity, that the same unique set of data can be retrieved later – proof that the card is both legitimate, and not exhibiting bad sectors / manufacturer defects.
I use Mac OS X, and the easiest way to do this was with the tool f3
.
You can find the official site here
You'll need to be familiar with using Terminal, too.
To start, you'll want to install the HomeBrew or MacPorts package managers. This is fairly straightforward, so google's your friend here.
Next,
brew install f3
or,
port install f3
Depending on which package manager you like. I chose HomeBrew.
As of writing, the HomeBrew package is at version 7.0 and has the tools
f3write
and f3read
. Curiously the f3probe
tool is missing, but you
don't necessarily need it to just verify an SD card.
To start verifying your card, plug it in, and run the following:
df -h
Which yields something like this:
$ df -h
Filesystem Size Used Avail Capacity iused ifree %iused Mounted on
/dev/disk1 811Gi 778Gi 33Gi 96% 5089882 4289877397 0% /
devfs 345Ki 345Ki 0Bi 100% 1194 0 100% /dev
map -hosts 0Bi 0Bi 0Bi 100% 0 0 100% /net
map auto_home 0Bi 0Bi 0Bi 100% 0 0 100% /home
/dev/disk2s2 1.0Ti 980Gi 43Gi 96% 7458248 4287509031 0% /Volumes/Time Machine Backups
/dev/disk3s1 119Gi 7.8Mi 119Gi 1% 62 975218 0% /Volumes/Untitled
Now, it's up to you to carefully pick the disk that you just plugged in.
If you aren't sure, unplug it, and run df -h
to see what's still there,
plug back in, and run df -h
to see what appears. Be 100% sure that the
capacity of the drive looks right – we wouldn't want to trash one of
your real drives here!
In this case, I see that /dev/disk3s1
(the system-level specifier for this drive)
is about the same size as my claimed 128gb drive – 119Gi
under Avail
.
That's mounted at /Volumes/Untitled
(i.e. the place I go in the filesystem
to interact with the volume).
Now, I can actually verify the drive with f3
by first writing data to it:
$ f3write /Volumes/Untitled
F3 write 7.0
Copyright (C) 2010 Digirati Internet LTDA.
This is free software; see the source for copying conditions.
Free space: 119.05 GB
Creating file 1.h2w ... OK!
Creating file 2.h2w ... OK!
Creating file 3.h2w ... OK!
[snip...]
Creating file 116.h2w ... OK!
Creating file 117.h2w ... OK!
Creating file 118.h2w ... OK!
Creating file 119.h2w ... OK!
Creating file 120.h2w ... OK!
Free space: 128.00 KB
Average writing speed: 70.86 MB/s
And now, let's confirm that the data was written correctly by reading it back:
$ f3read /Volumes/Untitled
F3 read 7.0
Copyright (C) 2010 Digirati Internet LTDA.
This is free software; see the source for copying conditions.
SECTORS ok/corrupted/changed/overwritten
Validating file 1.h2w ... 2097152/ 0/ 0/ 0
Validating file 2.h2w ... 2097152/ 0/ 0/ 0
Validating file 3.h2w ... 2097152/ 0/ 0/ 0
[snip...]
Validating file 118.h2w ... 2097152/ 0/ 0/ 0
Validating file 119.h2w ... 2097152/ 0/ 0/ 0
Validating file 120.h2w ... 94208/ 0/ 0/ 0
Data OK: 119.04 GB (249655296 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: 68.01 MB/s
And, that's good – can safely store media on this for the next big adventure!