Ask Leo!

How do I fix bad sectors on a flash drive?

Home » Hardware » Disks and Mass Storage

Summary: Once a flash drive starts to show wear by having errors, you shouldn't treat it like a hard disk. You'll be much safer replacing it.

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.

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.

Related:

Article 12396 | Posted May 6, 2008

Recent Comments

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! :)

Posted by: Glenn P. at May 13, 2008 01:36 AM

HP has a fee utility just for formatting flash drives. Worth a shot.

Packrat1947

Posted by: Ronald P. Nosack at May 17, 2008 02:45 PM

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?

Posted by: Nahom at July 23, 2008 03:06 AM

Post a comment on "How do I fix bad sectors on a flash drive?":






(Email Address will not be published.)

Remember Me?

By popular demand...
my tip jar
Cuppa Joe
Buy Leo a Latte!

(you may use HTML tags for style)

New!

RSS feed Subscribe to the RSS Feed specifically for comments on this article.

Before commenting, please...

Please wait. Your comment is being processed ...


Ask Your Question:


ask-leo.com
Web

Stay Informed

Weekly Newsletter

Archives

By Category
By Date

Advertisers

Advertise on Ask Leo!

««   »»

Question? - Ask Leo!
Who is Leo?
Link to Leo!

Terms, Conditions & Privacy