
Testing an SD Card's true capacity - alecjw
http://blog.nothinguntoward.eu/?p=238
======
londons_explore
A pretty big chunk of memory cards are fake.

"kind" fakes show write errors when writing data. Evil fakes just return
garbage data.

I have even witnessed a few fakes which understand a fat32 filesystem and make
sure the filesystem data structures and the first and last few kilobytes of
every file get mapped to working flash so that a chkdsk won't pick up issues
and browsing the files shows no obvious issue. Many cameras store jpeg
thumbnails, and the thumbnails continue to show too.

~~~
TazeTSchnitzel
Then there's the fakes that modulo the address. Write beyond the end of the
actual flash and you'll write over the start!

~~~
mikeash
Seems like that would be the simplest way to design one. Just leave off some
of the high address lines.

------
cjnicholls
I had this a year or so ago from Amazon on a Black Friday deal. A simple I/O
test is usually enough to confirm a fake. The sellers are aware of their stock
being fake, full refund without return and reported it to Amazon. Ebay have
supporting documentation about finding fakes on their platforms and testing
authenticity. [0] [http://www.ebay.co.uk/gds/Spotting-Counterfeit-fake-SD-
Micro...](http://www.ebay.co.uk/gds/Spotting-Counterfeit-fake-SD-Micro-SD-USB-
Memory-Cards-/10000000175807852/g.html)

~~~
kelchm
This is made a lot worse at Amazon because of the commingling of stock from
different sellers.

