Wednesday, April 20, 2011

Disable Spotlight on Mac OSX

Victory! After years of being somewhat irritated about the mdsworker and mds process running in the background and causing my fan to go on sometimes, I finally decided to do something about it. I never use Spotlight anyway so why not get rid it that and save some CPU cycles? There are many suggestions and tricks out there to disable Spotlight on Mac OSX, but most of them didn't make sense to me or didn't do exactly what I wanted when I tried them. The solution that I settled on here is the most effective, reversible, and safest in my opinion.

First a little background about OSX. When your mac boots up, it runs several property-list files (*.plist) via launchd, a unified, open source service management framework for starting, stopping and managing daemons, applications, processes, and scripts. So if we don't want Spotlight to start up and we don't want the mds process to index your drive(s), all we need to do it prevent launchd from starting the plist files that start these processes.

Here's how you do that (tested on Mac OSX Leopard 10.5)...

Spotlight

Open up Terminal, and run the command:
sudo launchctl unload -w /System/Library/LaunchAgents/com.apple.Spotlight.plist

MDS, MDSWORKER

In Terminal, run the command:
sudo launchctl unload -w /System/Library/LaunchDaemons/com.apple.metadata.mds.plist

Spotlight's Index Files

To get rid of Spotlight's files run the following command in Terminal:
sudo rm -r /.Spotlight-V100

Getting Spotlight back

If you change your mind after diabling Spotlight, all you need to do to start it again is to run the following commands in Terminal:
sudo launchctl load -w /System/Library/LaunchAgents/com.apple.Spotlight.plist
sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.metadata.mds.plist

Piece of Cake!!!

**Disclaimer - Use at your own risk. And remember, don't believe everything you read on the Internet! :)


References:

launchctl

4 comments:

Alex Nugent said...

So i ran these commands and it seemed to work, with one possible hiccup. when I tried to unload spotlight, I get:

launchctl: Error unloading: com.apple.Spotlight

However, mds worker is not running, and when I restarted the computer the spotlight icon in the top right went away, so it appears to have worked.

Tim Molter said...

@Alex My guess is you're running OSX 10.6 and they changed something minor between the releases. When I ran the first command to disable Spotlight, after a few seconds the Spotlight icon disappeared. I didn't need to restart. Glad to hear it worked for you though!

Andre Alforque said...

(I found you via Google search). Thanks for the tips. Any idea how to get this to work on 10.6?

Tim Molter said...

Andre, Nope, sorry. I haven't tried it on 10.6 yet.