How to Compact Active Directory Database

How to Compact Active Directory Database

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.


  • 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.

Subscribe to VirtualizationHowto via Email 🔔

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Brandon Lee

Brandon Lee is the Senior Writer, Engineer and owner at and has over two decades of experience in Information Technology. Having worked for numerous Fortune 500 companies as well as in various industries, Brandon has extensive experience in various IT segments and is a strong advocate for open source technologies. Brandon holds many industry certifications, loves the outdoors and spending time with family.

Related Articles

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.