Tip

Defragmenting the Active Directory database

Brien M. Posey

Just like any other type of database, the Active Directory database tends to become fragmented through normal use. The process of adding and removing objects naturally creates fragmentation. Windows 2000 uses the Garbage Collection Process and Online Defragmentation to get rid of most of the fragmentation that occurs. However, there are limits. Neither of these processes can reclaim lost space within the database. Fortunately, there is a way to reclaim this lost space, while helping your Active Directory database to run more efficiently. The process is called Offline Defragmentation.

Offline Defragmentation can't run while a domain controller is running. Instead, you must take the domain controller offline and boot it into Directory Services Repair Mode. You can do this by pressing F8 and selecting the corresponding command from the boot menu. When the computer finally boots, make a backup copy of the NTDS.DIT file. This

    Requires Free Membership to View

is the actual Active Directory database file for that domain controller. It's a good idea to make a backup in case anything goes wrong. Once the system has been booted normally, and you can confirm that Active Directory is running, you can get rid of the backup copy. I also recommend running this process only if you know that there is probably a lot of empty space in your database. Remember, too, that each domain controller contains a separate copy of the Active Directory database. Therefore, if you find yourself needing to use this technique, you'll probably want to repeat it for each domain controller in the domain. Be sure to do one server at a time, or you could cause some serious problems with the databases.

The next step in the process is to open a Command Prompt window and issue a series of commands that will show you the location of the Active Directory database. The command sequence is:

NTDSUTIL
FILES
INFO

Once you know the location of the Active Directory database, make a backup of it. You may now begin the Defragmentation process. The process involves creating a brand new, compacted version of the database and then using this copy to replace your previous copy. The commands for doing this are (assuming that the last command you entered was INFO):

COMAPCT TO F: (where F: is the location where you want to temporarily store the new copy)
QUIT
QUIT
ERASE C:WINNTNTDSNTDS.DIT  (this command erases your original database and assumes that the original database was located in C:WINNTNTDS
ERASE C:WINNTNTDS*.LOG
COPY F:NTDS.DIT C:WINNTNTDS

About the author:
Brien Posey, CEO of Posey Enterprises, is a freelance technical writer who has been working with computers for about 15 years. Before going freelance, Brien served as director of information systems at a large, nationwide healthcare company. He has also served as a network engineer/security consultant for the Department of Defense. You can access Brien's Web site, which contains hundreds of his articles and white papers, at http://www.brienposey.com.


This was first published in August 2002

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.