Helping people with computers... one answer at a time.

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.

"The more you write to a flash device the shorter its lifespan will be."

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?

Flash memory wears out.

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.

Article C3296 - February 19, 2008 « »

Share this article with your friends:

Share this article on Facebook Tweet this article Email a link to this article
Leo Leo A. Notenboom has been playing with computers since he was required to take a programming class in 1976. An 18 year career as a programmer at Microsoft soon followed. After "retiring" in 2001, Leo started Ask Leo! in 2003 as a place for answers to common computer and technical questions. More about Leo.

Not what you needed?

26 Comments
David Ball
February 20, 2008 9:24 PM

Hmmmm... makes me wonder how many MacBook Air owners may defrag their new SSD drives, potentially reducing the lifespan of the device. Using Flash for hard drives (Solid State Drives) is still an expensive, limited storage medium that is slowly gaining momentum. As more manufacturers (such as Samsung) throw their weight behind the technology we should see lower prices and increased capacities. The next couple of years could yield some very interesting drives in this arena - low power consumption, fast boot times, and potentially better performance that disk based drives.

Tensor
February 25, 2008 6:41 AM

The magnetic hardrive is a -mechanical- device that is, by orders of magnitude, the slowest* component in a modern PC of which all other components are solid state (CPU, RAM, GFX etc). File fragmentation increases the work that this mechanical device has to do, thereby worsening an existing performance bottleneck. Hence the need for defragmentation. In addition to preserving overall system performance, defragmentation may also improve the life of the drive in the long term, improve chances of file recovery (if the HDD crashes) and a defragmented drive may also reduce battery consumption in laptops. Infact, in the corporate space, unattended intelligent automatic defrag of workstations and servers is becoming the norm since it eases the workload of the IT people yet reduces user complaints of poor performance.

However, as Leo has so precisely explained, flash drives derive none of the benefits of defragmentation that are applicable to mechanical HDDs. So, there is no use defragging your thumb drive or ipod nano.

IMO, even with the rising popularity of SSDs, there is still a long way to go before they can seriously threaten the trusty magnetic-mechanical workhorse in our homes. As of now, the SSDs simply cannot compete on the price to performance ratio for home users.

* Excluding optical drives, that are infact even slower, but are only of peripheral interest (pun unintended) compared to a HDD.

Gramps
February 26, 2008 10:48 PM

"Hmmmm... makes me wonder how many MacBook Air owners may defrag their new SSD drives, potentially reducing the lifespan of the device."

Fortunately for OSX users, fragmentation isn't much of a problem. HFS+ (the standard file system for MAC users) uses a combination of methods to reduce fragmentation.Such as aggressive read ahead and write behind caching, journaling, and delayed allocation. not to say that files don't get fragmented, but there is much less of a performance hit from the few files that do get scattered across the drive.

That being said, great tip. Never, ever, ever defrag a SSD.

Ben
May 7, 2008 6:47 AM

Connie Ramirez -
In the May 1, 2008 edition of Windows Secrets several anti-virus programs were evaluated. The results were obtained from Virus Bulletin's April 2008 edition and tested 37 antivirus solutions. The tests were run on Windows Vista PCs and included a list of viruses known to be circulating in the wilds of the Internet as of January 2008: worms, bots, polymorphic viruses, file infector viruses, and even legacy virus strains.

Five products notched perfect 100% detection rates (prices include one year of virus-signature updates): Avira Antivir Personal (free for noncommercial use), ESET NOD32 ($40), Fortinet FortiClient ($28), Frisk FPROT Antivirus ($29 for up to five PCs), and Symantec Norton Antivirus ($40).

You can install and register free copies of Avira on each of your 4 computers from www.free-av.com. Understand that AV products seem to change rankings with each other depending on latest updates, test authorities, etc. As Leo has said many times, better to use something rather than nothing at all.

http://ask-leo.com/whats_the_best_popup_blocker_antivirus_software_antispyware_software.html

henry cossak
September 1, 2008 1:25 AM

interesting article leo, i totally agree about the wearing out of flash/solid state storage.

But i have been testing numerous SD and micro SD cards and the read/write benchmarks show a noted improvment after a defrag! how can this be explained?

El Bogarto
September 25, 2008 11:26 AM

@ 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.

Paulc
October 5, 2008 8:56 AM

I 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.

Cyclo User
October 13, 2008 3:36 PM

Actually, 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.

In a case like that I would not defrag, and I would not reformat. I would simply copy all the files off, delete all files from the flash drive, and the copy them back. Reformatting isn't needed, and would likely perform more writes to the flash than is necessary.
- Leo
14-Oct-2008

Steve Bukosky
November 6, 2008 12:08 PM

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?

Failure more: I would expect read/write errors of various forms. CRC errors and th like. I'd a) make sure that the flash memory is not the only place you keep that data, and b) when those errors start to occur, dispose of it.
- Leo
07-Nov-2008

