Do SSDs get fragmented, and if they do, is that an issue?

37

9

Do solid-state drives get fragmented? And if they do, does it cause their performance to suffer?

Jader Dias

Posted 2010-01-17T23:40:34.053

Reputation: 13 660

2

@JaderDias The following article provides a nice explanation: http://www.hanselman.com/blog/TheRealAndCompleteStoryDoesWindowsDefragmentYourSSD.aspx

– Simon – 2014-12-05T11:30:10.107

No heads to thrash, so, no suffering. – Fiasco Labs – 2013-08-06T02:06:28.670

Answers

25

Yes, SSDs do get fragmented. Does it impact performance as much as regular hard drives? No.

Fragmentation just refers to the placement of files out of order. It's necessary on all storage devices without having to reshuffle all the data that has ever been written every time you write something.

Marcin

Posted 2010-01-17T23:40:34.053

Reputation: 3 414

4@sblair That information is obsolete. Fragmentation on SSDs does hinder performance because each extent in the file has to be processed by the filesystem, updated when the file is deleted, and so on. The affect is particularly dramatic when file snapshotting and versioning is in use, which is typical on Windows systems. – David Schwartz – 2014-12-09T20:55:12.187

@DavidSchwartz Source? – Aaron Franke – 2018-03-19T02:55:30.350

@AaronFranke I'm not sure what you want a source for. That was a reasoned argument that includes the facts it's based on. SSDs are IOPS limited and fragments increase the IOPS required. – David Schwartz – 2018-03-19T14:15:55.583

12The fragmentation does not really hinder performance because, unlike HDDs, there is no seek-time penalty for SSDs (at least nothing of the same order of magnitude). However, wear-levelling does tend to "consume" free space whenever a file is deleted (so the SSD's performance is reduced unnecessarily); this is where the TRIM command helps. – sblair – 2010-01-18T00:10:01.253

19

Solid-state drives DO NOT require defragmentation. It may decrease the lifespan of the drive. Wear leveling technology purposely "fragments" the data to ensure the consistent life of the drive.

Source: OCZ

Molly7244

Posted 2010-01-17T23:40:34.053

Reputation:

3This information is obsolete. Modern SSDs do not have their lifespan significantly affected by occasional defragmentation, and fragmentation does harm SSD performance. For example, consider the difference in work that must be done when a file with 1,000 extents is deleted compared to a file with a single extent. – David Schwartz – 2014-12-09T20:56:28.517

Don't modern SSDs automatically level out the load across blocks, so that fragment-less file systems will have the same (if not a higher) lifespan than fragment-filled ones? – Aaron Franke – 2018-03-19T02:57:18.843

4This is also true. Since flash memory wears out after so many read/writes (I think mostly writes), it makes sense to spread out the activity throughout the drive. For instance if you have a 64GB SSD and you always find yourself using around 20GB, if it didn't automatically fragment you would end up killing the drive while unfortunately 44GB of the drive is still pristine. – Marcin – 2010-01-17T23:59:10.233

14

“Suffer”? No. Experience? Yes.

Fragmentation is simply when files are written to non-contiguous blocks. This is not a problem with a fresh, clean drive, but after a while, as the drive fills up and files are deleted, new files eventually begin to get written into whatever blocks are available which may not always be big enough for the whole file. There’s really no way around it (short of writing everything once to an empty drive then not writing anything ever again), not even with a better file-system.

However, as sblair pointed out, it’s not actually a problem with SSDs like it is with HDs because there is no head to physically move around the disk to collect data, so there is no performance penalty.

Also, as Marcin and Molly explained, SSDs need to scatter data throughout the whole drive to prevent the beginning of it from getting worn out while the rest of it remains unused. As a result, SSDs purposely fragment data to spread it around the whole drive. Also, you don’t want to defragment SDDs because not only does it defeat the purpose of spreading the data around, but all the extra writes wear it out faster. Robers gave a good explanation about how SSDs are different from traditional spinning disks and that the sectors on an SSD do not reflect the physical layout.


This is yet another benefit of SSDs over spinning HDs: fragmentation is no longer an issue.

SSDs : 5 (less power, less heat, faster, no fragmentation, smaller)
HDs  : 1 (longer lasting)

Caveat:

All this does not however mean that SSDs are the ideal, care-free storage solution. Aside from the fact that they wear out, there is a critical issue to be aware of. While it’s true that SSDs employ wear-leveling and their firmware manages sector mapping, that does not negate the fact that SSDs, like all storage devices that allow modification, do become fragmented which is death when you need to recover lost files.

Using a more tolerant filesystem like NTFS instead of FAT32 helps to some degree, but the fact is that a fragmented file is much harder to recover (if not flat out impossible) than one that is not fragmented. Of course in this case, “fragmented” means from the OS’ point of view irrespective of the physical layout.

Synetech

Posted 2010-01-17T23:40:34.053

Reputation: 63 242

4

The general consensus is that they can fragment, but that it's not necessary to defragment and, worse, it could lead to a shorter drive life. I like Tom's Hardware and their explanation when investigating Diskeeper's SSD defragmentation product.

tcv

Posted 2010-01-17T23:40:34.053

Reputation: 524

3

You actually can suffer reduced performance from fragmentation on SSD. Fragmentation remains a logical problem because the OS/filesystem has to keep track of all the pieces of files, and the pieces of free space. As files shrink and grow and as free space becomes more logically fragmented, over time, I/O operations will naturally become smaller, while the OS/filesystem will naturally consume more CPU overhead to figure out where to put the next piece of data to store, or when reading more overhead to figure out where all the bits of a massive file are.

Basically, IOPS will rise as fragmentation grows. More IOPS generally is bad. Am I wrong?

This may not seem as evident with non-file-based systems like databases that store all their content in a massive blob of disk space (letting the DB manage fragmentation a layer or two up from the filesystem).

However, you can and will suffer from fragmentation even on SSD if you don't do something on some basis to mitigate the long-term effects.

SSD is really freakin amazing, but is not the panacea. Anyone who insists fragmentation is a thing of the past on SSD is most likely selling something.

Tommy Noble

Posted 2010-01-17T23:40:34.053

Reputation: 31

Indeed, looking at a randomly selected SSD benchmark (like https://www.anandtech.com/show/7173/samsung-ssd-840-evo-review-120gb-250gb-500gb-750gb-1tb-models-tested/8) reveals that many SSDs prefer large sequential reads instead of small random reads. You may even come to a point where a framented SSD delivers less performance than a deframented spinning disk.

– Klaws – 2019-12-29T10:41:15.597

1

The reason you suffer from fragmentation, generally, is because the drive head has to move to many different places to access the file. It has to physically move, which takes time. With a solid-state drive (SSD), you'll still experience the fragmentation, but there are no moving parts that have to actually move to the location of the other parts of the file, so you don't encounter the same symptoms (reduced performance).

Also, solid-state drives have a finite number of times that they can be written to. So, defragmenting them may actually reduce the lifespan of the disk while not really giving you the benefit of increased performance like you would experience with a disk that has platters.

Jack

Posted 2010-01-17T23:40:34.053

Reputation: 1 083