Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

What happen if an SDHC card gets a write error (damaged cell / bad sector)?

Will the whole card be unusable (to trash, all data written to that sector now and in future will be lost)? Or rewrite sector (flash memory get corrupted when writing so maybe have any function to check if sector was written successfully) to another and mark as fault as unusable what will be seen as reduction of capacity but no data lost.

I have to do some research about SD cards on disk-less machines.

share|improve this question
add comment

2 Answers

The way NAND flash works is by providing a number of "eraseblocks" - each "eraseblock" has a number of "pages." Typically, you are looking at 128 Kbyte eraseblocks divided into 64 2 Kbyte pages. Each page can be written to, changing bits from 1 to 0. If you want to change any bits back from 0 to 1, you have to issue an erase command to the whole eraseblock which resets all bits to 1 (unless the block is worn).

Writing isn't perfect and some bits may fail to change from 1 to 0, or flip by themselves.

There is also an "out of band area", or an extra page, per eraseblock. There, ECC codes can be written, and that is what is used for SLC flash. For MLC flash, they use BCH codes which can recover more bits.

Internally this is how things work. SD cards do not provide raw NAND access but go through an internal microcontroller which is responsible for wear leveling and all that good stuff. The host device never sees the raw NAND, but only a block device. But SD does use ECC or BCH AFAIK.

share|improve this answer
add comment

In general, SD cards run with a FAT filesystem. This will detect and mark/flag bad sectors so end result is data is not lost but the amount of available space on the card is reduced slightly. It's not perfect, of course. Some newer cards have error correction code built in (ECC) that does a similar job at a lower level, so in theory should make it even less likely to lose info being written to a card. It's still possible, just less likely.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.