Ray
November 21, 2008 1:54 PM

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?

David Masover
November 27, 2008 8:18 PM

Defragging 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.

Couple of things are getting confused here. Defragging, particularly in the scope of this article, has nothing to do with RAM. Nothing. Defragging is all about disks and disk-like devices such as USB flash drives. Thus the FireFox thing mentioned is totally unrelated.

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.

- Leo
28-Nov-2008
Tiffany
December 15, 2008 6:12 PM

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

Ashamed
May 20, 2009 2:22 AM

Another 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.

shawn
September 23, 2009 10:05 PM

im 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

Yes, you are wrong. Flash memory is a VERY different kind of memory than what's in your PC. When you turn off your PC the RAM in your PC loses everything in it. Flash memory retains what's in it when the power is removed. Flash memory wears out the more you write to it, and defragging is a VERY write-intensive operation. (Not to mention that defragging is nearly pointless on memory-based drives.)
Leo
24-Sep-2009

Beau M
November 9, 2009 11:57 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.

MPG
December 3, 2009 3:49 PM

http://operation420.net/forum/viewtopic.php?f=45&t=1129

Great article, may I have permission to post it on my forum instead of just linking to it? I prefer reposting instead of just linking because there are times I posted links to articles that went down.

Unfortunately, no, I can't authorize a complete copy of my article, for several reasons. If you take a look a the terms you'll see that you can publish partial content that links back here. (I understand your concern, but I plan to keep this content up for quite a while Smile).
Leo
05-Dec-2009

Nancy Johnson
January 29, 2010 1:56 AM

I have accidentally deleted some of my important data's from MacBook's USB Flash Drive.Can I get it back using MacBook Data Recovery software, as defragmanet it before the data loss. Please help.

Transatlantic
April 4, 2010 1:39 AM

You might want to explain all this to Microsoft. When you read their help page about fragmentation (Windows Se7en), they mention Flash as being prone to fragmentation and sort of encourage users to defragment them also...

Paul Lopez
April 30, 2010 6:58 AM

Defragging my flash drive makes sense to me..i have a 4GB flash drive which was infected by some viruses..i had no way of recovering my files in it so i decided to reformat it, but to no avail..for some reasons, i cannot reformat my flash drive. I checked it with windows defragmenter,and defragged it..after doing so i easily reformatted my flash drive, and up to now is working very fine for more than 2 years.

Christopher Morton
May 11, 2010 8:01 AM

I purchased a 8gig thumb drive from corsair. I believe it has like 10 year warranty. My goal was to make a mega boot able devices that would launch into several OSes. A Multi-OS on a stick. I came found a good article that would let me do so using Grub4dos. The problem I encountered was that the large ISO files became fragmented and would not boot. So in this case I must defragment the drive many times in order to boot off all the boot able OS ISO files. After which no more write should be done to the USB thumb drive. In this one case I think it is acceptable, and if it does degrade Corsair will mostly likely send me a new one.

Jason Seabolt
January 31, 2012 11:06 AM

Thank you for the article, I was curious to see if there was any reason to or not to defrag a flash drive. I honestly wish I had come across this sooner, LOL. I will remember this for my next flash drive. Keep up the great articles. You have a new fan.

Samuel Yang
February 15, 2012 1:07 PM

This article's points are contradicted by the following pretty persuasive article: http://www.wizcode.com/articles/comments/flash_memory_fragmentation_myths_and_facts/.

JhenRose
April 13, 2012 7:54 PM

Hi!i accidentally defrag my 4gb flash drive, but i cancelled it right away.Then when i try to open it,windows asks to format it. But it fails.All of my files were gone. Is there any way to recover or at least fix my flash drive? Thanks :)

molodets
November 9, 2012 1:02 PM

Think outside the box. While defragging a flash drive may not improve performance, it is not the only reason that someone may be interested in doing it. For example, my DVD player that is connected to my TV, accepts usb flash drives. When playing music, it plays the files in the order that they were written to the flash drive. But I want it to play them in alphanumeric order. Some defraggers, such as Ultimate Defrag by Disk Trix will write files to disk in alphanumeric order. Unfortunately, that program won't defrag a usb flash drive.

FlorineCobb
December 29, 2012 3:47 AM

Different people opine, that is not easy to buy research papers. However, I guess that is easy to determine good custom writing organizations and you need to just seek hard them.

buy dissertation
January 30, 2013 7:26 AM

I appreciate your thought close to this topic. I would like tell that I have not find such kind of master dissertation writer until now. Could you accomplish the very perfect dissertation (topthesis.com) and thesis example?

Comments on this entry are closed.

If you have a question, start by using the search box up at the top of the page - there's a very good chance that your question has already been answered on Ask Leo!.

If you don't find your answer, head out to http://askleo.com/ask to ask your question.