Summary: We've all been told that defragmenting a hard disk is a good thing for performance, but the same is most definitely not true for flash drives.
Is it ever necessary to defragment a USB flash drive?
Defragmenting a hard drive makes sense to me because the hard drive read arm has to jump around the disk for fragmented files; but what about flash drives? If all the data is just stored in memory, it seems like accessing those memory addresses won't take any longer, whether they are consecutive or spread in different places. And if it is necessary to defragment a flash drive, then it seems like we could also argue that we need to defragment our RAM from time-to-time!
•
You've hit one nail squarely on the head: flash devices (or any "solid state" devices) don't gain a performance benefit from being defragmented.
But in reality things get worse. Much, much worse.
You should never defragment a flash drive.
•
Files are stored on hard disks in pieces; frequently in 512 byte chunks. Now, there's no requirement that these chunks be next to, or even near each other. That means that a file could have its contents spread out in totally random places on the hard disk. You normally never see this, because the file system takes care of locating all those chunks when you read or write a file.
On a traditional hard disk there's a physical read/write head that moves around on the media when data is being accessed. Much like the laser in a CD player (or the needle on a record player), the disk spins underneath it, while the head moves in and out to locate the proper "track" that contains the next chunk of the file that's being accessed.
Moving that read/write head takes time.
So, if you can ensure that all the chunks of a file are next to each other or "contiguous", the head doesn't need to move as much, and reading the file is faster.
And that's what defragmenting, or "defragging", a hard disk is all about: rearranging where on the disk the file chunks are stored so that when the time comes to access a particular file, all the chunks are together and the read/write head doesn't need to move as much.
Flash drives have no read/write head.
In fact, flash drives have no moving parts at all. Everything that makes it look and act like a hard drive is actually done by mimicking the characteristics of a hard drive in the flash drive's circuitry.
Defragging a flash drive will get you no performance benefits. Since there's no head to move, there's no additional time cost in fetching one chunk of data from a flash drive over any other. It doesn't matter how the files are laid out, it's all just as fast.
So now that I've convinced you that there's no point in defragging a flash drive, why did I say that you should never do it?
Writing to flash memory causes it to degrade ever so slightly. (Reading does not.) The more you write to a flash device the shorter its lifespan will be.
Now, don't get me wrong, "normal" usage should be just fine. And the technology continues to improve almost daily. Not only is the underlying technology improving, but the techniques to mitigate the problem are improving as well. For example, most flash drives try to "spread out" write activity across the entire device, so that even if you're constantly re-writing the same data over and over again, the device will "move it around" so you're not wearing a single spot on the device faster than any other.
But still ... flash memory wears out.
If you're regularly defragging a flash drive, you're adding thousands upon thousands of write operations each time you do so. Whatever the expected lifespan of the device, you could easily be cutting it in half or worse.
For no benefit.
(Full disclosure: OK, a reader did comment on a prior article with a potential benefit - defragmented files are easier for recovery utilities to recover. Fair enough. In my opinion that's not even close to a good enough reason to shorten your flash drive's lifespan. Use a good backup strategy instead.)
So defrag your hard drives every so often. But never defrag your flash drives, there's just no point.
Related:
Can a USB thumbdrive "wear out"? While the technology continues to improve, the fact is that flash memory has a limited number of times it can be written to. It can, in fact, wear out.
What is 'defragging', and why should I do it? Defragging is short for defragmenting which rearranges the layout of files on your hard disk for faster access.
How do I defragment my new hard disk? Defragmenting is a useful bit of maintenance to keep your hard disks speedy. It's not always needed, though. We'll look at when, and how, to defrag.
Article C3296 - February 19, 2008
@ Henry Cossak:
You might be noticing a performance increase in regards to file writes; it's been proven to my personal satisfaction that writing to fragmented free space will be slower than writing to contiguous free space. The bigger the file being written, the bigger the performance impact. No noticable difference in read time, though.
Personally, I defrag my heavily written flash drives once every 6 months or so.
Posted by: El Bogarto at September 25, 2008 11:26 AMI have an ocz 64gb SSD, which when new windows reported as 56GB. everytime I do a diskclean up I lose space not gain it. Last time I checked it I found I had 26GB installed inclunding hidden system file. 56-26 = 30GB of free space, but windows reported it as 20GB. I had lost 10GB over a few weeks. I decided to defrag the drive and got all the space back. Is this a windows or drive problem. Vista 64bit btw.
Posted by: Paulc at October 5, 2008 8:56 AMActually, defragging your flash drive can have some benefit but only if your hardware needs it. For example, the CycloDS and many other MicroSD to DS adapters require the card to be mostly unfragmented to work properly. There is even a debate on the official forums about whether it is best to use a defragmenting program or to simply copy everything off, reformat, and restore everything.
14-Oct-2008
Facinating. I did not know that they can wear out. I thought that they would work until some catastrophic failure, like a static spike or chip failure would render the whole device useless. What are the symptoms? Should they just be disposed of after a certain time?
07-Nov-2008
Leo, I saw your article about flash drives not necessarily needing defragmentation. I have a 750 gig maxtor usb I use for storing my Norton Ghost backups. After doing a backup, my 750 gig shows to be 99% fragmented. Running XP Defrag program takes up to 6 days running continuously. After it has been defragged, it's time of my next weekly backup with norton ghost, and I'm back to square one...it's 99% fragmented again. Is this a problem leaving it this fragmented, or is there a better and faster way to defrag the 750 gig?
Posted by: Ray at November 21, 2008 1:54 PMDefragging isn't entirely about seek time -- many of Firefox's leaks were tracked to memory fragmentation -- as in, RAM.
There's also the issue of space -- it's an extreme, pathological case, but modern filesystems store files in extents. If a file is contiguous, that's one extent -- just the location on the disk, and the file size -- which has to be stored. If it's more fragmented, each fragment is stored as an extent -- which is at least a few extra bytes of space, and very likely some extra time and RAM to access.
For most cases, that's really not going to matter -- certainly, for a little 8 gig thumb drive, the life of the thing is a much bigger concern. But I wouldn't say never defrag, just don't do it weekly like you might with a hard disk.
Also, Ray: A 750 gig external flash drive? Are you sure? Those are absurdly expensive -- I paid $300 extra for a 128 gig internal flash drive. You've probably got a USB hard drive, which absolutely will benefit from not being fragmented.
Similarly the extent thing doesn't really make sense either. Files use no more disk space whether they are fragmented on disk or not.
Finally, I stand by my statement: there is never a reason to defrag a USB flash drive. If, for some reason you want it "defragged" (and I see no real reason to), a) copy the files off the flash drive to a location on your hard drive, b) delete every thing from the flash drive, c) copy the files back. Same results with a lot less flash/disk writing.
28-Nov-2008
I accidentally started to defrag my flash drive, then cancelled. Now I'm having MAJOR problems with certain files. I used to be able to use the files, now I get error messages that the files are corrupted, and such.
My problem is that it's an OLD flash (1.0?) I'm using it on a Win98 computer at work - transfering needed files into a newer computer. It's the only flash I have that will work in this computer.
So...if I copy the files onto the hard drive to where it's empty and paste them back in, do you think this would take care of the problem? Should I reformat or scandisk (or defrag anyway - to let if finish?) the flash before putting files back on it?
I know it wears it out, I just need it to live long enough to transfer all the files out.
(Does anyone know where I can get an older type flash/thumb drive that will work on Win98, first ed.?)
THANKS SO MUCH!!
Posted by: Tiffany at December 15, 2008 6:12 PMAnother reason to avoid it is that it may just stop working! I defragged a flash drive, and now I'm told that it's unformatted! To make matters worse, after I discovered this, I remembered doing exactly same thing and having the same problem a couple of years ago. Alas, life's tough when you're thick.
Posted by: Ashamed at May 20, 2009 2:22 AMim not understanding as to why defraging is so bad for the flash drives..these flash drives,they contail the same memory chips as our pc memory itself uses..and pc memory never goes bad..unless you put it in backwards or somehow manage to fry it lol..in a way it makes sense,,but on the other side..memory is memory ..weather its being written to or used in I/O cycles..just a thought i had in my head...i could be wrong lol
24-Sep-2009
Posted by: shawn at September 23, 2009 10:05 PM
Defragging flash media DOES reduce its life-span, however, your reasons are slightly off. The life-span of flash drives are NOT reduced by writing to the drive. Flash memory uses a phenomenon (known as Fowler-Nordheim tunneling) to send electrons through a floating gate transistor where it remains even after power is turned off. This process does not "wear out" the media. Flash memory gets its name from the technique used to erase its data. To write data, an electric charge is sent through one transistor, called the floating gate, then through a metal oxide layer, and into a second transistor called the control gate where the charge is stored in a cell until it's erased. To reset all values, a strong electrical field, called a (yep, you guessed it) "flash", is applied to the entire card. Flash drives have two limitations: The bits can be erased only by applying the flash to a large block of memory and, with each ERASURE (not write), the block becomes less stable. In time (after 10,000 to 1,000,000 uses) a flash memory device will no longer reliably store data.
Posted by: Beau M at November 9, 2009 11:57 PM