Database Defragmentation – Poor Man’s Solution

You might already have heard of Defrag.NSF. Defrag.NSF. is a database-oriented utility that allows you to target Domino databases for defragmentation. You can automatically monitor and pre-allocate contiguous free space to be added to your databases during Defrag.NSF. maintenance, giving them headroom to grow without scattering data to random sectors of your disks.

Why is defragmentation of Notes databases important? To answer the question read Adam Osborne’s article:  Busting the Myth – how Compact -C fragments databases.

I’ve tested Defrag.NSF. during the beta phase of the product. It is a great tool, reliable and easy to use. So far , so good. But good tools cost money. And even $199 for a single server copy can be a lot if you do not have any budget.

As a developer, I could write my own solution, or find something in the World Wide Web. There are quite a lot of freeware tools ( even OpenSource ) available, but 99% of them can only defragment a whole disk but not a single file. The only tool I’ve found so far to defragment a single file or a set of files is Contig.exe by Mark Russinovich.

Contig.exe works on NT 4.0 and higher. Contig.exe can be used to defrag an existing file, or to create a new file of a specified size and name, optimizing its placement on disk. Contig.exe uses standard Windows defragmentation APIs so it won’t cause disk corruption, even if you terminate it while its running.

Just download and copy contig to your Windows directory and you are ready to analyse and defragment your databases. I’ve also tried to copy the executable to the Domino executable directory and trigger it by typing

load contig.exe -a -v -s d:\IBM\Lotus\Domino\data\*.nsf

Contig works and prints the results of the analysis to the Domino console. But unfortunately it seems that it has some side effect on running server tasks. At least the traveler task on my Domino 8.0.1 terminated abnormally.

Here are a few screenshots to show, how Contig works and that it can make files contiguous after being fragmented when using the -c option with ncompact.

Before running compact -c , my mailfile is not fragmented

Then I ran compact …

After the task has finished, contig -a -v showed 111 fragments …

Running contig -v moved the fragments to a free disk block and makes the file contiguous.

Well, this is my poor man’s solution. It is ok, if you only have a handful of databases on your server ( or you do not have a budget to buy a tool like Defrag.NSF ).