LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware
User Name
Password
Linux - Hardware This forum is for Hardware issues.
Having trouble installing a piece of hardware? Want to know if that peripheral is compatible with Linux?

Notices

Reply
 
Search this Thread
Old 08-30-2009, 06:02 PM   #1
bobwall
Member
 
Registered: Jul 2004
Location: Milpitas, California
Distribution: 1/2 Debian 1/2 my own
Posts: 189

Rep: Reputation: 30
32Gb SDHC with bad sectors


I recently bought a generic 32Gb card on
Ebay and got what I paid for - a bunch of bad sectors which makes my recorded videos unplayable when it reaches a bad frame.

The actual fraction of bad blocks is pretty low ~ 0.001, but I can't get format to recognize them as bad. I tried using the badblocks program to detect them:

badblocks -b 512 -v -w /dev/mmcblk0p1 4296000 4096000
Checking for bad blocks in read-write mode
From block 4096000 to 4296000
Testing with pattern 0xaa: done
Reading and comparing: 4169376
4169377
4169378
4169379
...

After running the test twice on the same range of 200k 512byte blocks, I get about ~167 bad blocks, but the problem is that the block #s are different due to wear leveling, so I don't think the blocks can be marked bad at the file system level. The persistent # bad blocks suggests the card doesn't remap bad blocks, which would be a real bummer.

Is there anything I can do about them, or am I out of luck? Namely, does anyone know the details of wear leveling, so I can mark all logical sectors that can map to a bad physical block as bad?

Last edited by bobwall; 08-30-2009 at 06:15 PM.
 
Old 08-31-2009, 11:39 AM   #2
htnakirs
Member
 
Registered: Mar 2007
Posts: 239

Rep: Reputation: 34
Wear levelling is new to me.

For normal hard disks, I usually create a partition comprising the bad sectors, and use the rest.

If the camera can manage multiple partitions, try creating a hidden partition containing the bad sectors.
 
Old 08-31-2009, 12:04 PM   #3
tredegar
Guru
 
Registered: May 2003
Location: London, UK
Distribution: Ubuntu 10.04, mostly
Posts: 6,007

Rep: Reputation: 367Reputation: 367Reputation: 367Reputation: 367
"Wear levelling" is probably handled differently by different chip manufacturers, and they are unlikely to publish or share their methods, as this would be sensitive commercial information.

Also, levelling is hidden from the hardware interface - the device itself re-maps blocks somehow, and I don't even know if it does this with hard, firm- or software. Without an electron microscope and an unreasonable amount of work, I am not going to be able to know.

So, I think your device is basically broken. Sorry for the bad news.
 
Old 09-01-2009, 03:12 AM   #4
chuckie
LQ Newbie
 
Registered: Jul 2009
Location: Blm. IL. USA
Distribution: slackware
Posts: 13

Rep: Reputation: 0
Maybe you could try to reformat the card using the option to check for and mark bad sectors.
 
Old 09-01-2009, 03:32 AM   #5
bobwall
Member
 
Registered: Jul 2004
Location: Milpitas, California
Distribution: 1/2 Debian 1/2 my own
Posts: 189

Original Poster
Rep: Reputation: 30
Surprisingly, the 1st 2Gb of space has virtually no bad sectors. Maybe this "quality control" helps unsuspecting customers from noticing corrupt images and from totally ruining the company's reputation.

A full format doesn't detect any bad sectors. I think this is because the format just writes 0s to every sector and expects the drive to report an error if it doesn't succeed. I don't know if flash storage is supposed to report errors to the software - maybe it never does because it masks write errors and remaps the block silently.

Either way, I'm quite convinced this SD card doesn't do bad block remapping nor raise errors. Meanwhile, I've written a tool (attached) to test the sectors by doing a write/read for each free FAT32 cluster and marking them bad if the read back is wrong. I've found a region becomes practically error free after ~4% - ~20% of the clusters have been marked bad. Based on the program execution, it seems a physical block is usually remapped within ~32M of some logical position and only at certain alignments. It's not as clear as a set associative cache, but there definitely is a pattern. An estimate for # logical locations a physical sector can map to is 20% / .001 = ~200.

Quote:
try creating a hidden partition containing the bad sectors.
I don't think that's practical. It's similar to my method, but it only works well when the bad blocks are tightly clustered, which isn't true in my case, hence it would waste a lot of space.
Attached Files
File Type: txt mark_bad.cpp.txt (6.9 KB, 8 views)

Last edited by bobwall; 09-01-2009 at 03:56 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Bad sectors, what to do with them? SuperDude123 Linux - Hardware 4 02-15-2009 07:36 PM
Checking for Bad sectors rotty Linux - Hardware 2 09-28-2006 11:34 PM
Bad sectors tuxombie Linux - Hardware 3 01-29-2005 01:05 PM
searching 4 bad sectors zeky Linux - Software 1 12-12-2002 08:49 AM
Bad sectors blystovski Linux - Software 1 10-17-2001 12:18 PM


All times are GMT -5. The time now is 07:00 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration