Home > Articles > Certification > Microsoft Certification

  • Print
  • + Share This
This chapter is from the book

Defragmenting Active Directory

AD performs an online defragmentation every 12 hours by default. This is normally all that's required. However, the online defragmentation does not reduce the size of the ntds.dit database file. If you have significantly fewer objects in AD than you had previously, you can shrink the size of the ntds.dit file by performing an offline defragmentation.

You can use the following steps to compact the database.

Step

Command

1.

Launch a command prompt. Back up system state data with the following command. This command uses the D: drive as the backup target, but you can choose a different target based on your system. wbadmin start systemstatebackup -backuptarget:d: -quiet

2.

At the command, type net stop ntds and press Enter. When prompted to stop additional services, press Y to confirm. This stops AD and related services.

3.

Type ntdsutil and press Enter.

4.

Type activate instance ntds and press Enter.

5.

Type files and press Enter.

6.

Type compact to C:\compact and press Enter. You can use any target folder desired (other than C:\compact). Your display should be similar to Figure 12-3.

7.

Type quit and press Enter. Type quit and press Enter again. This returns you to the command prompt.

Although the following steps aren't required, they help ensure that you can return to the original configuration if something goes wrong.

  1. Create a backup folder named ntdsbu in the root of C by typing md C:\ntdsbu and pressing Enter.
  2. Type copy C:\windows\ntds\ntds.dit C:\ntdsbu\ntds.dit and press Enter.
  3. Type copy C:\windows\ntds\*.log C:\ntdsbu and press Enter.

8.

Type copy C:\compact\ntds.dit C:\windows\ntds\ntds.dit and press Enter. When prompted to confirm the overwriting, type Y for yes.

9.

Type del C:\windows\ntds\*.log and press Enter.

10.

Type net start ntds, and press Enter. This restarts the ntds service. After it starts, you can launch ADUC to verify that everything still works.

Figure 12-3

Figure 12-3 Performing an offline defragmentation

  • + Share This
  • 🔖 Save To Your Account