Disable spotlight on newly mounted media (USB, CFast, etc.).

During video production, I frequently mount one media card after another. (USB drives, SD cards, CFast cards, etc.) As soon as they are mounted, MacOS fires up Spotlight on them, which is pretty useless: They're going to be mounted on my Mac only as long as it takes to unload the contents, and then they'll be reformatted.


The Spotlight indexing is still annoying, because:


  1. It prevents the cards from being unmounted, since Spotlight is busily using them.
  2. It writes Spotlight files to them, which consumes bandwidth that I'd rather use loading the cards.


Besides just globally turning off Spotlight indexing, is there a way to prevent this? Adding the `.metadata_never_index` file doesn't appear to stop indexing once it has started, and it starts instantly. Since each card has a new name, anything that involves maintaining a list of drive names isn't practical.


Thanks!

MacBook Pro 16″, macOS 14.5

Posted on Sep 14, 2024 7:39 AM

Reply
7 replies

Sep 14, 2024 8:15 AM in response to XofOldApple

Open the System Settings > Siri & Spotlight panel > Spotlight Privacy… panel. As soon as you mount the drive you do not want to be indexed by Spotlight, drag and drop it onto that open Spotlight Privacy window. You only need to do this once for each mounted drive.


Open a new Finder Window onto that mounted drive and press shift+cmd+dot to reveal the hidden .Spotlight-V100 folder that may have been previously created. You can drag that to the Trash and empty the Trash. Then issue that keyboard shortcut again to undo that hidden view.

Sep 19, 2024 8:46 AM in response to XofOldApple

Try creating the following file at the root of the volumes:


.metadata_never_index


It doesn't need any content. You can just do:


touch .metadata_never_index


using the Terminal. It may be possible using the Finder too, but it's more tricky.


If you already have a spotlight index that you want to remove, you can do the following:


sudo mdutil -X /Volumes/<whatever>


You will have to use this command. You won't be able to delete the Spotlight index on the volume otherwise.


I don't recommend using Spotlight Privacy. It is common for these kinds of volumes to have identical names. I'm not sure how Spotlight Privacy handles that internally. Also, Spotlight Privacy doesn't delete the index. It only excludes it from searching. Even if a volume is added to Spotlight Privacy, the Spotlight index will continue to be updated as normal. It just won't be included in the search.


Edit: I'm not sure about the index still being updated. I have to test with a real removable volume.

Sep 19, 2024 7:51 AM in response to XofOldApple

You can add /Volumes to Spotlight, if you wish. It will block ALL spotlight activity on the disks however, including your main.


It is what I did. I don't care about spotlight on my Mac drive but I have many external drives and USB that cannot be indexed due to contracts/NDA so, toss /Volumes in there and it appears to leave everything alone. For now.


Again though, your main Mac volume won't be indexed so don't do this if you use Spotlight to search your main files.


You could create a script that detects devices upon mount. I'm waking up or I'd figure out an example but I'm learning mac here - been primarily linux and other *nix systems. There's tons of these. You'll find plenty for linux and the scripts will work pretty much the same for mac, just a few minor changes, if one is so inclined.

Sep 19, 2024 9:10 AM in response to etresoft

OK. I did a more thorough test with a removable volume. Spotlight Privacy does prevent the Spotlight index from being searched or from being updated. It also functions much like the ".metadata_never_index". The privacy is applied to the volume itself and shows in Spotlight Privacy on other machines.


And adding a volume to Spotlight Privacy does delete the existing index.


And unmounted volumes don't show up in Spotlight Privacy at all. So duplicate volume names shouldn't be an issue.


So in other words, never mind.

Sep 20, 2024 5:55 AM in response to RF46

You're wrong. The first command fails.

The second command is not required.


(BTW, to add /Volumes, you may want to use your Finder and add it to your Favorites on your left before following my instructions to be able to find it easier when using the settings. The settings does not show hidden folders and you'll have a harder time navigating or, I'm still getting used to Mac. Just be aware, if you don't see it following my instructions, you can add it to your Favorites, then exclude it by selecting it from there)


FINAL EDIT: I have used Linux 20+ years. How many Mac users do you think want to have to use the terminal bud? It's different for us that use it daily ... Many people don't want to be executing system/root commands they don't understand. Do you even understand the commands or are you just copy/pasting? I've been in *nix environments for my whole life. I can answer for you but, I won't.


They can simply open the spotlight settings and add /Volumes through the GUI like I said above.

Then they can delete the spotlight folder. It is how I did it before posting.


I just tried your way and, the first command gets permission denied even as root on newest mac.


Your need to reply last has wasted multiple peoples' time or, will.


OF COURSE, it looks like the person above me "Ninja Edited" so here is their original reply:

(BUT AGAIN, Use the Settings -> Spotlight -> Add /Volumes to exclusion instead [pick "Search Privacy" at the very bottom-right as of current Mac version] , not what is below, I just won't be made to look a fool by a ninja edit)


Last person's actual reply:



"""


Try creating the following file at the root of the volumes:


.metadata_never_index


It doesn't need any content. You can just do:


touch .metadata_never_index


using the Terminal. It may be possible using the Finder too, but it's more tricky.


If you already have a spotlight index that you want to remove, you can do the following:


sudo mdutil -X /Volumes/


You will have to use this command. You won't be able to delete the Spotlight index on the volume otherwise.


"""

Sep 14, 2024 10:43 AM in response to VikingOSX

Yes, that works, but I am hoping for a more efficient process. Going through that with each new drive/card is really tedious. (There are also other problems, like being unable to reformat a drive because Spotlight is running on it.)


To editorialize for a bit (directed at MacOS and not you!), this is just broken. Spotlight firing up on every bit of removable media the instant you mount it is a serious annoyance for this kind of workflow.


I was hoping for a way to, in effect, tell MacOS "Don't start Spotlight on external drives unless I tell you."

Sep 20, 2024 8:29 AM in response to RF46

RF46 wrote:

You're wrong. The first command fails.

Obviously it doesn't fail.

The second command is not required.

It actually is required if you want to remove the .Spotlight-V100 directory altogether. But as I clarified, that may not be necessary.

I have used Linux 20+ years.

Beginner, eh? Everybody's got to learn somewhere. 😄

How many Mac users do you think want to have to use the terminal bud? It's different for us that use it daily ... Many people don't want to be executing system/root commands they don't understand. Do you even understand the commands or are you just copy/pasting? I've been in *nix environments for my whole life. I can answer for you but, I won't.

Aren't you just a bundle of joy and positivity?

They can simply open the spotlight settings and add /Volumes through the GUI like I said above.

For anyone reading this, definitely don't add /Volumes to Spotlight privacy.

Then they can delete the spotlight folder. It is how I did it before posting.

In some cases, the Spotlight folder is protected by SIP and can't be removed. My mistake was testing with a local APFS volume. Things may behave differently with a removable volume due to changes in permissions.

I just tried your way and, the first command gets permission denied even as root on newest mac.

I'm not sure what you were trying. It sounds like you were perhaps trying this with the /Volumes folder, which obviously won't work.

Your need to reply last has wasted multiple peoples' time or, will.

I'll be satisfied with just wasting yours.

OF COURSE, it looks like the person above me "Ninja Edited" so here is their original reply:
(BUT AGAIN, Use the Settings -> Spotlight -> Add /Volumes to exclusion instead [pick "Search Privacy" at the very bottom-right as of current Mac version] , not what is below, I just won't be made to look a fool by a ninja edit)

Ninja edit? That's not why you look a fool.


Maybe just chill out a bit, eh?


This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Disable spotlight on newly mounted media (USB, CFast, etc.).

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.