Tip

Defragmenting the Active Directory object database

When you defrag, you can save disk space and improve performance. This tip suggests two ways to defrag the Active Directory object database.

All objects in an Active Directory hosted on a Win 2000 Server are stored in a database named NTDIS.DIT and managed by an underlying Extensible Storage Engine (ESE). When filling pages, the ESE sacrifices memory efficiency for speed. Two defragmentation techniques recover the sacrificed memory.

Online Defragmentation:

The ESE performs online defragmentation periodically as part of the garbage-collection process. The process rearranges database pages and makes space available for new Active Directory objects. To change the online defragmentation period you need to change the garbage-collection period by modifying the garbageCollPeriod attribute in the enterprise-wide DS configuration object. Do this using any Active Directory editing tool, including Adsiedit.msc, Ldp.exe, or ADSI scripts. The path for the garbageCollPeriod of Server1 in the Company.com domain would be:

CN=Directory Service,CN=Windows 
NT,CN=Services,CN=Configuration,DC=SERVER1,DC=COMPANY,DC=COM

For details on other activities involved in the garbage collection process, check out

    Requires Free Membership to View

http://support.microsoft.com/support/kb/articles/Q198/7/93.ASP

Online defragmentation frees up space within the Active Directory object database (NTDS.DIT) to make room for new objects. However, it does not reduce the size of NTDS.DIT, and therefore cannot return unused memory to the file system. To do that you need to take the database offline.

Offline Defragmentation:

  1. Begin by backing up Active Directory, which can be done before taking the controller offline. (Use the backup wizard and either select the option to back up everything on the computer or select the option to back up the System State.)
  2. Reboot the domain controller and press F8 to display advanced options. Choose Directory Services Restore Mode and press Enter twice.
  3. Log on using the Administrator account. You'll need administrator permission to perform the defragmentation, and the security context and protection is quite different offline. If you have trouble, check out the note on the offline Security Accounts Manager (SAM) http://support.microsoft.com/support/kb/articles/Q223/3/01.ASP
  4. Click Start, select Programs, then Accessories, click Command Prompt, then type ntdsutil and press Enter.
  5. Type files, press Enter, type info, press Enter.
  6. You will now see the path and size of the Active Directory database and log files. Write down the path and note the size.
  7. Type compact to drive:directory where drive:directory is where you want to compacted file and has enough space to accept it.
  8. Type quit then Enter, then quit again to return to the command prompt.
  9. Copy the NTDS.DIT file from drive:directory to the path you wrote down in step 6.
  10. Reboot normally

For more background on defragmentation, check out these two articles:
http://support.microsoft.com/support/kb/articles/Q232/1/22.ASP
http://support.microsoft.com/support/kb/articles/Q229/6/02.ASP


Kevin Sharp is a registered professional engineer, writer, and yoga teacher living in Tucson, Arizona, and gains his expertise from a variety of professional activities. His engineering outlets include Web consulting for Supply Chain Systems Magazine, focusing on the fulfillment side of electronic commerce.

Did you like this tip? Let us know. You can drop a line to sound off.

Related Book

Windows 2000 Active Directory
Author : Joe Casad
Publisher : Osborne
Published : May 2000
Summary :
Explores what you can do in the new world of Active Directory, rather than just showing how to make a Windows 2000 network look and act like an NT 4.0 network. The Windows 2000 general reference books will not be able to approach this topic with this depth. Tech reviewed by the pros--Systems administrators, analysts, and MCSEs who are on the beta program testing Windows 2000 and Active Directory for their companies in the Microsoft Partnership Program have checked the book for accuracy and excellence. Expert author--Joe Casad is the best-selling author of SAMS Teach Yourself TCP/IP in 24 Hours, and two MCSE study guides from New Riders. In the industry, he is considered a networking expert and engineer. Full section on Total Cost of Ownership--Provides specific tips and examples that administrators can immediately use to reduce their networking costs. Topics include service publication, group policy integration, and Directory Object Extension. 16 pages of network blueprints--Illustrate the Active Directory Object naming system.


This was first published in August 2001

There are Comments. Add yours.

 
TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
Sort by: OldestNewest

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

Disclaimer: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.