Why can't you defragment Solid State Drives? [duplicate]
I keep hearing that this is a huge no-no. Why is this? I run Ubuntu mostly so it doesn't affect me, but I was just wondering.
Solid state drives are based on flash memory, which age very differently than standard spinning platter-based hard drives. Each sector has a limited number of write cycles, so the drives include wear-leveling features that allows the drive to last longer by essentially fragmenting the drive on purpose.
The read times are not greatly improved by defragmenting as they are in standard drives, so there is no real gain in defragmentation, but by doing so, you are increasing the number of writes to the drive, thereby decreasing the drive life.
Defragmenting puts your sectors near each other which is helpful for a disk that spins around. However, this is useless on an SSD which has constant access time for any sector. Defragmenting just causes extra writes on a disk (SSDs have a limited number of writes due to their design)
Note that there shouldn't be any technical reason for not "being able to defragment a solid state drive", in the sense that you could start a defragmenter program and run it against the drive.
But doing so doesn't have the effect it does on non-solid state drives, as moving the clusters together won't actually speed up the drive.
On the other hand, what you will do is perform lots of unnecessary writes on the drive, and this will shorten, albeit slightly, the life-span of the drive.
Additionally, many solid-state drives does optimizations to lessen this problem by reducing repeated writes to the same area, and this is transparent to the outside system, in which case the clusters might not be moved together at all but instead spread out over the drive. This technique is typically "wear leveling".
If a defragmenter program refuses to defragment a solid state drive (or even just list it as a drive you can select), I'd wager that it's basically a software refusal to do so, just to avoid the problems outlined above.
Note that I don't know enough about the underlying protocols used to defragment a drive, so there might very well be a hard block from a solid state drive to accept defragment commands, if there are such things. The reasons for this, however, are the ones described here.
Defragging will lower the live expectancy of your drive by performing unnecessary passes over a drive with a limited life-span.
It depends on what is on the drive. You will not get any performance increase by defragging an SSD, but it will have an impact on data-recovery.
On the one hand, flash-memory has a limited number of write cycles, so doing a lot of writing will eventually wear it out. Flash drives, memory cards, and SSDs use tricks like wear-leveling and TRIM to extend the life of the media, but defragmentation tends to cause a large number of writes, which will cause it wear out all the faster.
On the other hand, fragmented files are infinitely harder to recover when accidentally deleted, hit by a virus, etc. so keeping your files in a contiguous state (e.g., by defragmenting) will greatly increase the chances of recovery.
Therefore, like I said at the start, it depends on what is stored on the drive, how important the files are, how likely you are to need to perform data-recovery, and how frequently the files are changed (frequent deletions and copies will lead to fragmentation faster as well as eat up more write cycles).