When you press Command + Space to open Spotlight on your Mac, you expect instant search results. However, if the system has recently crashed, or if you have cloned a massive amount of data from an external drive, the internal metadata database can become corrupted. When this happens, Spotlight will either return completely blank results, or spin endlessly while \”Estimating Indexing Time.\” To mathematically force the operating system to delete the corrupted database and rebuild it from scratch, advanced macOS users rely on the mdutil command.
Why Use the mdutil Command?
The standard graphical method for fixing Spotlight involves dragging your hard drive into the \”Privacy\” tab of System Settings, and then dragging it out again. This GUI workaround is notoriously unreliable and often fails silently on modern APFS volumes. The mdutil (metadata utility) command interfaces directly with the mds (metadata server) daemon running in the kernel. It allows you to view the exact status of the indexing engine, turn the indexing service completely off for specific volumes, or force an immediate, aggressive rebuild of the entire database.
Step 1: Check Indexing Status
Before taking action, you should audit the current state of the mds daemon on your primary hard drive. This command requires root privileges.
- Open the macOS Terminal.
- Run the command to query the status of your root volume (
/):
sudo mdutil -s /
The terminal will return a status message. If it says Indexing enabled, the daemon is active. If it says Indexing disabled, the daemon has been turned off, which perfectly explains why your searches are failing.
Step 2: Turn Indexing Off and On
If the daemon has crashed, simply toggling the service off and on can sometimes reset the worker processes.
- To mathematically disable the metadata server for your main drive:
sudo mdutil -i off /
- Wait a few seconds, and then mathematically re-enable it:
sudo mdutil -i on /
You can also target specific external drives by replacing the / with the volume path, such as /Volumes/BackupDrive.
Step 3: Force a Complete Rebuild (Erase)
If toggling the service does not fix the corrupted search results, you must force the system to delete the existing database (usually hidden inside a folder named .Spotlight-V100) and start over.
- Use the
-E(erase) flag on the root volume:
sudo mdutil -E /
The terminal will instantly reply with Index will be rebuilt. There is no progress bar in the terminal; however, if you press Command + Space to open Spotlight and type a single letter, you will see a small progress bar indicating that the system is re-indexing your files. Note that this process can take several hours depending on the speed of your SSD and the total volume of data.
Step 4: Disable Indexing Completely (For Performance)
If you are using a Mac as a dedicated server (e.g., a web server or a media rendering node), you may want to permanently disable Spotlight to prevent the mds_stores process from consuming CPU cycles.
- Run the disable command:
sudo mdutil -i off /
- Follow it immediately with the erase command to delete the existing, now-useless database to free up disk space:
sudo mdutil -E /
By mastering the mdutil command, macOS administrators can programmatically resolve complex metadata corruption and optimize system resource allocation without relying on graphical workarounds.