Technology in terms you understand. Sign up for the Confident Computing newsletter for weekly solutions to make your life easier. Click here and get The Ask Leo! Guide to Staying Safe on the Internet — FREE Edition as my thank you for subscribing!

How do I fix bad sectors on a flash drive?

I have a flash drive and I found that some files on it were
corrupted. When I recopied them from a backup, these files were
corrupted again, sometimes immediately, but sometimes only after a few
days or weeks.

Some folks have suggested I simply “buy a new one”. But I think that
this might be more or less the nature of flash memory, similar to dead
pixels on an LCD display. So I’m thinking that a better way might be to
mark bad clusters and keep using the drive.

I tried “chkdsk /R” and the result is “Windows has checked the file
system and found no problems”. Then I tried the old Windows 98
scandisk, and tried Write/Read test. I know that I shortened the flash
memory’s life by doing this? Again no error was detected.

I filled the disk with files exactly 32768 bytes long – the size of
a FAT cluster on this drive – with random data content. I then checked
the CRC for these files. I also overwrite these files with inverted
data a few times and checked the CRC again. I found a few files where
this failed from time to time, so I changed the attributes of these
files to read-only and hidden. As long as no mechanism moves these
files, this then prevents those bad clusters from being used again.

Is this a reasonable approach?

Let me put it this way: “buy a new one”.

Your approach might be reasonable, sort of, but I don’t agree with
some of the assumptions you’ve made that lead you down this path.

And I can pretty much guarantee that it simply won’t work on many
newer flash drives.

Become a Patron of Ask Leo! and go ad-free!

My biggest disagreement is your statement that it’s the nature of
flash memory to have bad or “weak” spots. The short answer is that if
it does, you should never see it. Most flash memory chips have error
detection and correction built in, using a variety of techniques to
avoid you ever seeing any defects on the device.

Well, that is until the device has so many problems that the error
correction logic simply can’t compensate any more.

What that means is that if you are seeing simple read/write
errors, CRC errors and the like – either from the operating system or
your own tests, then the device is much worse off than you think. In my
opinion you’re on the verge of serious failure and data loss.

“Flash drives aren’t hard drives, and don’t
live, or die, by the same rules.”

Hence: buy a new one.

Unfortunately tools like chkdsk, scandisk and the like are
unreliable when it comes to scanning flash drives for what on a hard
disk would be called a “surface error”. Flash drives aren’t hard
drives, and don’t live, or die, by the same rules.

The technique you outline is a very valid technique when working on
hard disks. In fact, I have to admit I’ve done something very similar
myself in the past. When a disk maintenance utility refused to remove
an obviously bad sector from my hard disk, once I found that it had
been allocated to a file, I renamed and hid the file, so that the bad
sector would never be used for something else later.

But flash memory is different.

As I’ve mentioned before, flash drives wear out. One of the advanced
techniques that flash drive manufacturers now use is called “wear
levelling”. This means that while you or the operating system might
think you’re writing to a specific location on the device, the device
itself is randomly re-mapping the actual physical location. For example,
you might think you’re writing to sector #23 over and over again, but
in order to balance the wear across the entire device to maximize
longevity the flash drive circuitry is moving where, exactly, sector
#23 lives each time you write to it.

That means the file that you think has the bad sector today might
not have it tomorrow – it could show up somewhere else entirely.

A lot depends on exactly how each specific flash drive is
designed as well. Some have wear leveling and some do not. Most have
error correction. Exactly how the error correction might happen, and
how or when errors become visible, will vary a great deal not only on
the specific error, but also on the specific manufacturer and
design.

Your device could fail massively tomorrow. Or, having used your
technique, it might last for years.

I just don’t think you can predict which, or when.

The only data you have is that it does have visible errors,
and that’s probably not good.

Buy a new one.

Subscribe to Confident Computing! Tech problem solving & safety tips & a weekly confidence boost in your inbox every week.

I'll see you there!

10 Reasons Your Computer is Slow

Slow Computer?

Speed up with my special report: 10 Reasons Your Computer is Slow, now updated for Windows 10.

NOW: name your own price! You decide how much to pay -- and yes, that means you can get this report completely free if you so choose. Get your copy now!

