Skip navigation

How do I manually defragment Active Directory?

A. Windows 2000 servers running Directory Services (DSs) perform a directory online defragmentation every 12 hours by default as part of the garbage-collection process. This defragmentation only moves data around the database file (ntds.dit) and doesn’t reduce the file’s size.

To create a new, smaller ntds.dit file and to enable offline defragmentation, perform the following steps.

  1. Back up Active Directory (AD) (see the FAQ How do I back up Active Directory and the System State?).
  2. Reboot the server, select the OS option, and press F8 for advanced options.
  3. Select the Directory Services Restore Mode option, and press Enter. Press Enter again to start the OS.
  4. Win2K will start in safe mode, with no DS running.
  5. Use the local SAM’s administrator account and password to log on.
  6. You’ll see a dialog box that says you’re in safe mode. Click OK.
  7. From the Start menu, select Run and type
  8. cmd.exe
  9. In the command window, you’ll see the following text. (Enter the commands in bold.)
    C:\&gt; <b>ntdsutil</b><br>
    ntdsutil: <b>files</b><br>
    file maintenance:<b>info</b><br>
    ....<br>
    file maintenance:<b>compact to c:\temp</b>
  10. You’ll see the defragmentation process. If the process was successful, enter
  11. quit<br>
    quit
  12. to return to the command prompt.
  13. Then, replace the old ntds.dit file with the new, compressed version. (Enter the commands in bold.)
    C:\&gt; <b>copy c:\temp\ntds.dit %systemroot%\ntds\ntds.dit</b>
  14. Restart the computer, and boot as normal.

Below is an example of the entire procedure.

D:\&gt; <b>ntdsutil</b><br>
ntdsutil: <b>files</b><br>
file maintenance: <b>info</b><br><br>
Drive Information:<br><br>
C:\ FAT (Fixed Drive) free(1.2 Gb) total(1.9 Gb)<br>
D:\ NTFS (Fixed Drive) free(152.4 Mb) total(1.9 Gb)<br><br>
DS Path Information:<br><br>
Database   : D:\WINNT\NTDS\ntds.dit - 8.1 Mb<br>
Backup dir : D:\WINNT\NTDS\dsadata.bak<br>
Working dir: D:\WINNT\NTDS<br>
Log dir    : D:\WINNT\NTDS - 30.0 Mb total<br>
res2.log - 10.0 Mb<br>
res1.log - 10.0 Mb<br>
edb.log - 10.0 Mb<br>
file maintenance: <b>compact to c:\temp</b><br>
Opening database \[Current\].<br>
Using Temporary Path: C:\<br>
Executing Command: D:\WINNT\system32\esentutl.exe /d "D:\WINNT\NTDS\ntds.dit" /<br>
/o /l"D:\WINNT\NTDS" /s"D:\WINNT\NTDS" /t"c:\temp\ntds.dit" /!10240 /p<br><br><br>
Initiating DEFRAGMENTATION mode...<br>
Database: D:\WINNT\NTDS\ntds.dit<br>
Log files: D:\WINNT\NTDS<br>
System files: D:\WINNT\NTDS<br>
Temp. Database: c:\temp\ntds.dit<br><br>
Defragmentation Status (% complete )<br><br>
0    10   20   30   40   50   60   70   80   90  100<br>
|----|----|----|----|----|----|----|----|----|----|<br>
...................................................<br><br>
Note:<br>
It is recommended that you immediately perform a full backup<br>
of this database. If you restore a backup made before the<br>
defragmentation, the database will be rolled back to the state<br>
it was in at the time of that backup.<br><br>
Operation completed successfully in 17.896 seconds.<br><br><br>
Spawned Process Exit code 0x0(0)<br><br>
If compaction was successful you either need to<br>
copy "c:\temp\ntds.dit" to "D:\WINNT\NTDS\ntds.dit"<br>
or run:<br>
D:\WINNT\system32\ntdsutil.exe files "set path DB \"c:\temp\"" quit quit<br>
file maintenance: quit<br>
ntdsutil: quit<br><br>
D:\&gt; <b>copy c:\temp\ntds.dit %systemroot%\ntds\ntds.dit</b><br>
Overwrite D:\WINNT\ntds\ntds.dit? (Yes/No/All):<b> y</b><br>
1 file(s) copied.
Hide comments

Comments

  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Publish