Disable spotlight for any external drive?

Discussion in 'OS X Mavericks (10.9)' started by wb0gaz, Jan 7, 2014.

  1. wb0gaz macrumors newbie

    Joined:
    Jan 7, 2014
    #1
    I use USB drives to move large (multi-gigabyte) raw data files to/from mavericks system. I wish to prevent spotlight from ever trying to index any external drive (that is, as a permanent policy for my system), as the indexing is not useful.

    I looked at spotlight in system configuration but could not see how to specify "any external drive".

    How can I proceed?
     
  2. LCD macrumors member

    Joined:
    Dec 28, 2012
    Location:
    USA
    #2
    In the Privacy Pane of Spotlight in System Preference click the Add button or drag the disk into the empty box to prevent Spotlight from searching it
     
  3. wb0gaz thread starter macrumors newbie

    Joined:
    Jan 7, 2014
    #3
    Thank you for the fast reply ---

    I understand I can drag a given external drive into spotlight privacy dialog pane, however, I wish to set up a rule pre-emptively for *any* external drive, so I don't need to do this step each time (as there are many drives involved.)

    Thank you again!
     
  4. w0lf, Jan 7, 2014
    Last edited: Jan 7, 2014

    w0lf macrumors 65816

    w0lf

    Joined:
    Feb 16, 2013
    Location:
    USA
    #4
    As far as I know there is no easy way to do this.

    Only thing I can think of is

    1) monitor /Volumes using folder actions
    2) when something connects add /Volumes/(name)/.Spotlight-V100/VolumeConfiguration.plist [only if it doesn't exist]
    3) then using either a template VolumeConfiguration.plist or the command defaults write edit the file you just made to include this
    Code:
    <key>Exclusions</key>
    <array>
    	<string>/</string>
    </array>
    
    I think the command for defaults write is something like

    Code:
    defaults write /Volumes/(folder_name_here)/.Spotlight-V100/VolumeConfiguration.plist Exclusions -array-add '{"/"}'
    All in all it's probably more hassle than it's worth unless we're talking hundreds of usb devices or you just want to learn some basic bash/applescript.
     
  5. LCD macrumors member

    Joined:
    Dec 28, 2012
    Location:
    USA
  6. w0lf macrumors 65816

    w0lf

    Joined:
    Feb 16, 2013
    Location:
    USA
    #6
    Hmm yeah .metadata_never_index sound easier assuming you just drop it in the root of the mounted drive.

    Not really too sure about the workings of folder actions but if you can run a bash script and pass the items as arguments you could just have something like:

    Code:
    for f in $@; do
      if [[ ! -e "$f"/.metadata_never_index ]]; then
        touch "$f"/.metadata_never_index
      fi
    done
    
    You might also have to add in a check to make sure it's not your internal drive.
     
  7. OS/4 macrumors newbie

    Joined:
    Jul 27, 2015
    #7
    Just want to add that I found this post very helpful, especially https://discussions.apple.com/thread/5486948 - thanks!

    I had an issue with one of my USB sticks being abysmally slow to copy files to - write speeds of less than 0.5MB/s - and just couldn't figure it out, because the same USB stick worked fine on Ubuntu or Windows.

    It seems such a "gotcha" for Mac newbies - it took me quite a while to realise what was happening: Every time I was plugging in the stick, Spotlight tried to index it, and because I was too impatient, it never finished, which also explained why sometimes it just wouldn't want to eject and I ended up forcing it. ...really frustrating until I added the USB stick to the Spotlight > Privacy list of things to exclude from indexing - then it started to behave fine and the USB write data rate improved hugely and were/are comparable to using the USB stick on other platforms.

    Like the OP, I think it would be nice if there was a setting to just _never_ index any USB sticks, but I'll settle for adding
    .metadata_never_index to the root dir of each USB stick I use, which still seems more convenient than having to add it to the Spotlight preferences, or at least going there to check whether I've already added it or not.
     
  8. OS/4, Aug 10, 2015
    Last edited: Aug 10, 2015
  9. foice macrumors member

    Joined:
    Dec 23, 2008
    #9
    I am wondering if anything like this might work to exclude from spotlight indexing all files with a given extension, say *.dat. Would you think the VolumeConfiguration.plist can work for this type of exclusion?

    Or do you know of another better way to instruct spotlight to ignore certain file types?
     

Share This Page