Defrag Exchange 2010 Mailbox Database using PowerShell Utility

In this blog I am going to give you a relevant discussion on how to use Eseutil utility to defrag exchange 2010 mailbox database and also explaining about white space in database and how it would be removed. After reading this blog you have conceptual view that help in database defragmentation.

What is white space in Database?

The database is used to store data, on that a user can perform insert, update and delete operations. When user performs delete operation then some data or data file removed from the database due to which some space is free and that free space is called white space in database. Most of the exchange administrator suffered from this issue so they need a tool that can used to defrag the exchange 2010 mailbox database.

Microsoft provides an inbuilt Eseutil utility which can be used to defrag the exchange database and resulting database will be reduced in size and more space will be available to use. Follow the steps given bellow to defrag the exchange 2010 mailbox database.

Steps to Defrag Exchange 2010 Mailbox Database

To defrag the exchange database you have Eseutil utility that need to be run on PowerShell command line. If you are familiar with command prompt then you can easily use it and if not then you may face some trouble when running the commands. You have two ways through which you can remove white spaces from database.

  • Perform an offline defragmentation on existing database to remove white space.
  • Create a new database and move all mailboxes in it.

Both the processes have its own pros and cons.

Step 1: - Determine the free space in an Exchange 2010 Mailbox Database

In Exchange 2010 you can see your mailbox database size and white spaces that it contains by using the Eseutil utility given bellow.

       Get- MailboxDatabse –Status | ft name, databsesize, availablenewmailboxspace –auto

This command will provide you a tabular result that contains Name, DatabaseSize and AvailableNewMailboxSpace. Now you have determined the free space in the database now before starting defragmentation you need to prepare database defragment able.

Step 2: - Make an Exchange 2010 Database defragment able

The first thing you have to dismount the database because the defragmentation can be done only when the mailbox database is dismounted. It means that the user is unable to access his mailbox while you are defragging it.

Second thing should be kept in mind that you need some free disk space equivalent to 1.1 X predicted size of new file to perform defragmentation. Because a new file will be created during this process and both the file will exist at the same time so if required disk space is not present then you need to specify a different temporary location and that con be on other local drive or a UNC path, and due to network latency defrag process will take longer time.

Step 3: - Use Eseutil to Defrag Exchange 2010 Mailbox Database

  • Open the Exchange Management Shell and locate the folder that contained by the database like given bellow.
          cd D: \Data \mailbox name
  • Dismount the mailbox database use the command
          Dismount –Database database_name
  • Now run the Eseutil utility to defrag the mailbox
           D: \Data \Database_Name>Eseutil /d mailbox.edb_file /t \\testserver\defrag\temp.edb
    Note: - it is recommended that you need to perform immediately a full backup of this Database.
  • Mount the Database again on to the server
          mount-database database_name

Now you can see clearly that all the white space is removed and Exchange 2010 is defragmented by running the command as used in starting to determine the white space.

      Get- MailboxDatabse –Status | ft name, databsesize, availablenewmailboxspace –auto

Conclusion

I have tried to give you a simplified way to defrag exchange 2010 mailbox database and remove the white space in database. I hope that this blog will help to defrag the database and to understand the situation.