3

I have several sd micro SD cards that have a failed sector or two. But i don't see why i shouldn't be able to make a boot disk out of them. Unfortunately, dd fails when it encounters a bad sector, and ddrescue keeps trying for hours. In the end, I never get a bootable sd card. I want to know, is there any way to make a bootable sd card out of one which has a few failed sectors?

1 Answer 1

4

Once an SD card starts producing errors I believe it is defunct. They generally use a methodology called wear levelling (apparently often via a 32-bit ARM microcontroller) to maximize their lifespan.1

This means the addresses the card exposes are virtual, they do not literally correspond to specific physical blocks; a consequence of wear levelling is that any correspondence is prone to re-arrangement. In other words, block 106 may physically be the right after block 105, but at any point the microcontroller may change that, and this mechanism is independent of whatever computer it is plugged into and the OS accessing it. The addressing is opaque, and dynamic under the hood.

I would think the wear levelling also throws away bad physical addresses internally, but perhaps not (it may not recognize they are bad). If it exposes them:

  • This is a sign of bad things to come, because the wear has been leveled; if one bunch of transistors has failed, there are others that will be close to it.

  • You cannot isolate the physical blocks because the addressing is virtual, dynamic, and opaque.

If it isn't supposed to expose them but you are getting errors, something is even more wrong.


1. It's not required to function, but I think all major brands currently do. On a card that doesn't, you might be able to isolate the actual bad blocks, but I do not think it is a worthwhile pursuit.

4
  • I was able to do it, but yeah I understand why I shouldn't too. Unfortunately Im poor right now, and I have a contract to fulfil using the pi so I must begin Immediately and get piad. Then i can get a new sd card.
    – j0h
    Apr 7, 2015 at 14:03
  • Just so there's no confusion, by "cannot isolate the physical blocks" I did not mean a tool would fail, not find any, etc. If the card is failing you certainly could use badblocks or anything else to check it, and that tool will not know the difference (hence "opaque"). So you could have a tool tell you it has found bad blocks because of write/read discrepancies, but trying to simply avoid those (fake, virtual, i.e. not really physical) addresses won't solve or avoid any problems if wear leveling is in effect. The actual block numbers are fake.
    – goldilocks
    Apr 7, 2015 at 14:13
  • If the wear has got so bad that the wear levelling is failing to "hide" bad sectors then that suggests that the physically "reserved" sectors that are use to replace the failing ones have all been used, that means that you are now "flying without a safety net" and any sectors that the internal system thinks are not up to standard cannot be covered over - that being the case you can expect more data corruption/loss in the near future if you continue to use the card.
    – SlySven
    Dec 18, 2015 at 16:53
  • The other thing to consider is that if this is happening on multiple cards is there something about your system set-up that is causing it. One known issue is that it is not considered a good idea to record "access datetime" data for partitions on devices using Flash memory - the effect of this is that EVERY time you read anything a write is made to the directory metadata recording that read taking place. For *nix systems you want to check that the "options" field for lines in /etc/fstab/ for Flash-memory based partitions (SSD drives, SD cards, & USB thumbdrives) contain noatime.
    – SlySven
    Dec 18, 2015 at 17:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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