O'Reilly logo

Active Directory Cookbook by Robbie Allen

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

16.12. Performing an Offline Defrag to Reclaim Space

Problem

You want to perform an offline defrag of the Active Directory DIT to reclaim whitespace in the DIT file.

Solution

Using a command-line interface

  1. First, reboot into Directory Services Restore Mode.

  2. Next, check the integrity of the DIT, as outlined in Recipe 16.7.

  3. Now, you are ready to perform the defrag. Run the following command to create a compacted copy of the DIT file. You should check to make sure the drive on which, you create the copy has plenty of space. A rule of thumb is that it should have at least 115% of the size of the current DIT available.

    > ntdsutil files "compact to <TempDriveAndFolder>" q q
  4. Next, you need to delete the transaction log files in the current NTDS directory.

    > del <CurrentDriveAndFolder>\*.log
  5. You may want to keep a copy of the original DIT file for a short period of time to ensure nothing catastrophic happens to the compacted DIT. If you are going to copy or move the original version, be sure you have enough space in its new location.

    > move <CurrentDriveAndFolder>\ntds.dit <TempDriveAndFolder>\ntds_orig.dit
    > move <TempDriveAndFolder>\ntds.dit <CurrentDriveAndFolder>\ntds.dit
  6. Repeat the steps in Recipe 16.7 to ensure the new DIT is not corrupted. If it is clean, reboot into normal mode and monitor the event log. If no errors are reported in the event log, make sure the domain controller is backed up as soon as possible.

Discussion

Performing an offline defragmentation of your domain controllers can ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required