If you give somebody your USB drive to put files on it, it is so annoying to clean up afterwards, all these useless for other than OSX platforms artifacts, which pollute the disk. Is it any solution to prevent this behavior. Maybe to write those files on your own and set them as read only something like "6/700" permissions?

P.S. I'm not asking what to do on OSX by others, since I don't know who will put me a new file next time (I can't explain this problem and any configurations to all other people), but rather what to do from the USB drive point of view.


2 Answers 2


If you're going to share an writable, external disk with other OS X systems, you can run the following command from YOUR machine to prevent .DS_Store files from appearing

touch /Volumes/your_volume_name/.metadata_never_index

then protect the file by running

chmod 444 /Volumes/your_volume_name/.metadata_never_index

This existence of this hidden file will prevent OS X Spotlight from indexing the drive so you only need to do it once unless you reformat the drive. I don't know if this works cross-platform, e.g., the dreaded thumbs.db Windows files.

Hope this helps.

  • 14
    So to prevent it writing hidden files to the usb you have to create a hidden file? Sigh
    – Basic
    Nov 19, 2014 at 9:23
  • 1
    What benefit is chmod 444? It may prevent writes to it, but it won't prevent its deletion, and you probably don't care about its contents. Whether Unix permissions will work on the USB stick's file system is also up for debate.
    – mwfearnley
    Oct 3, 2019 at 8:02

I found this blog post very useful: http://blog.hostilefork.com/trashes-fseventsd-and-spotlight-v100/


To stop OS/X from doing Spotlight indexing, you need a file called .metadata_never_index in the root directory of the removable drive. To stop OS/X from making a .Trashes directory, you need to make your own file that isn't a directory and call it .Trashes To keep it from doing logging of filesystem events on the drive, you need to make a directory called .fseventsd and inside that folder put a single file named no_log. ... I don't know of any way to prevent OS/X from creating .DS_Store files, which track some preferences in each directory...

But read the blog for full information and details.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.