Optimizing The Windows Defragmentation Process

When I switched to Mac, the thing I missed least of all was having to periodically defrag my hard drive. Since I’m currently doing Windows development, I’m back to running Windows in a VM and made the mistake of not defragging my Windows drive for several months. After running the built-in defragger off and on for several days with no end in sight, I decided to back up and try a different approach.

  • I used msbuild /t:clean to remove all of the build artifacts for my Visual Studio projects.
  • I used cygwin‘s rm command to destroy everything in C:\Documents and Settings\\Local Settings\Temp. You could use the delete functionality of Windows Explorer or the Windows erase command, but I find rm to be much faster when there are 1000’s of files. If you use Windows Explorer, just make sure you empty your trash bin before you start the defragger.
  • I used rm to destroy most of the files in C:\WINDOWS\Temp.
  • I installed Smart Defrag.

Not only does it look like it’ll be done by the end of the day, but Smart Defrag‘s automatic functionality should keep future fragmentation down to a minimum.