0

I have a USB stick of 16Gb, Verbatim, that is valuable for me as a gift as much as a tool. Lately I had a problem - a file I have carried over on that stick was damaged. So I have run badblocks -wsv on it. I used the default 4 tests.
I have run 4 tests 5 times. On the first run it showed me 3000 errors. On all consecutive runs - 0 errors.
What could have happened? Should I use it now or is it time to put it on the shelf? Actually, I would try to replace the internal board, because I value that item. Could running badblocks have repaired the error?
Badblocks does not use filesystem, so it could not have written information about broken sector somewhere, could it?

3
  • 1
    Assuming it is a standard vfat file system, does fsck.vfat -n /dev/<device> report any errors?
    – FelixJN
    Mar 10 '16 at 21:09
  • It has no filesystem after running badblocks. Do you want me to create a new filesystem and check it immediately? It will be fine, sure. I use exFAT by the way. Mar 11 '16 at 3:11
  • So data loss is no problem in the whole issue? You could wipe the drive without hesitation?
    – FelixJN
    Mar 11 '16 at 10:29
2

The problem is complex as usb flash drives have firmware inside them that translate each of your writes of the same block via an hidden dynamic mapping table into i/o on what could be a completely different internal block number each time due to a wear-levelling architecture. See this lwn article.

In short, there is hope that the internal firmware has noticed that it is getting read errors from some physical parts of the flash memory, and has removed that area from the list of space that can be used. This is first done at manufacturing, and the list of bad areas accumulates with time.

Because of the mapping, several well-separated blocks may actually all be in the same physical flash area, so there may have been only one condemned area.

PS. make sure your drive is always getting enough usb power during writes, eg if it is on a hub, use a powered hub. You can buy cheap inline usb power meters that show you the volts/amps going to a device if you are worried.

1
  • Thanks. I use PC front panels all the time. So, there is some filesystem-agnostic leverage mechanism. That was actually the point I wanted to clarify. Mar 11 '16 at 18:36
1

Unless your flash drive has a very particular issue (like a firmware bug), it is very probable that wear leveling mechanism was trying to prevent errors for as long as it could by balancing the write numbers of all available flash sectors. By the time you get bad blocks on the media, some sectors are over their limit to handle any more writes, while others are on their way to the limit. It is probable you'll get more and more errors over time.

Before a flash sectors becomes totally unusable, it often shows reduced storage times (writing something and reading back immediately works, but reading back in a few weeks fails), so yes, overwriting faulty blocks may seem to "repair" them, but not for long.

It is also possible that faulty sectors were substituted by a reserve, like meuh described. However, the main point still applies: other sectors of your flash driver are most probably on their way to failure.

I would not store any important data on this media anymore, and have the internal board replaced if possible.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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