none
HOWTO: Defrag all disks

    Question

  • Just a bit of useless info to help people schedule a defrag on all disks in their systems without buying any tools.

     

    1. Log onto the server via RDP

    2. Create a batch file and save where ever you like.

    3. Edit the batch file and put these lines in it.

     

    @echo off

    c:\windows\system32\defrag.exe C: /v /f

    c:\windows\system32\defrag.exe D: /v /f

    for /d %%i in (c:\fs\*.*) do c:\windows\system32\defrag.exe %%i /v /f

     

    4. Create a scheduled task via control panel using the batch file as the task, schedule as you like. Once a week should be enough I think or once a month.

    5. Test the task.....

     

     

    Notes:

    1. I was able to play mp3s and picture slideshow on Vista MCE without any real performance issues, haven't tested dvd's yet. Balancing was using more CPU time than the defrag.

    2. If you do not want to schedule it, install the Program Launcher Addin and start it via the console when you like.

    3. It can take a very long time to complete each disk, especially if they are full.

    4. If you are going to use this for command outside the batch file, make sure %%i = %i

    5. /v = Verbose output

    6. /f = force defrag even is disk is full

    7. With the /a (analyse) switch you could add logging and also schedule the defrag to only happen with more than say 10% fragmentation. Perhaps I will post this later.

     

    Hope that is useful

     

    Cheers

    DB

    Tuesday, October 23, 2007 2:44 AM

All replies

  • I didn't think that you were meant to use the built in disk defragmenter that came with Windows 2003? I think I read somewhere that it could break the DE technology. There are programs (Diskeeper and Perfect Disk) that do this but you will have to buy them.
    Tuesday, October 23, 2007 10:09 AM
  • The Microsoft documentation states that all tools within the Disk Management section of WHS must not be used, as these will cause problems. They were the ones that also said that we should wait for the 3rd Party tools that will be available.

     

    Colin

    Tuesday, October 23, 2007 5:33 PM
  • Well I have been defraging and using my homeserver for a week now and no problems yet. I will keep you posted.

     

    I did look into diskeeper, but really it is just doing the same thing as defrag.exe perhaps better, perhaps not. It does have VSS features and recognises all the disks whereever they are mounted.

     

    I think the problem with defrag is you have to use the volume names and not the drive letter, and you have to access it from storage management section which is a no go for your average Joe Public with a store brought server. This puts it outside the realm of normal home server use as it can not be accessed from the console and the windows gui version can only see C and D drive.

     

    Also one of my disks had 15000 files and 8000 of them had fragments.

     

    Any MVP's got an opinion?

     

    Cheers

    DB

     

    Tuesday, October 23, 2007 7:03 PM
  • As stupid as this might sound, I am not adverse to spending some cash to buy DiskKeeper to ensure that my valuable pictures/video, etc. do not get destroyed. If MS recommends against using the built-in defrag and makes it difficult for the average user to circumvent, that I for one am not going to argue over a few bucks to ensure the safety of that data!

     

    I think some thing are better left not tried, and this is one of them.

     

    .02

     

    Erik

    Tuesday, October 23, 2007 7:45 PM
  • But that is not the issue, MS are not making it hard for (IT) users to access these tools. They are in the same location and perform the same functions as with the original 2003 server release.

     

    In the console they are not options or available, that is the only place that you could argue they are restricted...but more than likely they just did not have time to add basic maintenance schedules for them as in Vista where defrag is set to run at 3.00am automatically.

     

    It is not about saving money, I will buy what software I need, but I would first also way up the pros and cons of that software and diskeeper to me when I have used it on older systems had a mind of it's own and what you might gain in disk performance is quickly eaten up by the diskeeper services anyway. But times might have changed.

     

    Cheers

    DB

     

    Tuesday, October 23, 2007 7:57 PM
  • Mcebrowned,

    I have the same set up like yours on my client pc's to auto defrag then during the night time. Saves me time from doing it mannually.

    But, there are plenty of posts here that say one should not use the built in defrag tools on WHS.  Since WHS runs on top of Server 2003 things aren't exactly the same.

    Now, I've run defrag myself on WHS many times.   There are some files that just won't defrag. No biggie.  BUT, I have had WHS CTP crash from defraging and I had to do a reinstall!  Twice!  Ouch!  RC1 and my OEM have survived a defrag just fine.  Honestly, I think the WHS team has a point when they say not to use the built in defrag. So, with my OEM I bought the software so I don't have any issues

    But hey, why not experiment and have some fun. If it works....roll with it. If not....you've been warned...
    Thursday, October 25, 2007 11:26 AM
  •  

    I am in the middle of testing....but so far

     

    I have run defrag in a repeating batch file looping all disks since I made the post.

    The server has 901GB of files duplicatedover 9 disks.

     

    16GB of new files have been added.

    Backups are running on 3 PC's every night.

    Videos have been streamed to MCE.

    Music Streamed to MCE.

    New AV software installed on the server last night and defrag stopped and restarted in between that.

     

    No Problems so far.

     

    One disk went from 77000+ files, of which 41000+ files had fragments. Now only about 100 have fragments.

     

    I will keep you all updated.

     

    Cheers

    DB

     

    Thursday, October 25, 2007 7:04 PM
  • Another report.

     

    Complete Defrag done Monday morning. No problems. All 9 disks completed in half a day compared to 3 days for first defrag to complete.

     

    This weeks server events

    5am restart Monday morning as scheduled.

    12GB files added.

    8GB files removed.

    7 days x 3 computer backups.

    Music streamed over the weekend.

    DVD streamed over the weekend.

    AV software completed scan.

     

    No problems to report.

    Cheers

    DB

    Monday, October 29, 2007 8:42 PM
  •  

    I am getting conflicting reports about using or not using defrag on WHS.
    Someone on the WHS team said "There should not be any issue using Windows disk defrag utility from an Administrator session using RDC".

    Some say do not defrag, whats the real story?

    Monday, October 29, 2007 9:41 PM
  • from the drive extender technical brief:

    Caution
    You should not use the DEFRAG utility on your Windows Home Server hard drives. Defragmentation does not affect the primary data partition in a home server with multiple hard drives because the majority of files are 4 KB tombstones. The DEFRAG utility may cause issues with the Volume Shadow Copy Service that runs every 12 hours to create previous version snapshots of the shared folders on the home server.

    Andrew
    Wednesday, October 31, 2007 9:23 AM
  • There seems to be some confusion around this subject following the publication of the white paper yesterday.

     

    Its says dont do it, as quoted above, but then there are companies such as Diskeeper and Raxco producing WHS specfic and aware defrag software, which they wouldnt do if it broke WHS. Personally I think the whitepaper is referring to either built in defrag or non WHS aware defrag.

     

    I have been using the WHS Diskeeper product for a while now and had no problems at all.

     

    Andrew

     

    EDIT: I've pinged an email off to the WHS team for clarification on this one.

    Wednesday, October 31, 2007 9:28 AM
    Moderator
  • I have been using Windows Disk Defragmenter (unaware of the warnings) and have repeatedly experienced subsequent system hangs:

    . Disk Defragmenter and Windows Explorer both stop responding,

    . System GUI becomes slow or unresponsive,

    . Disk activity is very low or absent, and

    . Processor usage remains low or is unaffected.

     

    (It was for this reason that I began researching this topic and this is the first thread that I found.)

     

    Friday, March 21, 2008 8:36 PM