~~~
cjnicholls
Thats true but Amazon needs to create a more transparent reporting system that
is buyer centered such as seller rating rather than just item. This was also
highlighted with Apple chargers so Amazon has a problem with no 'solution' to
preventing it.
([https://www.forbes.com/sites/amitchowdhry/2016/10/23/apple-n...](https://www.forbes.com/sites/amitchowdhry/2016/10/23/apple-
nearly-90-of-genuine-iphone-chargers-on-amazon-are-fake/#7cdf7a595b07))

------
woliveirajr
There are some good programs already written to test your Sd / flash card /
USB / whatever you want:

USB Flash Drive Tester:
[http://www2.vconsole.com/client/?page=page&id=13](http://www2.vconsole.com/client/?page=page&id=13)

H2testw:
[https://www.portablefreeware.com/?id=1519](https://www.portablefreeware.com/?id=1519)

------
throwanem
Stock Wordpress takes it hard when HN comes around!

The Internet Archive has it:
[http://web.archive.org/web/20170711105235/blog.nothinguntowa...](http://web.archive.org/web/20170711105235/blog.nothinguntoward.eu/?p=238)

~~~
ship_it
True, thanks for the link. Shame that author uses Wordpress. I'd advice him to
use a static page generator for the future.

~~~
18nleung
Wordpress is still essentially the status quo outside of technical circles and
for non-technical people I'd recommend it over most other static site
generators.

~~~
throwanem
There's a whole pile of caching plugins for it, too. I can't speak to their
relative quality, though; I just stuck Cloudflare in front of my site and
called it a day. Perhaps I will come to regret that.

------
CaptainZapp
Why buy an SD card of ebay or, alternatively, find a deal which is too good to
be true (and is neither good, nor true, of course)?

A branded, well specced SD card is not really that expensive that I would risk
- for example - my photos which are certainly much more valuable to me than a
few $ saved. Even if it's in the 10s $ range.

I honestly just don't get it.

~~~
ptero
How you do you purchase cards to guarantee you are not getting a fake? I
believe fakes are pretty much everywhere now, in branded stores as well. Maybe
buying those from stores that serve people who care helps (e.g., B&H photo --
as you indicate, a pro photographer losing his photos would be furious). They
try to act on problems and work with suppliers quickly, but even this is not a
guarantee.

A better approach IMO is to test the card first using easily available tools
and use backups. This is more work, but can save you a major aggravation. My
2c.

~~~
sho
> e.g., B&H photo

I basically buy all my camera gear from B&H. The prices are competitive, their
shipping is prompt and reliable, and I don't have to think about counterfeits
- I have a fair amount of trust that they will not devastate their entire
professional-oriented brand by allowing fakes into their supply chain. Getting
something fake from B&H would probably be more shocking to me that getting it
from an Apple store! Amazon is a different story - you can hardly tell if it's
the "real" sandisk (or whoever) you're buying from. Hundreds of listings from
hundreds of unknown sellers for the same thing, all slightly different, maybe
backed by amazon, maybe not? No thanks.

I'd rather have a reasonable amount of trust in the distribution chain and not
have to run checks when the thing arrives.

~~~
cdubzzz
Further to that, I buy as much IT stuff in general as I can get at B&H for
those very same reasons. I even got a couple of 52-port PoE switches from them
a few years back. Generally the prices are better than/comparable to Amazon
and faster shipping (to the D.C. area, to be fair).

------
ehPReth
I've been using F3
([http://oss.digirati.com.br/f3/](http://oss.digirati.com.br/f3/)) to test new
SD cards. Installable via homebrew and seems to work quite well

~~~
randkyp
Yes. I just run f3probe for a quick capacity & speed test and then run a
single-pass, random data badblocks test just to be sure. If there are any
'bad' sectors, I just pass the badblocks output to mkfs. Be careful with your
choice of card reader/adapter though--some starts to get too hot and end up
breaking the card under heavy testing!

------
amelius
Title should be: Testing _for_ a fake SD card

------
lima
About the sync: you can bypass the fs cache by specifying
iflag=direct/oflag=direct.

~~~
qb45
In fact, I'm quite surprised that it worked at all without direct. Even if
sync writes the cached data to disk, it isn't exactly guaranteed that the
following read will read them back instead of just returning a copy from the
cache.

------
dis-sys
nothing special here, just a 16GB card got marked as 64GB, this kind of scam
has been there for ages. You got hit by dishonest marketing BS from big brands
all the time as well, buying from reliable brand and its recommended
(overpriced) channel doesn't solve the problem, it seem to become the standard
way of doing business in storage (what is the likelihood to get a fake
RAM/CPU/GPU to this extent?). I think that is actually the most scary part.

I was lately trying to buy a new SSD, surely you want a NVMe SSD, so I picked
up the Pro version of this top brand SSD, as the spec is the best of the best
you can find on the market. Did a simple test, fsync performance is actually
worse than the 2 years old SATA SSD from the same brand and that SATA was a
EVO module. Sure, they didn't advertise fsync performance, but do you think it
is fair not to mention/disclose/report such very poor fsync performance when
it is actually slower than their own 2 years old product?

I didn't waste my time to argue with anyone, got it refunded and bought the
EVO version of the NVMe SSD as I thought I just forget about the fsync
performance and save that $100 difference. Got the fancy EVO NVMe SSD, did a
sequential write test, the throughput performance dropped like 40% after
certain amount of writes. Carefully checked the product spec, there is some
text on the box written in some size 2 font basically telling people to expect
such performance drop as there is some cache style design there.

Well, at least I got this very good random IOPS spec, right? Did some tests
myself, guess what? The advertised IOPS performance is only true when running
in situations considered as rare or even abnormal for such consumer grade SSD
- you need a very long IO queue depth. In plain English, if you just buy this
consumer grade SSD and use it in a consumer setting, you are not going to get
the advertised performance.

Fake or marketing BS? If the whole idea is to fool me to pay for their over
stated stuff, then what is the difference?

~~~
ve7cxz
The issue is that with these cards they're not just branded wrong, they often
present themselves as being bigger than they actually are - so your OS sees it
as being 64GB when it's only 16GB, for example.

Were it just a branding thing it wouldn't - from a technical standpoint - be
quite so bad, other than you know, the intentional lying...

------
polote
What is the percentage of SD cards which are not fake ? Are we sure that
popular SD cards on Amazon are not fake ?

~~~
notyourday
I do not know about Amazon but I have some interesting experiences:

Over last several years I have ordered a few hundred SD Cards, some from Ebay
some from Amazon, some bought at the stores. Store cards were Kingston and PNY
branded - bought at Microcenter. Amazon were some unbranded ones and Sandisks.

My method of testing is rather simple - for 64G card generate a file of
63864569856 bytes of random data, dd it onto a card dd result off the card,
fingerprint both. If they match the card is probably good.

This is what I found:

* cards with fake sizes will fail to write entire file with IO error

* cards with questionable quality will happily spew the following into kernel log:

[6135586.258783] sd 7:0:0:2: [sdf] tag#0 CDB: Read(10) 28 00 07 6f 4f 80 00 00
08 00 [6135586.258785] blk_update_request: I/O error, dev sdf, sector
124735360 [6135586.654749] sd 7:0:0:2: [sdf] tag#0 FAILED Result:
hostbyte=DID_ERROR driverbyte=DRIVER_SENSE [6135586.654752] sd 7:0:0:2: [sdf]
tag#0 Sense Key : Hardware Error [current] [6135586.654753] sd 7:0:0:2: [sdf]
tag#0 Add. Sense: No additional sense information [6135586.654755] sd 7:0:0:2:
[sdf] tag#0 CDB: Read(10) 28 00 07 6f 4f 80 00 00 08 00 [6135586.654757]
blk_update_request: I/O error, dev sdf, sector 124735360 [6135586.654760]
Buffer I/O error on dev sdf, logical block 15591920, async page read

* Sandisk had the lowest number of the failures when bought on ebay - sub 10%, highest rate of failures when bought on Amazon - over 90%.

* Kingstons from Micro Center passed the tests.

* PNYs failed the test.

The only wrinkle that I currently have is that I use Sandisks in a dual card
Nikon configured for dual write. So far two of the cards that passed the tests
created a "Card error" reported by the camera on separate occasions with
separate slots. I do not however know if the issue is caused by the the
adapter or by the card. I just ordered a few new adapters to see if I can
isolate it.

[Edit: Formatting]

[Late addition: below]

The cards that triggered an error in camera passed the read/write test after
the error so I am inclined to believe it could be the adapter.

~~~
qb45
> My method of testing is rather simple - for 64G card generate a file of
> 63864569856 bytes of random data, dd it onto a card dd result off the card,
> fingerprint both. If they match the card is probably good.

One optimization:

    
    
      dd bs=1M count=N if=/dev/urandom | tee /dev/mmcblk0 | md5sum
      md5sum /dev/mmcblk0

~~~
notyourday
Ah, I generated a file once and now it is sitting on my disk drive instead of
generating it every time. This also allows me to guarantee that I have the
data that I have written so I can see if there's a specific set of corruption
that happens. That's for example how I found that certain cards do 16GB loop.

------
zeep
I've received some fake ones but they were unbranded... The ones that I
ordered online on Amazon with the whole retail packaging have always been good
so far.

Sounds like something an evil cloud storage company would do to promote the
use of online storage... that and removing SD cards slot from whatever they
can.

------
wingi
Hmmm, some start writingGB17 on the position of the GB1, so your 1MB read/test
will make all green.

------
TazeTSchnitzel
At least for USB flash drives that behave similarly, sometimes there are
software tools that let you configure the drive's claimed capacity.

~~~
jaclaz
Yes and no. In the sense that many "manufacturer tools" for USB sticks (and
controllers) are available (sometimes released by he actual manufacturers,
sometimes released by some "OEM" or "Brands" as a recovery or formatting
software, the most part AFAICT leaked), while there are very few (if any at
all) correspondent tools for SD cards.

Here is a couple known articles by "Bunnie" of BunnieStudios, respectively
2013 and 2009:

[https://www.bunniestudios.com/blog/?p=3554](https://www.bunniestudios.com/blog/?p=3554)

[http://www.bunniestudios.com/blog/?page_id=1022](http://www.bunniestudios.com/blog/?page_id=1022)

