Apple’s Spotlight technology is its built-in searching routine for finding almost anything you will use in your account, and to do this it will create and then maintain a metadata index for each locally attached drive on your Mac; however, there may be times when you open the Spotlight menu and always see the progress bar indicating the system is indexing your hard drive. In addition, if you open the Activity Monitor utility, you will likely see the processes “mds” and “mdworker” using up a large percentage of the CPU.
Generally Spotlight may re-index your drive after a major system upgrade, restoration from backup, or after a fault such as a kernel panic or hang where you had to force-reboot the system. These are expected times for a full re-indexing of the drive to take place, and when spurred, indexing may take several hours to complete. However, if you otherwise see constant indexing and notice high activity with the “mds” and “mdworker” processes, then something is wrong and needs to be addressed.
First, try clearing your Spotlight index manually, to force a rebuild from scratch and ensure no problems exist with it that could be spurring regular attempts to update it. This can be done in two ways:
1. The Spotlight Privacy list
Open the Spotlight system preferences and go to the Privacy tab. Then drag each of your locally-mounted filesystems (internal and external) to this list, followed by immediately removing them from the list. This will delete the index on the drives, and thereby force the system to recreate them when the volumes are removed.
2. The Terminal
As for most system services, Apple includes a few Terminal utilities to manage the Spotlight index, which can be used to clear and rebuild the Spotlight index on your system. To do this, open the Terminal and run the following three commands sequentially:
mdutil -Ea mdutil -ai off mdutil -ai on
Keep in mind that once either of these routines is done to clear the index, once the rebuild begins it may take a long time to complete, so do not be alarmed if you see the same behavior kick in for at least a few hours. Give it time to finish, and then see if the problem persists.
If you again see the issue crop up, then try looking at your hard drive’s formatting. Filesystem errors can easily lead to access and data handling problems that could, among other issues, have Spotlight continually try to index files. Therefore, use Apple’s Disk Utility program to verify and repair your hard drives:
- Open Disk Utility.
- Hold the Command key and click each of your mounted volumes in the sidebar to add them to the current selection.
- Click “Verify Disk” in the First Aid tab.
Doing this will run the verification on all selected drives, and if any issues are found, then attempt to repair them using the Repair Disk button. If the problem is found on your boot drive, then you will need to reboot to the Recovery HD partition (hold Command-R when you hear the boot chimes at startup), to fix the issue at hand.
mdutil -ai off
mdutil -ai on
Thanks Topher, very useful, but can you tell it to do that on specific volumes? I would need to do that on a backup volume but without going through re-indexing my main/boot drive.
Absolutely! The -a option is precisely the one telling mdutil to work on all the volumes. If you omit it, you need to specify the volumes you want to affect:
sudo mdutil -i off /Volumes/My\ Volume
(Note that I included the sudo command since this has to be run by root in most volumes, and that I “protected” the space with a backslash…. but autocomplete is your friend.)
For your system drive you can simply type something like:
sudo mdutil -i on /
Great, thanks a lot!
Apple should also allow to search non-indexed volumes, as EasyFind does.
Besides having a decent interface as HoudahSpot
I use EasyFind a lot, but depending on what you’re looking for, it can be pretty slow. A very fast search app (files only, including system, but not contents) Is Thomas Tempelmann’s Find Any File.
I would recommend to do what Topher wrote, but in reverse order: First check (and repair) volume structures, then rebuild the Spotlight index.