Performing an Offline Defragmentation of Active Directory Database
By default, Active Directory performs online defragmentation every 12 hours as part of the Garbage Collection process. Online defragmentation doesn’t compact the database, it only optimizes the data storage. To compact the AD database (ntds.dit), you can perform an offline defragmentation by following the procedure described below.
1. Restart the domain controller.
2. Press F8 and then select Directory Services Restore Mode.
3. Logon as Administrator.
4. Go to the command prompt and type ntdsutil.exe.
5. Type files.
6. Type info and make a note of the path.
7. Type compact to path, where path is the location for the compacted database, e.g. c:\temp, or “c:\compacted database”. You’ll need quotes around the path if there are spaces in the path.
8. A new compacted database called ntds.dit is created in the path you specified in the above step.
9. Type quit a couple of times until you exit ntdsutil utility.
10. Copy the new compacted ntds.dit over the old ntds.dit located in the path listed in step 6.
11. Reboot the domain controller normally.