Reading List

The Selfish Gene
The Psychopath Test: A Journey Through the Madness Industry
Bad Science
The Feynman Lectures on Physics
The Theory of Everything: The Origin and Fate of the Universe


ifknot's favorite books »

Thursday 7 January 2016

Spotlight Schmotlight - Stopping runaway CPU usage by mds & mdworker nonesense!

photo credit: It's Murder, Watson! via photopin (license)

Have you tried switching it off and on again?

Disable Spotlight

The primary method is using launchctl, this will require the administrative password:





 sudo launchctl unload -w /System/Library/LaunchDaemons/com.apple.metadata.mds.plist 

Another approach is to use the older indexing method of “sudo mdutil -a -i off” which turns off indexing only:

mdutil -Ea      
mdutil -ai off  
mdutil -ai on   


The first of these will erase the Spotlight index on all volumes, the second will turn Spotlight indexing off, and the third will then turn it back on. 

Reenable Spotlight

The guaranteed way to reenable Spotlight is to reload it into launchd using launchctl:
Again, the alternate approach is the indexing related “sudo mdutil -a -i on” command, but that method can throw the “Spotlight server is disabled” error and not allow you to turn it back on. If you run into that problem, use the sudo launchctl load command instead to enable both indexing and Spotlight.

After Spotlight has fully reloaded launchd, mds agent will start reindexing to the filesystem. The time will be different for each used based on the number of changes that were made and new files since the last time MDS ran. You can verify that MDS is running through Activity Monitor or by pulling down the Spotlight menu to see an “Indexing Drive Name” progress bar.


Another option is to selectively disable Spotlight indexing of specific drives or folders by excluding them from the index, that is much easier to do and does not involve the command line at all, and instead you only need to drag & drop items into the Spotlight control panel.

Individual exclusion via settings:

http://superuser.com/questions/46195/why-does-mds-run-wild-in-mac-os-x-10-6


Failing that use Apple’s Disk Utility program to verify and repair hard drives:
  1. Open Disk Utility.
  2. Hold the Command key and click each of your mounted volumes in the sidebar to add them to the current selection.
  3. 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 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.

No comments:

Post a Comment