12 comments on “How do I fix bad sectors on a flash drive?”

  1. DON’T give up on your Flash Drive if it has corrupted files!

    One thing I’ve found, that may be a factor in disk errors on a Flash Drive, is the type of filesystem being used. Try a more primitive one!

    Some Flash Drives are intolerant of NTFS, so try FAT32 instead. Some may also be intolerant of FAT32, so if even FAT32 doesn’t work, try FAT16 (a.k.a. simply “FAT”) instead. I found that one Flash Drive which regularly corrupted files, abruptly settled down and started behaving perfectly, after I reformatted and went from FAT32 to ordinary FAT. In either/any case, GOOD LUCK! 🙂

    Reply
  2. i think i have a kind of same problem. i can see the flash in the my computer window. i can also see the files in it. but i cant open any of them, copy from or copy to the flash. And also i cant format it. Doing all these i see the CRC check error message. Any ideas?

    Reply
  3. I am facing the quite similar problem with my FlashDrive.
    In my case, whenever I copy any data it gets copied properly. But after sometime, the files get corrupted. Names of the files in the folder gets changed to something random.

    I don’t think its a virus as I have checked that.
    Is it because of bad sectors? Is my problem exactly the same?

    Did you read the article you just commented on? Time to replace it, it’s wearing out.

    – Leo
    04-Dec-2008
    Reply
  4. i hav got the bad sectors prob in ma flash drive…..does any one knows about the free utility to recover it….

    Reply
  5. If like me you don’t want to let go of your flash drive and you know theres bad sectors on there somewhere maybe sourcing where these are specifically and partitioning the drive so the partition with the bad sectors you don’t use, would that work im no techy expert so im asking you guys?

    Reply
  6. High end type probably have wear levelling, but then again they are probably quite reliable being high end. For these, it’s likely the drive will become obsolete due to it’s size long before the drive physically fails. We’re talking here about low end stuff, not so great quality but cheap, and I’m sure that for the guys who produce it wear levelling is the last thing on their mind, but rather how to make it cheaper and reliable enough and get it out on the market ASAP so they can make some bucks before they need to produce a bigger size. So I think the issue is valid, for low end type of sticks that most likely don’t have wear levelling, I’m sure you can mark the bad sectors and use quite safely what’s left. And besides, without theorizing whether it has or not wear levelling, you can just go ahead and mark whatever bad sects you see, and if they keep popping up afterwards it means the stick does have wear levelling and this approach won’t work. On the other hand, if I’m right, it will just work, and you’ll get a reasonably reliable stick.

    Reply
  7. Leo, I don’t pretend to be an expert on the subject, but I read that the newer flash drives no longer “wear out”. I suspect many of the people having these problems actually have “fake” sized flash drives, where you bought a 16 gb drive, but its really a 2 gb drive where its been modified to APPEAR as though its a 16 gb drive. Of course when you try to write 16 gb to it and read it back, only the first couple gb are correct, and the rest appears corrupted. A freeware program called h2wtest 1.4 can be downloaded to test for fake flash drives.

    Now me, being the chap bugger that I am, and having gotten a refund for the 16 gb flashdrive I PAID for, *I* would like to MARK the other 14 gb and USE the 2 gb worth of chip that really is there. I would have been able to do this in the old days by creating files of the block size and then using a utility to identify the bad files, but I can’t find any modern day utility to test and mark the bad areas. Any suggestions?

    The technology behind flash memory still wears out – it’s just getting better and thus lasts longer. But eventually it dies. I’ve never heard of or experienced the “fake” scenario you describe. Might run chkdsk /F /R on it, but if it’s bad, it’s risky to use at all and I’d discard it.

    Leo
    31-Mar-2010

    Reply
  8. I have a 8GB 2.5″ form factor IDE flash disk formatted as FAT32 that has a 2 GB file that is critical to my work. I cannot read past about the 308MB mark with any utility I’ve tried. I need to recover as much data as possible from the rest of the file, but I haven’t found a way to get at any of the rest of the data. In Windows the file transfer freezes when it gets to the 308MB mark and the disk must be forcefully removed before I can access it again at all (I have it mounted using a USB to IDE adapter).I have also tried it in a VxWorks RTOS system and tried transferring the file via FTP. Same result – fails at 308MB. I don’t need the drive, just whatever is left of the data. I tried CHKDSK /r and it froze and never finished. CHKDSK /f said some bad File Allocation Tables detected. I tried creating an image using Acronis True Image 11 and it freezes at the same point, even with “ignore bad sectors” option set. Any other tools that you think might help?

    If it’s a flash drive, then no, I don’t have any ideas. I believe you may be out of luck.

    Leo
    08-Apr-2010

    Reply
  9. I have 128MB LG and 8GB SDOstorage USB flash drives. 128Mb flash drive works perfectly after 4 years usage. 8GB USB flash drive worked perfectly only few months. It seems to me that reliability is depend on storage capacity: the more storage the less reliability? Can a cell phone radiation corrupt files on USB flash drive if both devices are in one pocket.

    Reply
  10. I found the approach of the person asking the question was genious! If I had the patience I would try that myself. My mom gave me a 32gb flash drive that I never been able to use. And I cant return it cause she bought while on a trip 🙁

    Reply

Leave a reply:

Before commenting please:

  • Read the article.
  • Comment on the article.
  • No personal information.
  • No spam.

Comments violating those rules will be removed. Comments that don't add value will be removed, including off-topic or content-free comments, or comments that look even a little bit like spam. All comments containing links and certain keywords will be moderated before publication.

I want comments to be valuable for everyone, including those who come later and take the time to read.