Lost Website

You Are Here

Archive for July, 2010

How you know your SD card is badly broken?

without comments

I’ve recently bought a 16 GB SDHC card from a Hong Kong seller on eBay. You might think that I was looking for trouble not to buy from a brand name card. Yet, the card was half the price of brand names cards and… it might have worked! I got refunded the card pretty quickly by the seller.

The card was properly detected and could be read by the 2 SD card reader I have at home so I initially thought I had made a good deal. Troubles started to happen when I tried read data I had written on it. The filesystem always ended up in pieces. A bad sector check did not report anything bad.

The final verdict on the quality of the card was determined by an interesting experiment I’ve done.  Here is what I tried.

sudo dcfldd if=/dev/zero of=/dev/sdc

dcfldd is an extension to the venerable dd command. It adds, amongst other features, a transfer status output. This is a welcome improvement from the silent nothing that is running dd. If there is anything you need to remember from this post, it is the existence dcfldd command (in the dcfldd package in Debian and Ubuntu).

Once the card is supposedly filled with zeroes, use the same command to read the content:

sudo dcfldd if=/dev/sdc of=BORKED_SD

Then hexdump (hd) the content of BORKED_SD:

00000000  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
6abfea50  00 00 00 3f 00 00 00 00  00 00 00 00 00 00 00 00  |...?............|
6abfea60  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
74a13000  00 22 00 00 00 06 00 00  00 c7 00 00 00 09 00 00  |."..............|
74a13010  00 00 00 00 00 02 00 00  00 00 00 00 00 0c 00 00  |................|
00000000  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
...

Beyond this point, the hexdump data starts to become random.

The hexdump would have only output one line if the card had correctly been filled with zeroes.  The data you see on the next lines should not be there. Either the card returns bad data, or bad data was somehow written on it. You can then understand why the filesystem on the card constantly got corrupted.

Written by François-Denis Gonthier

July 17th, 2010 at 3:38 pm

Posted in Linux,Tips and Tricks

Tagged with , ,