20
\$\begingroup\$

One of my cheap SD cards goes corrupt from time to time and the camera demands it needs to be reformatted.

It's frustrating, but I want to know what might be the reason that makes it go corrupt and why this might be linked to cost. It can hold close to the advertised capacity of 16gb for months sometimes and other times it gets corrupt after a couple of snaps.

\$\endgroup\$
1
  • 1
    \$\begingroup\$ best thing is to use pro line compactflash. If thats not possible, then go for pro line SD cards, like sandisk extreme. you said it yourself "One of my cheap SD cards ". you get what you pay for. cheap usb drives and sd cards cant be expected to last you more than 1-2 times. \$\endgroup\$ Jun 27, 2013 at 22:25

3 Answers 3

26
\$\begingroup\$

There are several ways in which an SD card can go bad.

Physical Damage

First, cards can be actually physically broken. You can bend them in half pretty easily if you try, but in general they're actually pretty resilient. Many are effectively water-proof even if not marketed that way. I've sent cards through the laundry, and once I dropped one full of precious baby photos right into hot coffee — no problem! Now, I wouldn't recommend pushing your luck, but if you're careful, this is unlikely.

Electrostatic discharge could also damage the electronics, although again most cards are surprisingly well-resistant. (Try to intentionally destroy a card with static and your success rate will be low.)

Flash isn't particularly light-sensitive, so airport x-rays aren't a real risk (longer exposure to high-energy x-rays is another story). And magnets aren't a worry either — "A magnet powerful enough to disturb the electrons in flash would be powerful enough to suck the iron out of your blood cells", according to the executive director of the Compact Flash Association.

It's also surprisingly heat-resistant — the plastic housing is probably at more risk than the memory itself.

Filesystem and File Corruption

Physical damage is at the most basic level. At the higher end, you can have corruption and data loss without anything fundamentally going wrong. The firmware in cameras and card readers (that is, the mini-os and software that runs on the device) can make mistakes, or be caught in situations it can't handle.

The most obvious is that you can mess things up if you pull out the card while trying to write to it. Don't do that. (And remember that with caching, that can happen quite a while after you think the data transfer is done.) With SD or Compact Flash cards, it's usually reasonably safe to remove the card from a reader while it's mounted for read access; beware that if you happen to have an xD card device that this is not safe.

A bug could happen in deleting files, or if the card fills up. And, it's theoretically possible that if you format the card on a computer conflicting filesystem bugs will cause issues.

Presuming you avoid the yank-the-card-out scenario, and don't have a hardware failure, these are also pretty rare, because the filesystem implementations used in cameras have been around for a long time and are very well tested.

It's also possible that bad cables, bad USB ports, or problems in the computer itself could corrupt files on transfer. Trying again on another system is always a good first diagnostic.

In all of these cases, the card itself is really fine — reformat and you can use it again.

Bad Blocks

Then, there's the SD card really going corrupt.

This happens in two major ways:

Manufacturing Defects

There's a lot of pressure to produce small, cheap, high-capacity devices. In order to do this, manufacturers have learned to not worry about perfection, and ship devices with something like 2-5% of the memory already bad, right out of the factory. These initial bad blocks are masked out and shouldn't affect anything, but actually do have a long term effect — see below.

And it's possible that a particular card will have a lot more than it's supposed to, including blocks which weren't properly masked out. This is much more likely with cheap cards.

Accumulated Failure

Flash memory inherently has a limited number of write/erase cycles. Inevitably, electrons get trapped where they're not wanted, and the voltage levels shift, eventually causing read or write failure. Any given bit of flash memory is specified for a certain number of cycles before failure, but really it's a random process and there could be a problem long before the numbers would predict on average.

Coping Mechanisms

Because these things are inevitable, SD cards are designed to minimize the damage. In addition to the masking out of bad blocks initially, they detect and mask out new bad blocks as they appear. They're made with excess capacity initially, and as blocks wear out, spare blocks are transparently substituted, so everything keeps working. The flash card's built-in controller will use error correction to prevent the errors from corrupting data as they occur.

