Home > General > Scheduled Defrag in Windows 2008 R2 disabled by default

Scheduled Defrag in Windows 2008 R2 disabled by default

November 17th, 2012 Leave a comment Go to comments

I was at a customer yesterday and got a tip about the defragmentation in Windows 2008 R2. It came up when we where discussing about the SCOM and an alarm in Operations Manager regarding fragmentation on monitored volumes.

I thought that it was doing things automatically but the scheduled task that is responsible for the defragmentation is disabled by default. Now there is different best practices regarding if you should be defragmenting the volumes if it is virtual machines residing on a SAN. If you have physical servers with local drives I would definitely say that you should be doing defragmentation.

So how do you see if your defragmentation task is enabled or not?

Open the Task Scheduler from Administrative Tools and go to Defrag

Then if you check the properties by changing to triggers on the scheduledDefrag task and look, you will see that it is disabled by default, double click on task and you can edit it.

You can then press the edit button and enable the task

Then your task is enabled and on every wednesday at 01:00 the defrag task will be running. As I wrote above, enabling this in a virtualized environment with 100+ VM´s can impact on your storage system quite seriously if all VM´s start to defrag at the same time. One way to mitigate this is to set the start day and start time different on all machines.

Categories: General Tags:
  1. Per Sjökvist
    November 24th, 2012 at 21:04 | #1

    Yes. that is a annoying one.

    Here is a simple script I’m using in my test labs during deployment of server 2012 to get rid of that.
    Of course it could also be used in a Orchestrator runbook for auto remediation when Scom triggers the alert.

    $hour = Get-Random -Minimum 0 -Maximum 24
    $day = Get-Random -input “Monday”, “Tuesday”, “Wednesday”, “Thursday”, “Friday”, “Saturday”, “Sunday”
    $date = Get-Date
    $at = Get-Date “$($a.Month)/$($a.day)/$($a.Year) $($hour):00″

    $Trigger = New-ScheduledTaskTrigger -Weekly -at $at -DaysOfWeek $day

    Set-ScheduledTask -TaskName ScheduledDefrag -TaskPath \Microsoft\Windows\Defrag\ -Trigger $Trigger | Out-Null

  2. Don Smith
    August 14th, 2013 at 20:00 | #2

    @Per Sjökvist

    Hello Per,

    I am trying to achieve this exact thing.

    I am trying to write an Orchestrator runbook to run when SCOM generates a defrag alert.

    Any tips on the easiest way to accomplish this?
    Thanks!
    Don

  1. No trackbacks yet.