Should I defrag my SSD?

The answer is: “Yes!” and “No, never!” or somewhere between.

SSD disks has overcome the physical limitations of traditional harddisks. It is actually not a harddisk any more because it doesn’t have a disk. Traditionally when you access a fragmented file the data is scattered around on the disk so the read heads has to move around on a magnetic surface to read the whole file. With SSD this is no longer a problem as the data is stored in NVRAM (think “USB Pen”). This is one of the most significant advantages of the SSD drives. So fragmented files can be read nearly just a fast as defragmented files.

However the NTFS file system does some interesting things.

All hail NTFS, it was a very good file system at a very early time. Others have only started to catch up recently. Though there are some really good alternatives, none (afaik) has all the capabilities that NTFS has.

NTFS keeps track of all allocated and free space on the partition. When storing a file a certain amount of blocks are allocated. If the file size is only one block size it is actually just stored directly in the MFT. But if the file requires multiple blocks then free blocks are located and used. NTFS tries to find areas with many free blocks to prevent fragmentation. Despite this conditions such as high fragmentation (only small sequences of blocks available/low on space) and simultaneous writing to the disk may lead to fragmentation. Most of the time Windows don’t know how big the file you will be writing is and therefore can’t reserve the space. Other files can then be written in between causing fragmentation.

So when the time it takes to read a fragmented file isn’t an issue, how can fragmentation be an issue? One great feature in NTFS is that it will store allocated and free data as chunks. Traditional file systems like for instance FAT32 has a 1-1 mapping of file allocation and data block. NTFS does this way smarter by storing sequences. Instead of storing “FILE 100 is allocated to blocks 10,11,12,31,32,33” it stores “FILE 100 is allocated to blocks 10-12,31-33”. For a defragmented file it only needs one allocation sequence, while for a fragmented file it will need many.

The end result is that a defragmented drive will keep the MFT (NTFS file table) smaller so less memory is consumed, more of the (frequently used MFT) can be cached in memory and less CPU is required for processing a file.

Now the problem is that SSD drives has a limited number of writes for each block. Defragmenting the disk regularly will use all the available writes pretty quickly.

My recommendation is to defragment the SSD disk very rarely. You want to keep the files you never write to defragmented, and keep free sequential space to write files in. Defragmentation programs that can leave defragmented files and only worry about the fragmented ones is a good alternative. Defrag that comes with Windows will do fine.

3 thoughts on “Should I defrag my SSD?”

  1. Tedd, you should check out how SSDs work:

    They have an extra translation/virtualization layer below what the OS can see, this is how they avoid wearing out the root directory/master file allocation tables etc.

    It is still true that an unfragmented drive will save OS allocation entries, but performance wise it really doesn’t matter.


    • Reading up on SSD internals is high on the todo-list. I know about the abstraction to spread writes, but my point was memory (cache) and CPU saved in having a smaller MFT. But I should probably specify that I wouldn’t defragment it more than really <em>really</em> rarely. The optimization benefit with a small SSD drive is minimal, but as they grow it can be more beneficial. Unsure if it is worth it though. Too many other points to optimize before worrying about a few CPU cycles in the kernel. 🙂

      • Hi, you should not defrag it.
        Even though older SSD’s do degrade performance, you have a limited amount of cycles you can write.

        The newer SSD’s have TRIM to fix the issue regarding the degrading performance.

        I’d say:
        Disable search indexing
        Disable defragmentation
        This will affect the lifespan of your drive.

        AFAIK, there is no TRIM support while using SSD in raid.
        There will be released a lot of nice SSD’s this spring/summer… (veeeery fast ones and (slightly more) affordable storage!)

        PS. I’ve browsed your blog a bit and you are covering a lot of interesting stuff.

        Hilsen en fra Bergen 🙂

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: