OK, so I've never been very happy with the disk defragmenter that comes with Windows 2000 and XP. It's a "lite" version of Executive Software's Diskeeper
. I haven't tried any recent versions of Diskeeper, but the v4 release didn't do a very good job if the disk was heavily fragmented and nearly full. Its basic algorithm is "for each file, find a free slot big enough to hold that file and move the file there. Repeat until bored." Of course, if you haven't got a free slot that's big enough, you're hosed.
I tried Norton's defragger once and it corrupted my NTFS volume. I haven't even dared try a newer version. Things may have improved, so I have no warnings or recommendations there.
Then I found detailed documentation on how the defraggers are implemented here. The site also provided a cheap defragger and source code. Unfortunately, it suffered the same basic design flaw as Diskeeper - if there wasn't enough free space to hold the whole file, you weren't going to get any better.
So, I got to work. Here is the result. My defragger employs the tried and true defragmenting algorithm of "evacuate and place". It first evacuates a large portion of contiguous free space, then starts placing files in the new empty hole. Repeat until defragged. However, in order to do this, it needs to repeatedly iterate over every file on your disk. This makes the overall process quite slow if you have many files, but the algorithm never fails to completely defrag your disk, no matter how full it is (well, you need some free space). My machine at work has a disk full of about 112,000 files and folders taking up about 15GB and it takes less than 8 hours to do a total disk defrag.
It works with any OS-supported file system* on any OS-supported writable media. It will only work on Windows XP and later versions of Windows. It's been tried on XP, Server 2003, Vista, and some prerelease versions of Server 2008 (Longhorn). This program will not work on any other line of Windows (2000, 9x, Win 3.1, etc). There is no 64-bit version at this time. I highly recommend against trying to run this on any 64-bit version of Windows.
- Can be run by any user (service needs to be installed by an administrator).
- Complete whole-disk defragging, including private operating system files.
- Multiple instances can be run simultaneously (if you have multiple disks).
- Individual file defragging, with wildcards and recursion. This mode is an opportunistic defragger, marginally better than Diskeeper in that it will at least defrag the file as best it can rather than not at all.
- Defrags NTFS, FAT** and FAT32** filesystems on any media (HD, Flash, ZipTM/JazTM, Floppy, etc).
- A "shotgun" mode, where it severely fragments files. Useful for testing or really annoying someone.
- Individual file fragmentation analysis. Find out where on disk a file resides, and how many fragments it's in.
- 100% safe and interruptable. This program doesn't actually move the files - the OS does it. Even if you suffer a power failure while it's working, you run no higher risk of file system corruption than you would if you had happened to be saving a file from any application.
- Boot-time defragmentation.
- Functionality on 64-bit Windows
- Defragmentation of NTFS metadata files
Given that Windows "7" has substanitally improved built-in defragmentation, I won't be doing any work to ensure full compatability with that version of Windows. I expect the current version will work as-is on Windows "7", and I don't plan on fixing any issues that are found.
*At this time, the OS only supports defragging on FAT, FAT32, and NTFS volumes. I don't know how far-reaching HPFS volumes are, or if other file system drivers even exist. For this program to work with those filesystems, the filesystem driver needs to support the defragging APIs of the OS.
** The operating system doesn't provide for defragmenting directories on FAT and FAT32 drives. While all your files will be as defragmented as possible, the immobility of directories totally throws a wrench in the process. Unless you really need to be using either of these file systems, I suggest you don't. NTFS is substantially more robust (you rarely need to run chkdsk) and it supports a huge variety of extra features, like volume striping, journaling, transactioning and so on.
Download Defrag.zip (82.04 KB, x86, 23 May 2004)