1. Moving Active Directory to a Different Drive
You can sometimes improve the performance of Active
Directory (AD) by moving the database file (ntds.dit) to a different
physical drive. This can also be useful if you are running out of hard
drive space. You can use the following steps to move the ntds.dit
database file to a different location.
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
Note
The Windows Server Backup feature must be installed for this step to work.
Tip
Although this step is not required, it ensures that you can recover
your DC if something goes wrong. It takes some time to complete.
|
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 move db to e:\ntds and press Enter.
Note You
need to substitute the drive letter e: with a valid writable drive on
your system. The folder doesn’t need to exist because the move command creates it.
|
7. | Type quit, and then press Enter twice to return to the command prompt. |
8. | Type net start ntds and press Enter to restart AD. After it starts, you can launch ADUC to verify that everything still works. |
2. 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.
Tip
An offline defragmentation compacts the file, and
you can compact the file only when AD is not running. You can stop the
service with the net stop ntds command. It’s not necessary to reboot into Directory Services Restore Mode.
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
Note
The Windows Server Backup feature must be installed for this step to work.
Tip
Although this step is not required, it ensures that you can recover
your DC if something goes wrong. It takes some time to complete.
|
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 1. |
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.
Create a backup folder named ntdsbu in the root of C by typing md C:\ntdsbu and pressing Enter. Type copy C:\windows\ntds\ntds.dit C:\ntdsbu\ntds.dit and press Enter. Note
If you moved the ntds.dit file, you need to substitute the C:\windows\ntds folder for the actual location.
Type copy C:\windows\ntds\*.log C:\ntdsbu and press Enter. Note These
steps create backup files of the ntds.dit AD database and the AD logs.
If the ntds service is unable to restart, you can simply copy these
files back to their original location.
|
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. |