Search code examples
osx-snow-leopard

Spotlight index breaks after reboot


After each reboot, my Spotlight index seems to break and I only get Dictionary results. I then have to rebuild the index (like add/remove root / to that list in the system preferences for spotlight) and it works fine until reboot. After reboot the same problem appears again.

I think my index first "crashed" after inserting my USB key, but it might only be a coincidence... I think I removed the USB key (iirc via Eject) before Spotlight has indexed it. I am not sure if this is relevant. I have not used my USB key since then, but the problem persists. I am not using any external drives.


Solution

  • Had this issue, registered an account just to post how I fixed it because there's so much crap on the net and most are half-arsed answers.

    So yeah, my Spotlight broke after every single time I rebooted. So I had to rebuild the index every single time.

    This is what I did, in the order I did it;

    sudo diskutil repairPermissions /  
    

    I repaired all the disk permissions, seeing as apparently that's what causes it most of the time. Then I rebooted into single user mode (Command-S while booting) and put in

    /sbin/fsck -fy 
    

    The check came back ok.

    Then I entered 'reboot' to reboot the computer and logged back in.

    Then I completely nuked Spotlight by;

    sudo rm -r /.Spotlight*
    
    sudo rm -r /Library/Spotlight
    
    sudo mdutil -i off /
    
    sudo mdutil -i on /
    

    Then I restarted and logged back in. After this, Spotlight started indexing everything. I also opened up Console (Applications -> Utilities). Select "All messages" under Database Searches on the left. I searched for "mds" and "mdworker" while it was indexing, refreshing it every now and then. I found one file it had errors on, the message was;

    Mar 15 16:02:48 CAPTAIN-JEWs-MacBook-Pro /System/Library/Frameworks/CoreServices.framework/Frameworks/Metadata.framework/Versions/A/Support/mdworker[558]: FontImporter: Validation failed - "/Users/jewishjews/Public/World of Warcraft/Interface/AddOns/MikScrollingBattleText/Fonts/cooline.ttf".
    

    So I deleted that file. Actually I deleted all of WoW because I don't play shitty games anymore. Moving on...

    I had activity monitor open the entire time. I was watching the activity of mdworker and mdworker32 (indexing processes). At one point mdworker was sitting on 0% activity, then I checked the indexing progress of Spotlight. It was stuck about 3/4 of the way through, and the time was just increasing, up to about 9 hours. After awhile I got fed up and reset the computer.

    After it rebooted I checked again and it was stuck on calculating the time remaining. mdworker wasn't running in activity monitor either. I checked online and some people were going on about md5 failing to hash things, which is why mdworker wasn't running. I couldn't find anything related to it in the Console logs though.

    At that point I had to leave, so I just shut the computer down for about an hour. When I got home I booted it up and it started indexing again, and mdworker was running fine. Weird. It finished, and Spotlight was working fine.

    Then I decided to reboot, seeing as I lose Spotlight functionality after a reboot. I logged back in and ... it worked fine. I decided to try booting into Bootcamp and then back into OS X to see if that is what messes my indexes up.

    So I did that, came back. Then Spotlight wasn't working again, only giving me dictionary results as usual. SHIT. I had the bright idea that I could try removing Bootcamp from Spotlight indexing. I wasn't sure if it would even index it, but I have NTFS Fuse, so it was a possibility.

    So I clicked the Spotlight button, searched for something then clicked Spotlight Preferences. Then I went to privacy and added the Bootcamp volume. Then I closed it and tried Spotlight again, and the damn thing worked. So I rebooted. Stopped working. I added Bootcamp to privacy again. It worked again. What the hell?

    I rebooted again and tried it again. I searched for Firefox, and nothing came up. So I decided to click Spotlight Preferences again. I saw that the second I clicked Spotlight Preferences it gave me results for the split-second that the Spotlight window is open for before it closes and System Preferences opens. So it seems that adding Bootcamp wasn't what did it.

    So I rebooted. Searched, got nothing. Clicked Spotlight Preferences, closed it then searched again. The stupid thing works. I then tried booting back into Bootcamp to see if that would destroy it. I logged back in and Spotlight works without me having to do the Spotlight Preferences trick. I've rebooted/shut down about 15 times so far and so far it is working perfectly.

    So yeah, that's how I fixed it. It's still working so for now it's fixed...

    Sorry for the rather verbose reply. I just detest people who give really shitty replies or say "dw i fixed it lol" 2 weeks later. Considering the computer-voodoo I had to go through to get it working, I figured I'd say everything I did because to be honest I have NO clue what exactly fixed the evil temptress that is Spotlight.