Exchange Server Troubleshooting: EseUtil/d didn't Shrink my Database
Introduction
You may need to shrink the Exchange Server Database due to various reasons, such as performing clean-up process to reclaim the space or maintenance routine to reclaim unutilized space.
Like other files and databases, Exchange Server databases do suffer from unutilized space, also called white space. When you delete existing data from the database, it sometimes doesn’t reduce the size of the database. Instead, it creates space for storing new data.
To see if there is space to reclaim, you can use the below PowerShell cmdlet. It will give the details, such as database name, actual size, and available size.
Get-MailboxDatabase -Status | ft name, databasesize, availablenewmailboxspace -auto
In above example (see image), you can see that the database size is 247.9 MB while it has 74.34 MB of white space. With EseUtil, you can reclaim this space.
How to Shrink/Defrag the Database?
Here’s the process to defrag/shrink the database.
First, you need to open the Exchange Management Shell (EMS) to dismount the database. For this, run the below command.
Dismount-Database <database name>
Note: When you dismount the database, the users will not be able to access their mailboxes. So, this operation would need to be done after working hours or during a maintenance window.
Once the database is dismounted, run the EseUtil/d command (as given below) to start the defragmentation process.
Eseutil /d <database name> /t <temporary database name>
It is to be noted that if you already have an issue with space, this operation will not be successful as it needs temporary storage to work on. You might end up with no disk space on the server which would cause some repercussions. After some time, depending on the size and performance of your disks, you can mount the database by using the following PowerShell cmdlet.
Mount-Database <database name>
Once the database is online, you need to re-run the Get-MailboxDatabase PowerShell cmdlet from the Exchange Management Shell (EMS).
Get-MailboxDatabase -Status | ft name, databasesize, availablenewmailboxspace -auto
Why EseUtil/d didn’t Shrink my Database?
In a normal scenario, the storage will be reclaimed to the system and the space will be freed. However, at times, after executing the defrag/shrink process, you will find that the storage reclaimed is too small or there was no change.
The reason for this is that there is no space to shrink. It means that the database is full and there is no unutilized space that can be reclaimed.
If your server still has ample space, you can create a new database and move some mailboxes to the new database. This will ensure that the space is reduced from the original database.
To Conclude
If your server storage gets full during the process or the reason to shrink the database is that you are out of disk space, then repercussions might occur. The database or the database logs may get corrupted if the disk storage is full. In such a case, the database would end up in Dirty Shutdown state and will not mount.
However, it is suggested that you always monitor the storage of your server and have monitoring services in place to notify you about the storage status. This will help you to take timely action.