Wednesday, July 25, 2007

Clearing Spotlight Cache in Mac OSX

The mdutil program in OS X can be used to clear out the metadata store that Spotlight uses. The metadata store is located in the /.Spotlight-V100 directory.

I had a problem with Spotlight where it started to behave erratically. Clearing out the metadata store fixed the issue. To clear the metadata store, you need to use sudo or become root. Additionally, the mdutil command requires that you specify a volume to operate on. Your primary volume is '/'. Other volumes, such as thumb drives, can be specified by their mount point.

Usage:

  1. To display the status of indexing
    # mdutil -s /
  2. To clear the metadata store
    Turn indexing off for /
    # mdutil -i off /
    Clear the metadata store for /
    # mdutil -E /
    Turn indexing back on for /
    # mdutil -i on /
When you clear the store and turn the indexing back on, it will take a while for the system to re-index the files and programs that you have installed.

1 comments:

Mark Recek said...

Thank you, very useful. Over time the index seems to become slower and sometimes won't clean-out old items, so it's good to reset the cache now and then.