none
Defragment in SSD

    Question

  • Hi,

    On SSDs defragment does not mean.

    What does defragment for SSDs in windows 8.1?just bunch Trim commands?

    Thursday, July 24, 2014 7:45 AM

Answers

  • Windows 8.1 does not normally defragment SSDs, though under some conditions when it makes sense it actually can do so.  What Windows normally does is to re-TRIM an SSD.

    The default settings are good; Windows 8.1 identifies SSDs when it runs WinSAT behind the scenes, and you usually do not need to change anything for best performance and proper drive handling.

    For what it's worth, with most modern SSDs (made in 2013 or later) you really don't have to worry nearly as much about babying it to prevent "write wear" as with older ones from earlier than 2012.  Virtually all internal controllers nowadays do internal wear leveling and you can expect many years operation even under heavy usage.

     

    -Noel


    Detailed how-to in my eBooks:  

    Configure The Windows 7 "To Work" Options
    Configure The Windows 8 "To Work" Options

    • Marked as answer by Arash_89 Friday, July 25, 2014 2:50 PM
    Friday, July 25, 2014 7:36 AM
  • Hi,

    The operating system detects the presence of an SSD and optimizes operation accordingly. For SSD devices Windows 8/8.1 disables defragmentation, SuperFetch and ReadyBoost, the latter two being boot-time and application prefetching operations. It also includes support for the TRIM command to reduce garbage collection for data which the operating system has already determined is no longer valid.


    Kate Li
    TechNet Community Support

    • Marked as answer by Arash_89 Friday, July 25, 2014 2:54 PM
    Friday, July 25, 2014 7:46 AM
    Moderator

