Tell me more ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

When plugging a USB stick into a Mac, OS X creates a number of hidden files on the stick, including a Spotlight index and Trash folder.

Example from the terminal for a USB stick "Untitled":

$ ls -a /Volumes/Untitled
.Spotlight-V100
.Trashes
._.Trashes
.disk
.fseventsd

It even does this on the xD memory card for my camera, so after having copied my pictures and deleted them from the card, the card is still full.

Is it possible to turn this off for USB and memory cards, so OS X either writes these files to the primary disk or doesn't write them at all?

share|improve this question

8 Answers

up vote 11 down vote accepted

As I know you have 2 choices :

  1. TinkerTool (free)

alt text

  1. BlueHarvest (commercial)

alt text

share|improve this answer
OK, thanks. Was kind of hoping that there would be a built-in setting somewhere, but at least there's a solution available. – j-g-faustus Jan 20 '11 at 18:08
@j-g: Tinkertool shows the system settings in a GUI interface as opposed to CLI, which can be harder to use for a lot of people. – Philip Regan Jan 20 '11 at 18:28
@Philip: Unfortunately Tinkertool only deals with .DS_Store files according to their detail page, which presumably means that this is the only hidden file that can be disabled through the CLI - the other files need custom tools. But BlueHarvest looks nice, and does what I need. (Found some more details on the issue here and here) – j-g-faustus Jan 20 '11 at 18:47

Another way to deal with (just the) spotlight files, is to add that volume to your Spotlight exclude list. Plug the device in, and go to the Spotlight prefpane in System Preferences. Select the Privacy tab. Now drag that volume from your desktop up into the privacy list.. or use the + button at the bottom to add it. No more spotlight indexing will happen on that volume.

share|improve this answer
Thanks, I'll try that. – j-g-faustus Jan 21 '11 at 8:16

For just a particular mounted volume - like a flash drive called yourUSBstick in this example - these commands will remove existing cruft, stop Spotlight indexing now and in the future, stop the related fsevents logging, and disable the Trash feature.

mdutil -i off /Volumes/yourUSBstick
cd /Volumes/yourUSBstick
rm -rf .{,_.}{fseventsd,Spotlight-V*,Trashes}
mkdir .fseventsd
touch .fseventsd/no_log .metadata_never_index .Trashes
cd -

Other unfamiliar stuff you may still see you probably want to keep, like Apple double "._*" files and other Apple DS cruft relating to icons and window placement.

share|improve this answer
While this may disable indexing, those files and directories will still be present on the volume (which is the annoying part in the first place), and if you delete them .Spotlight* and .fseventd will come back. In fact, .metadata_never_index is one more entry in the file listing than the usual cruft. – ShreevatsaR May 21 '11 at 8:02
+1, Actually, I came up with he idea of touching trashes myself and went here for a better solution, but having seen this one couldn't resist +1 it. It solves the real problem — stopping car audio from playing trashed files ;) – Michael Krelin - hacker Feb 1 '12 at 19:33

To keep Spotlight from indexing non system volumes, add /Volumes to the Privacy list in System Preferences > Spotlight.

/Volumes is the point in the file system where all non-system disks are mounted by default.

enter image description here

share|improve this answer

I use the MacOS Terminal command line to list and delete all these files and folders before ejecting the device from the desktop. For some files, you may have to sudo the /bin/rm command.

share|improve this answer
That's what I do too. Although it would be even better if I didn't need to, so I'm investigating the alternatives. – j-g-faustus Jan 20 '11 at 20:26
By the way, the device is found somewhere at /Volumes/<name> – DerMike Jan 21 '11 at 11:31
  1. Insert the USB drive.
  2. Navigate to Macintosh HD > Applications > Utilities and open Terminal.
  3. At the Terminal prompt, type the following command, replacing path_to_volume with the real path:

    sudo mdutil -i off /path_to_volume

  4. Press return.

  5. If prompted for a password, type your admin password, then press return. You will receive the response:

    /path_to_volume/: Indexing disabled for volume. in Mac OS X 10.4 or

    /path_to_volume: Indexing disabled. under Mac OS X 10.5 or later.

    Spotlight will immediately cease to index the specified volume.

  6. If you are using Mac OS X 10.5 or later, skip to step 9.

  7. At the Terminal prompt, type the following command, again substituting the correct path:

    sudo mdutil -E /path_to_volume and press return

  8. If prompted for a password, type your admin password, then press return. You will receive the response:

    /path_to_volume/: Volume index removed.

  9. At the Terminal prompt, type exit then press return.
  10. Quit Terminal.

Thanks to thexlab.com, their troubleshooting Mac OS X e-books, and their website for the detailed explanation of why other methods sort of work.

share|improve this answer
Note sudo asks for the current user's password – Mark Feb 16 at 8:21

An easy way to stop my car audio trying to read hidden Mac OS files is to remove them in Windows OS. Simply copy your MP3 music to the USB stick from iTunes. Swap the stick into Windows OS and select view hidden files from folder options. This will then allow you to delete every single hidden file that your trusty Mac placed on your USB stick including those pesky .trashes files. Finally a use for Windows OS!

share|improve this answer

it can't work.

no way to resolve this problem.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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