But, cheaper cards may have less sophisticated error correction, and are likely to have less spare capacity for covering up for bad blocks.

Flash devices also use wear leveling, so that writes are spread across the whole device, not just always using the same area over and over. Here again, cheap cards may do a worse job of this.

So, Overall...

It's worth it to buy high-quality name-brand cards because of the inherent issues in the last section. Even then, failure is inevitable (like death and taxes), so don't place all of your eggs in the same basket — make sure you have backups. Other than that, the main advice is to be careful when writes are occurring.

\$\endgroup\$
1
  • 2
    \$\begingroup\$ Name brand is the way to go, but beware of counterfeit cards. It's often difficult to tell if you really got a SanDisk, Lexar, etc card. Search for 'sd card counterfeit' - it's not a short list :( This is definitely a case of 'you get what you pay for'. \$\endgroup\$
    – AngerClown
    Jun 28, 2013 at 23:36
4
\$\begingroup\$

Based on your description of the problem, it sounds like the card in question may have a bad block that isn't being masked out by the card's controller. Since most flash cards use some type of wear leveling, the problem will only occur each time the controller attempts to access the bad block. If the card is, for example, an 8GB card that is re-formatted frequently (so that all "good" blocks are generally available for writing on a regular basis), you could expect to experience the problem each time approximately 8GB has been written to the card since the last time the problem occurred. If you leave around 4GB of data permanently written to the card, then you would experience the problem each time another 4GB has been written to the card.

Why does this happen more often with cheap cards?

  • Lower quality control allows cards with more bad blocks through.
  • Cheaper cards often have less sophisticated error correction processes built in.
  • There is less "reserve" memory included on the card to replace bad blocks as they are detected and masked out by the controller.

Note: This is an overly simplified description of how wear leveling works in actual practice, but illustrates the basic concept.

\$\endgroup\$
5
  • \$\begingroup\$ It would be appreciated that any negative vote for an answer be accompanied by an explanation of what information in the answer is incorrect or how the answer could be improved. \$\endgroup\$
    – Michael C
    Jun 29, 2013 at 1:47
  • 1
    \$\begingroup\$ I'm mystified. Maybe someone doesn't get what you are saying with the wrap-around 4GB. \$\endgroup\$
    – mattdm
    Jun 29, 2013 at 13:53
  • \$\begingroup\$ Maybe they wanted more of a why and not what' going on? *shrug* \$\endgroup\$
    – mattdm
    Jun 29, 2013 at 13:54
  • \$\begingroup\$ Formats don't kill the bad sector listing... it's an incorrect answer and hence the downvote. \$\endgroup\$ Jun 29, 2013 at 16:10
  • \$\begingroup\$ This answer doesn't say it does, since the bad sector is not being listed to begin with... \$\endgroup\$
    – Michael C
    Jun 29, 2013 at 17:09
3
\$\begingroup\$

There are generally two reasons for corruption...

The card is faulty.

Cards are so cheap relative to cameras that there is no excuse not to follow the 'if in doubt, throw it out' mantra and then you can replace them with cards that do have a warranty. If cards fail it's normally the 'controller' that fails and it will be completely inaccessible.

The card is having garbage written to it.

In my experience this is way more common and can happen for lots of reasons.

Although not specifically camera related, the 'Raspberry Pi' SoC based educational/hobby computer has a wealth of problems talking to cards, some it likes, some it doesn't and out of 6 cards that I own (which have all been tested with various tools and can be shown to be fine) only one works. That's a roundabout way of saying to check your card is supported by the camera first.

I also have an issue that again 1 card (of the tested batch) has garbage written to it by my camera and it then claims the card is broken. That could be one frame or I could fill the card. I've contacted the manufacturer but because the problem isn't consistently reproducible they've been unable to do anything about it except advise me to format my card (which clears the corruption in just the same way as removing the last file written to the card but doesn't prevent it from occurring again - the whole thing about formatting SD's is FUD put about by people who don't understand the technology.) The card is fine and although I've retired it from the camera it now performs well in another system where it's in use most days and has been for some time without so much as a minor error...

\$\endgroup\$

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