I recently came across two completely unrelated installations of Mac OS X 10.5.6 where Spotlight had failed to index any new searches and was either holding onto a previous index or contained nothing at all. If you’re encountering Mac Spotlight problems, you might find the following useful.
The two macs I was dealing with were a 24 inch iMac – Intel Core 2 Duo 2.93GHz with 4GB RAM and 640GB hard drive installed. Spotlight seemed to be working properly with the iMac. You could perform a search and find a file, BUT if the file was newer it would not find it. The other was a Xserve with two 2.66GHz Quad-Core Intel Xeon Nehalem with 3GB RAM, 160GB Hard Drive installed and had a Promise VTrak E-Class RAID subsystems attached via Fiber Channel. I installed this Xserve out of the box with Mac OS 10.5.5 installed and updated it to Mac OS 10.5.6. Once the XServe was configured I attached it to the Promise VTrak subsystems and began transferring the companies archive files to it. After this was complete I began searching with Spotlight to see if I missed anything. I found that spotlight worked locally on the first and second Hard Drive but failed when asked to search the Promise VTrak.
There are two ways of handling this type of problem, either through the System Preferences or Terminal. Before starting either option please remember to always REPAIR PERMISSIONS before starting. The System Preferences route is mainly for those who have not used Terminal before and want to use something that is already part of the Mac OS 10. Simply launch System Preferences and Click on Spotlight. Once open, click on the Privacy Tab and then on the “+” (plus) button and add the volume you are trying to index. Wait a few minutes (5-10) and select the volume again on the Privacy Tab and click on the “-” minus button to remove it again. This will force Spotlight to perform a clean re-index of the volume.
In both cases I used the mdutil command in Terminal to resolve the issue. If you are not familiar with mdutil, its the command used to manage the metadata stores of mounted volumes that are used by Spotlight. The mdutil options include:
-p Publish metadata.
-i (on|off) Turn indexing on or off.
-E Erase and rebuild index.
-s Print indexing status.
-a Apply command to all volumes.
-v Display verbose information.
To perform this command you will need to launch Terminal and type the following to turn off indexing:
username$ sudo mdutil -i off /Volumne
Password: (your password here)
With Terminal still open, type the following to get an index of the volume you are trying to repair spotlight on.
(This gets you into the volumne structure)
username$ sudo ls
(This give you an index of all the hidden files on your Hard Drive)
You should see something similar to the following:
.DS_Store Library home
.fseventsd Shared Items mach_kernel.ctfsys
.hotfiles.btree System net
.vol Users private
Applications Volumes sbin
bin tmp cores usr
The two files you are after here are the .metadata_never_index and .Spotlight-V100. In one of my cases the .metadata_never_index was missing as in the example above. Don’t freak out if it is. The next two commands will remove these two files.
username$ sudo rm -r /.Spotlight-V100
username$ sudo rm .metadata_never_index
the sudo rm of the .metadata_never_index might return the following as mentioned about. Not to worry – that’s why we are working through these steps to get everything up and running again.
rm: .metadata_never_index: No such file or directory
Now let’s get everything back up and running. Type the following:
username$ sudo mdutil -i on /
username$ sudo mdutil -E /
That should do it. You will see the Spotlight icon in the upper right corner start pulsing a small dot in the center and if you click on it you can find out how long it will take to re-index.