All replies

  • Windows 8.1 does not normally defragment SSDs, though under some conditions when it makes sense it actually can do so.  What Windows normally does is to re-TRIM an SSD.

    The default settings are good; Windows 8.1 identifies SSDs when it runs WinSAT behind the scenes, and you usually do not need to change anything for best performance and proper drive handling.

    For what it's worth, with most modern SSDs (made in 2013 or later) you really don't have to worry nearly as much about babying it to prevent "write wear" as with older ones from earlier than 2012.  Virtually all internal controllers nowadays do internal wear leveling and you can expect many years operation even under heavy usage.

     

    -Noel


    Detailed how-to in my eBooks:  

    Configure The Windows 7 "To Work" Options
    Configure The Windows 8 "To Work" Options

    • Marked as answer by Arash_89 Friday, July 25, 2014 2:50 PM
    Friday, July 25, 2014 7:36 AM
  • Hi,

    The operating system detects the presence of an SSD and optimizes operation accordingly. For SSD devices Windows 8/8.1 disables defragmentation, SuperFetch and ReadyBoost, the latter two being boot-time and application prefetching operations. It also includes support for the TRIM command to reduce garbage collection for data which the operating system has already determined is no longer valid.


    Kate Li
    TechNet Community Support

    • Marked as answer by Arash_89 Friday, July 25, 2014 2:54 PM
    Friday, July 25, 2014 7:46 AM
    Moderator
  • Kate, I have been reading very occasional reports that Windows 8 can make the choice to actually defragment an SSD-resident file system when the level of fragmentation reaches very high levels.  Is there anything to that, or is it possibly misinterpretation by some people of what Windows is doing?  Or possibly on some systems the SSD I/O subsystem hasn't (yet) been properly characterized by WinSAT?

    I know I've not seen Windows attempt to defrag my own SSD array on its own.

     

    -Noel


    Detailed how-to in my eBooks:  

    Configure The Windows 7 "To Work" Options
    Configure The Windows 8 "To Work" Options

    Friday, July 25, 2014 9:07 AM
  • Hi Noel. When you say that "Windows 8.1 does not normally defragment SSDs", I guess that you mean if you do it through the Optimize Drivers window; but does this also apply if you run defrag C:/ on the command prompt window? In this case, does Windows 8.1 perform a traditional defrag or optimises the SSD instead - despite having been registered in Event Viewer as a defragmentation?  
    Thursday, August 07, 2014 9:50 PM
  • You can manually request a file system defrag on an SSD, though as I recall you need to force that with a command line switch...

    defrag  C:  /D

    The /D switch specifically requests a "traditional defrag".

    I believe just choosing defrag C: on the command line would still result in a re-trim if the system has judged C: to be an SSD, which seems to go against the documentation you see if you type the command:  defrag /?

     

    -Noel


    Detailed how-to in my eBooks:  

    Configure The Windows 7 "To Work" Options
    Configure The Windows 8 "To Work" Options

    Friday, August 08, 2014 12:29 AM
  • Hi again Noel. Thanks for your quick reply. My laptop is running Windows 8.1 and equipped with a SSD, which has been detected by the OS and is optimised on a weekly basis. By mistake, I run defrag C: on the command prompt window and I just wanted to make sure that a defragmentation was not performed on my SSD. The Event Viewer shows that the Recovery partition has been successfully "defragmented", so I am not sure if a "real" or "traditional" defragmentation just took place; or, actually, the event has been registered as defragmentation (since the defrag command was run) but Windows 8.1 performed TRIM on the SSD. Do you think that defragmentation never occurred? Is there any way to check it out?

    Thanks in advance for your help.

    Friday, August 08, 2014 3:08 PM
  • It's possible an actual defrag occurred, but I can't say for sure.  I once did the same thing and in my case defrag emitted an error.  As a test I then validated that it WOULD do a true file system defrag on defrag /D.

    I wouldn't worry about it.  No harm will have come to your SSD from having done a defrag once, and your system might even run slightly more efficiently for it.

     

    -Noel


    Detailed how-to in my eBooks:  

    Configure The Windows 7 "To Work" Options
    Configure The Windows 8 "To Work" Options

    Friday, August 08, 2014 4:48 PM
  • Many thanks for your answer, Noel. Let me just ask you about one last doubt, please. After running accidentally defrag c:/o /v /u on cmd (the /o parameter chooses the right optimisation for the drive type), the command prompt window disappeared instantly. I checked out straightaway Event Viewer (Windows logs/Application/Event ID 258 - defrag) which showed that the storage optimizer had successfully completed re-trim on c:, while the Recovery partition had been defragmented.

    - How is possible that c: gets trimmed whereas the recovery partition gets defragged if both are in the same SSD?

    - As mentioned above, is it possible that Event Viewer has registered the event as defragmentation (because the defrag command was run) but that actually never happened because Windows 8.1 does not perform defragmentation on SSDs?

    Thanks!!

    Friday, August 08, 2014 8:50 PM
  • I'm sorry to say you'll have to look to Microsoft Engineering for more detail than I've already provided.  My information comes from having read their infrequent forum and blog posts on the subject, and from my own observations.

    As I have mentioned, Windows 8.1 absolutely CAN do a file system defrag on an SSD, if the appropriate command and switches are specified, so I can't say that a defrag could never have happened for you.   I don't know whether there is the possibility for a log entry such as you've seen to be generated another way.

    As mentioned up-thread, I've seen infrequent reports online from folks who claim Windows 8 automatically defragged their SSDs as well, though I haven't seen that behavior.

     

    -Noel


    Detailed how-to in my eBooks:  

    Configure The Windows 7 "To Work" Options
    Configure The Windows 8 "To Work" Options

    Saturday, August 09, 2014 7:41 PM
  • Do you have some links to SSD defrag articles from MSFT? I have been looking into it and have seen something I can't explain yet. When the command defrag c: was run from the command line the c drive had a successful trim in the event viewer and the recovery partition had a successful trim in one event then with the same event time it also had a successful defragmentation event logged. It appears that it is recognized as a SSD because it didn't throw an exception when it sent trim hints but it also said it defeated the same drive. This partition had other optimizer events logged for trim but it did both when running it from the command line.

    Why would it do a defrag and a trim on the same drive when it is a SSD and not to mention a recovery partition that isn't modified so neither should be needed.

    Is it possibly because the image wasn't created correctly by the manufacture so windows can't correctly deal with the partition. I am stumped for now. Does windows look at the recovery partition differentl? Any help figuring this out would help. Maybe it is a bug that it does a defrag on only recovery drives

    Thursday, August 14, 2014 11:34 PM
  • I don't have links handy.  What I remember reading were a few very welcome and revealing inputs from Microsoft folks right here on this forum around the time Win 8 first came out.  I wish I could remember some keywords.  I'll put a few brain cells to work on it, and if I think of any searches that pan out and find the threads I'll post links.

    I don't know if Windows considers the recovery partition differently.  Maybe so - because it's relatively small, or because it has special needs.

    I have developed a couple of thoughts/SWAGs/theories, mostly based on observation and experience...

    1.  I don't think WinSAT necessarily identifies whether the storage on a new system is SSD right away.  It's possible some people see it do the wrong thing, as though the drive is an HDD, then later get it right.  I don't know if the time is hours, days, or what, but it seems to take some time for the OS to "settle in".

    2.  A file system defrag on an SSD isn't bad per se, for the same reasons it's good on an HDD.  It's just that with an SSD the overhead isn't terribly much in absolute terms to access several fragments of a file - but it's still quite a bit more than accessing the file in one big single sequential access.  Thus it's just barely possible Win 8 makes the decision to go ahead and actually defrag an SSD on purpose occasionally.  I don't know.

    Folks focus a lot on the "wear out" factor of SSDs, but the exact same thing applies to HDDs - it's just not quantified as easily.  I know this:  I've worn out a fair number of HDDs in my time, but never an SSD yet.  Have you?

     

    -Noel


    Detailed how-to in my eBooks:  

    Configure The Windows 7 "To Work" Options
    Configure The Windows 8 "To Work" Options

    Friday, August 15, 2014 3:15 AM
  • I don't think that a defrag on an SSD is a bad thing I have seen it take a drive from death to just about new. It isn't something that you should run all the time just like anything too much is bad.The thing I can't get yet is it did a trim and a defrag and they were both at the exact same time. Since it did a trim and it didn't error out the OS knows its an SSD but then it did a defrag. Since nothing should be changing in the recovery drive it shouldn't have needed a defrag and it really just doesn't make sense how it would on a recovery drive.

    Anyhow the bigger question I have and maybe this should be a new thread is how does Windows 8 do a traditional defrag on an SSD. I know the -d flag will force one but since the SSD has wear leveling and it hide the true location of the data from the OS does the defrag not really happen on the data but the mapping for the OS?

    Friday, August 15, 2014 6:17 PM
  • No, I'm quite sure the OS cannot change the internal mapping of flash blocks to LBAs.  I know this for two reasons: 

    1.  SSD makers are very protective of their proprietary internal controller technology and do not expose the nitty gritty of flash block mapping to denizens of the CPU.

    2.  The SATA interface doesn't define commands (to the best of my knowledge) that an OS could use to accomplish such a remapping.  I'm not as sure about this item as number 1 above as it's been a while since I looked in detail at SATA standards.

       

    -Noel


    Detailed how-to in my eBooks:  

    Configure The Windows 7 "To Work" Options
    Configure The Windows 8 "To Work" Options

    Friday, August 15, 2014 7:39 PM