What does "Optimize Drives" do in Windows 8?

88

19

With Windows 8, there is an option to "optimize" a drive. This looks similar to the Defragment option of previous versions of Windows:

Screenshot

I have an SSD and I know that SSDs shouldn't be defragmented. However, Windows 8 recognizes that the drive is an SSD, and still says it needs optimization. What exactly does the "Optimize" option do in Windows 8? Is it safe for SSDs?

Ry-

Posted 2012-09-25T03:02:03.910

Reputation: 2 116

2I made some major changes to the question to help prevent it being closed. I believe that this is a valid question and worthy of answering, as I'm interested in what this does as well. If you disagree with the edits feel free to roll-back, change, or ping me with any questions. – James Mertz – 2012-09-25T15:35:38.127

Answers

78

What this does is run the Trim command on the drive (if it supports it). It does not actually defrag the drive, as is the case with a traditional rotating drive. It is probably a good idea to execute Trim to wipe blocks which are no longer in use.

The Windows Assessment Tool (winsat) is what initially determines whether or not the drive is an SSD and switches the behavior of Disk Optimizer. Under Windows 8, winsat runs under the Microsoft\Windows\Maintenance schedule in the Task Scheduler. This is the same tool (winsat) that would disable defragmentation of SSDs on Windows 7.

Just to re-iterate the point and drive it home: Do not think of Disk Optimizer under Windows 8 strictly as Defrag; it is now a general purpose tool that performs the appropriate disk optimization task based on the type of disk which is attached. The identification of disk type is based on winsat.

Official response to a similar question at answers.microsoft.com

Kiran Bangalore [MSFT] -

Hello, In Windows 7 - we turned off defrag for SSDs as you mention in your entry; but in Windows 8, we have changed the defrag tool to do a general optimization tool that handles different kinds of storage, and in the case of SSD's it will send 'trim' hints for the entire volume;

SSDs are storage devices made of flash memory; flash memory unlike hard disks are block erasable devices - they can be written to at a byte level but need to erased at a block level; Trim is a storage level hint that was introduced in the Windows 7 days to indicate that Windows is not using certain regions of the storage device; NTFS will send these trim hints when files are deleted or moved from those regions; SSDs consume these hints to perform a cleanup in the background called as 'reclaim' that helps them get ready for next writes. The SSD may choose to perform the optimization immediately, store the information for later optimization or throw away the hint completely and not use it for optimization since it does not have time to perform this optimization immediately.

In Windows 8, when the Storage Optimizer (the new defrag tool) detects that the volume is mounted on an SSD - it sends a complete set of trim hints for the entire volume again - this is done at idle time and helps to allow for SSDs that were unable to cleanup earlier - a chance to react to these hints and cleanup and optimizer for the best performance. We do not do a traditional defrag (moving files to optimizer there location for space and performance) on SSDs.

Thank you for your question and I hope this clarifies the need to run the Storage Optimizer on a regular basis.

Art

Posted 2012-09-25T03:02:03.910

Reputation: 1 357

3Could you maybe add more detail about what exactly "optimize" drive does beyond what it does for SSDs? – James Mertz – 2012-09-25T17:25:31.113

@KronoS I updated the answer with the original quote. On SSD's it issues a TRIM for the enitre volume, for HDD's it does a good ole' fashioned defrag. – Scott Chamberlain – 2012-09-25T21:15:24.700

There are more defrag options in W8, no offical documentation so far....http://www.eightforums.com/windows-8-news/3316-new-defrag-options-windows-8-a.html

– Moab – 2012-09-25T21:17:43.170

Is it normal for this to take a long time (10+ mins) and for the machine to slow to a crawl while it's happening? My laptop has an SSD (and Win8 has recognized this) and when the drive optimizer ran recently, the system was unusable while it ran. Can it really have that much TRIM work to do, particularly since Windows apparently sends trim commands as it works. – Ian Griffiths – 2013-06-14T07:11:51.140

