Allegro.cc - Online Community

Allegro.cc Forums » Off-Topic Ordeals » Checking the quality of an SD drive

This thread is locked; no one can reply to it. rss feed Print
Checking the quality of an SD drive
Chris Katko
Member #1,881
January 2002
avatar

Linux guys... know a good way to scan an SD card for bad sectors?

AFAIK, blocks are arbitrarily moved around for wear leveling on flash drives and SSD drives (which are more-or-less just flash + maybe some DRAM cache). So if you nuke a block to zeros, and read it back to check it, for all you know, you're reading a different block each time.

I could also try Windows (if such tools work correctly, such as the internal windows format tool) but I have had ZERO LUCK with SD card readers. I've bought at least 5 throughout the years and every one craps out, seizes up, burns up (!) or just plain doesn't work. Meanwhile, every LAPTOP SD card reader I've had has been exemplary and works great.

Well, I've got a Linux laptop, and a Windows PC with a crap SD card reader. So those are my choices. If I HAD to, I could dig up my old work laptop but it takes a day-and-a-half to boot up.

-----sig:
“Programs should be written for people to read, and only incidentally for machines to execute.” - Structure and Interpretation of Computer Programs
"Political Correctness is fascism disguised as manners" --George Carlin

Eric Johnson
Member #14,841
January 2013
avatar

Well, it's like you said, blocks are moved around arbitrarily, so there's no real way to accurately check for "bad sectors". As I understand it, if you do encounter bad sectors on an SD card, it's likely the whole thing is dead, so nothing can be done there. Also, an SD card is more likely to fail when writing than when reading...

That being said, maybe you could try to fill the card to (or near) full capacity, and then compare its contents to a controlled directory of the same contents. For example, if your card is 2GB, then get ~2GB of files together and place them in a directory. Then, get the md5 or sha1 hash of that directory and write it down. Next, format the card and then fill it with the ~2GB of files from the directory. Check the contents of the SD card with md5 or sha1 hash and compare it to the directory's hash. I'm just spitballin' here, but my thinking would be that the hashes should be the same if the files were written correctly; if not, then the card is going bad somewhere. Dunno for sure though. :-X

Chris Katko
Member #1,881
January 2002
avatar

I ended up using DD to making a file just under the filesystem's size, filling it with /dev/random. It didn't have any file system / hardware errors so that should be pretty good unless it's a silent error.

Maybe I'll make a small bash script that actually dumps in chunks of data and verifies them until it fills the medium, and then deletes them back when done. I could do that in an evening.

I've got other SD cards to check yet but the two I had were somewhat obviously "good" and "bad." The good one hadn't had problems ever, and the bad one has been dead on every controller I try to load it on and it never even enumerates to a drive. ... Come to think of it, I should confirm it's not showing up (but not mounting) in dmesg, but I'm 99% sure it's a completely dead card.

[edit]

Any idea how to mount a card that won't mount? Possibly a dead/broken/raw file system?

It won't show up in blkid or fdisk -l. But dmesg shows:

Quote:

[14773.156881] usb 2-7: new high-speed USB device number 18 using xhci_hcd
[14773.301295] usb 2-7: New USB device found, idVendor=05e3, idProduct=0727
[14773.301300] usb 2-7: New USB device strings: Mfr=3, Product=4, SerialNumber=2
[14773.301303] usb 2-7: Product: USB Storage
[14773.301305] usb 2-7: Manufacturer: Generic
[14773.301308] usb 2-7: SerialNumber: 000000000260
[14773.302689] usb-storage 2-7:1.0: USB Mass Storage device detected
[14773.306543] scsi host2: usb-storage 2-7:1.0
[14774.313757] scsi 2:0:0:0: Direct-Access Generic Power Saving USB 0260 PQ: 0 ANSI: 0
[14774.314395] sd 2:0:0:0: Attached scsi generic sg1 type 0

-----sig:
“Programs should be written for people to read, and only incidentally for machines to execute.” - Structure and Interpretation of Computer Programs
"Political Correctness is fascism disguised as manners" --George Carlin

Eric Johnson
Member #14,841
January 2013
avatar

I'm not sure you can mount it if it's dead.

Strange that dmesg shows it as a USB device. Does it show up in lsusb? Also, does anything show up in /media when you insert the card?

Johan Halmén
Member #1,550
September 2001

Someone told me that old Windows software, which searched for bad sectors on hard disks or floppys and disabled them, could work on SD cards, too.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Years of thorough research have revealed that the red "x" that closes a window, really isn't red, but white on red background.

Years of thorough research have revealed that what people find beautiful about the Mandelbrot set is not the set itself, but all the rest.

Go to: