Recent Entries

Rss Feed

Related Entries

Cheap and free disk defrag with contig

Saturday, March 3rd, 2007

For my day job, I work on large, proprietary databases that are gigabytes and gigabytes. Nothing is worse for these files than them being fragmented. The same can be said of Mysql’s .myd files or sqlite’s all-in-one database files.

Disk defragment is good, but we’ve all been mad seeing it shift the entire hard drive over a few sectors to make the whole thing contiguous. The process for a large drive takes hours, and your disk will soon be fragmented afterwards as any file block allocations will come from the beginning of the free space, which is now gigabytes away. My point in the previous sentence is that lots of time is wasted.

Contig is a sysinternals tool that will defragment individual files or recurse through directories so that they are contiguous on disk. This takes much less time. The only caveat is that it can’t work on files that are open for exclusive write. If you have application databases for apps that always keep their databases open, you won’t be able to run this while the database server is up.

From the command line, here is how to run contig on your windows system folder:

contig -s c:\windows\system32\*.dll

Or if you want to run it on mysql’s database files

contig -s c:\mysql\data\

It’s a very helpful tool. Download it here

Leave a Reply