In order to compact the size of the Active Directory Database you need to stop Active Directory Domain services.ย If you are running Windows 2008 and above you can simply stop the ADDS service and proceed with the steps.ย However, if you are running Windows 2003 you will need to restart your domain controller in Directory Services Restore Mode by rebooting, pressing F8 and choosing DSRM.
Stopping the service in Windows 2008 R2
After you have stopped the ADDS service (Windows 2008 and higher) or restarted in DSRM (Windows Server 2003 and below) you can proceed to launch the NTDSUTIL utility to run maintenance on your Active Directory files.
NTDSUTIL
- run ntdsutil at a command prompt after stopping ADDS
- type files
- If you get an error about the Active Instance not being set, then type Active Instance NTDS and this will set the instance
- type files again if you had to set the Active Instance
- type compact to c:yourfoldername replacing the path with one of your choosing
- the database will then be compacted and you will see the status indicator moving across until finished.
After the compacting process finishes, you receive instructions on what to do next:
- You are told to copy your compacted file to “Location of your AD database currently”
- Delete old log files in the ADDS log file directory
After you have finished copying the compacted file to the proper location, and deleted the log files, you can then restart the ADDS service or restart your pre Windows 2008 domain controller normally.
Final Thoughts
The compacting process for an Active Directory database is pretty straightforward.ย Keep in mind that you will need to do this on all domain controllers that need to be compacted as the physical database itself isn’t replicated to all other domain controllers.