April 15, 2012

Disabling Spotlight on OSX Lion

Apple's search indexer “Spotlight” likes to run and use all the disk bandwidth and most of the CPU on my machine quite regularly. It seems to correlate with large numbers of file changes, and can keep running for hours. For example, it can't handle doing a git checkout which changes a few thousand files. Backup programs which generate a large number of short lived temporary files also seem to incapacitate the indexer (for example, BackBlaze). Unfortunately, it's not that easy to disable globally from the GUI. Luckily Apple provides a command line tool. To disable indexing for the main volume you can do:

sudo mdutil -i off / 
I also discovered that deleting the index frees a shocking amount of space (around 7G on my machine!)
 sudo mdutil -Ea 

If your Mac is being slow, and not sure if you have this problem you can check your favorite monitoring tool for two processes: “mds” and “mdworker”

Powered by Hugo & Kiss.