How to reduce windows.edb size

Today, My Grafana Dashboard notified me about low disk space on Jenkins Server. I investigated the Jenkins Server and found windows.edb too big.

NOTE: windows.edb is a windows index service database for indexing and property caching3v By default, the Windows.edb file is located in the below path.]

C:\ProgramData\Microsoft\Search\Data\Applications\Windows\Windows.edb

Power Shell Command to Check Windows.edb Size

((Get-Item $env:programdata’\Microsoft\Search\Data\Applications\Windows\Windows.edb’).length/1GB)

How to reduce windows.edb size

1. Reduce Windows.edb size using Defragmentation
  • Stop the Windows Search service.
#Disable & Stop Service
#1 Powershell
Set-Service -Name wsearch -StartupType Disabled
$S = Get-Service -Name wsearch
Set-Service -InputObject $S -Status Stopped

#2 SC Command
sc config wsearch start=disabled
sc stop wsearch
  • Defragmentation
esentutl /d %ProgramData%\Microsoft\Search\Data\Applications\Windows\Windows.edb

#With Fixed Path Version
#esentUtl /d "C:\ProgramData\Microsoft\Search\Data\Applications\Windows\Windows.edb"
  • Start the Windows Search service.
#Enable & Start Service
#1 Powershell
Set-Service -Name wsearch -StartupType AutomaticDelayedStart
Set-Service -Name wsearch -Status Running -PassThru

#2 SC Command
sc config wsearch start=delayed-auto
sc start wsearch
  • Full Step, I prefer powershell
#Disable & Stop Service
Set-Service -Name wsearch -StartupType Disabled
$S = Get-Service -Name wsearch
Set-Service -InputObject $S -Status Stopped

#Defragmentation
esentUtl /d "C:\ProgramData\Microsoft\Search\Data\Applications\Windows\Windows.edb"

#Enable & Start Service
Set-Service -Name wsearch -StartupType AutomaticDelayedStart
Set-Service -Name wsearch -Status Running -PassThru
2. Reset and Rebuild the Windows Search Index

Force windows search service to force delete index by changing Registry Path "HKLM\SOFTWARE\Microsoft\Windows Search" key SetupCompletedSuccessfully data from 1 to 0. This causes Windows Search to clear custom indexed locations, add default locations, and rebuild the index from scratch.

  • Command Line Version
sc stop wsearch
REG ADD "HKLM\SOFTWARE\Microsoft\Windows Search" /v SetupCompletedSuccessfully /t REG_DWORD /d 0 /f
del %PROGRAMDATA%\Microsoft\Search\Data\Applications\Windows\Windows.edb
sc start wsearch
  • PowerShell Version
#Stop Service
$S = Get-Service -Name wsearch
Set-Service -InputObject $S -Status Stopped

# Set variables to indicate value and key to set
$RegistryPath = 'HKLM:\SOFTWARE\Microsoft\Windows Search'
$Name         = 'SetupCompletedSuccessfully'
$Value        = '0'
# Create the key if it does not exist
If (-NOT (Test-Path $RegistryPath)) {
  New-Item -Path $RegistryPath -Force | Out-Null
}
# Now set the value
New-ItemProperty -Path $RegistryPath -Name $Name -Value $Value -PropertyType DWORD -Force 

#Remove Windows.edb
Remove-Item %PROGRAMDATA%\Microsoft\Search\Data\Applications\Windows\Windows.edb
#Start Service
Set-Service -Name wsearch -Status Running -PassThru

If you don't want to run a command, GUI Mode Open Control Panel >> Indexing Options >> Advanced >> click Rebuild

In my opinion, the Jenkins Server is not required to maintain any index. So, I choose the option to reset and rebuild the Windows Search Index to reclaim disk space.

Reference


Discover more from naiwaen@DebuggingSoft

Subscribe to get the latest posts sent to your email.