Defragmenting your Exchange Database


Exchange database files only grow, never shrink. Every night, during maintenance the database is defragmented while online but not truncated. This means that internally the Exchange database works more efficiently but the size remains the same, even if mails are downloaded from the server or otherwise deleted from the mailboxes.


Exchange 2000 and 2003 databases now come in pairs, one with an EDM extension, the other with a STM extension. Both need to be defragmented, but as you’ll see you only need to specify the EDB extension and the STM file will be defragmented as well.


To shrink your database files you will need the ESEUtil utility located typically at c:\Program Files\Exchsrvr\Bin for Exchange 2000 and 2003 servers, unless the installation defaults were changed. If you’re unsure as to which directory Exchange was installed to, just search for the Exchsrvr\bin sub-directory on your hard drives.


However, even after five versions and myriad service packs this directory is still not added to the system path during installation so if you just go to the command prompt and type “ESEUtil” it will not run. To add this directory to the system path, run the Control Panel System applet.




Now press the “Environment Variables” radio button.




There, edit the Path variable to include “C:\Program Files\Exchsrvr\Bin”.





Preparing for ESEUTIL


Deframenting a database requires free disk space the size of the existing database to write a temporary file. If you don’t have this much disk space on the same drive where the database is located you can use the /t switch to specify a location. This can also be a network location but using a network drive is not as safe as using a locally mounted disk and much slower.  Sometimes with old servers that badly need this and don’t have enough disk space I take a simple IDE drive and connect it instead of the IDE CD-ROM.


ESEUTIL requires the databases be dismounted using ESM. With Exchange 2000 and 2003 administrator have the ability to defragment the database stores groups independently.  With Exchange standard edition server this means you can defragment the Mailbox Store and the Public Store independently. With Exchange Enterprise Edition this means that you can defragment any database of any Storage Group without downtime to the other databases. Just know that when you remount a database the other databases in the same storage group experience a short timeout while the log files are being re-synced.




It is recommended that you do a “cold” backup before starting the defragmentation process. This means backing up the database files (EDB and STM pairs) to a tape or to another disk drive or a network location so you would be able to recover in case a disk fails during the defragmentation process.


Now change to the directory where the Exchange databases are located and run the following command:



Eseutil /d [database name]


For SBS and Exchange Standard server the name of the database will typically be priv1.edb. After running this command a long procedure will commence to defragment this database and its .STM companion


After the process is over make sure to mount the database you just defragmented.




Be sure to defragment your database whenever you move users between servers or delete a lot of information. You can also know how much space can be saved by checking the event viewer for event ID 1221 message description contains the following text:



The database “storage_group\mailbox_store (server_name)” has nnn megabytes of free space after online defragmentation has terminated.

About The Author

Leave a Comment

Your email address will not be published. Required fields are marked *

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Scroll to Top