@IanGriffiths, I would say this is highly unusual. On the systems where I have run it or scheduled it to run, it completes pretty quickly and I do not notice any usuability with the drive. I would perhaps take a look at the SSD manufacturer's site to see if they have a firmware update for your drive. Also, it is possible that Windows may not have recogniced the drive as an SSD and be performing an actual defragment operation (which would explain your speed issue). – Art – 2013-06-14T13:08:02.787

@Art like I said, it has recognized the drive. (It reports the drive as being solid state in the optimization UI.) I'll check out the firmware, but the root cause appeared to be that Windows was doing phenomenal volumes of IO. (The computer wasn't totally locked up, and I was able to see IO throughput in the Resource Monitor, and it seemed to be hammering the drive. It looked pretty much like you'd expect it took if Windows was erroneously attempting to defrag an SSD - furiously reading and writing lots of data.) The optimizer reported "consolidating" throughout this process. – Ian Griffiths – 2013-06-14T17:06:00.757

Windows 8/8.1 actually runs full defrag for SSD. See: http://www.outsidethebox.ms/why-windows-8-defragments-your-ssd-and-how-you-can-avoid-this/

– Alex – 2013-11-25T08:10:51.883

3

Optimize Drives in Windows 8, previously called Disk Defragmenter, helps to optimize the different types of drives that PCs use today. No matter which type of drive your PC uses, Windows automatically chooses the optimization that’s right for your drive.

Whilst traditional defragmentation of SSDs is not required, optimisation of SSDs is definitely required — SSDs do slow down due to file and free space fragmentation.

Condusiv Technologies have a short video called “Forum Post Response: SSDs and Defrag”, which should provide a clearer picture.

Simon

Posted 2012-09-25T03:02:03.910

Reputation: 4 193

So is this like a late, less-useful copy of the top answer? – Ry- – 2013-01-02T18:57:36.243

@minitech When you say late - I was unaware it was a race. It was in the list of top questions 7 hrs ago, and I wasnt trying to compete with the top answer. The 2nd paragraph somes it up – Simon – 2013-01-02T20:41:52.197

No, it's not a race, it's just that answers at similar times sometimes have similar content. In this case, a bit of a silly styling issue on the mobile version of this site made it look like your answer was copied and pasted from the first one. It's not, sorry! :D If you'd make some sort of small edit, I'll change my vote. – Ry- – 2013-01-02T22:45:54.510

@minitech No problem, what edit do you suggest – Simon – 2013-01-03T09:44:24.583

Make the link inline, I suppose? :) [This short video](http://www.youtube.com/watch?v=hznCSqb4Mzg)? – Ry- – 2013-01-04T00:02:18.537

@minitech Done :) – Simon – 2013-01-04T16:57:17.113

2

Here is another answer for your reference, it's simply the re-branded version of what Windows defrag was used to be called. In Windows 8 it's now called Optimize Drives

Jonathan

Posted 2012-09-25T03:02:03.910

Reputation: 1 857

2

Just an addition to the Art's answer. Windows 8 should optimize an SSD by sending TRIM command, but actually it performs a defrag. Here is a part of Application log:

Get-EventLog -LogName Application -Source "microsoft-windows-defrag" | sort timegenerated -desc | fl timegenerated, message

TimeGenerated : 03.10.2013 14:42:54 Message : The storage optimiser successfully completed re-trim on (C:)

TimeGenerated : 03.10.2013 14:42:54 Message : The storage optimiser successfully completed defragmentation on (C:)

TimeGenerated : 03.10.2013 14:26:24 Message : The storage optimiser successfully completed re-trim on System Reserved

TimeGenerated : 03.10.2013 14:26:24 Message : The storage optimiser successfully completed defragmentation on System Reserved

The only drive in notebook is SSD.

So, currently there is a bug in Windows 8 which causes periodical SSD defragmentation.

Alex Cardenas

Posted 2012-09-25T03:02:03.910

Reputation: 29

7Just because it says "defragmentation" doesn't mean that it actually did. The time stamps are in the same second, which seems to me that it just calls the TRIM command "defragmentation", and it never ran a true defrag for HDDs. – Slurpee – 2014-04-16T02:43:45.727