I have a thumb drive that I use frequently, which results in a lot of the ._* files being created, which I periodically delete by executing something like find /Volumes/Secure -name '._*' -exec rm -vf {} \;, and I've never had that ruin anything before. However, it looks like something may have gotten broken during this last execution.

Heres the console output of the find/rm command:

[Tue Aug 14 09:39:12]{1:126}jdoe@MacBook-Pro:/Volumes/Secure(✓)$ find -d . -name '._*'
[Tue Aug 14 09:39:18]{1:127}jdoe@MacBook-Pro:/Volumes/Secure(✓)$ find -d . -name '._*' -exec rm -vf {} \;
find: .: Invalid argument

(Not sure, but maybe it has something to do with the {} not being in quotes? I can't remember if I used quotes in the past)

When I mount the volume, I can see the contents just fine as long as I'm not referencing the content using a relative path while I'm in the mounted volume (PWD).

Here's an example of what I mean. You can see that I can list the contents of /Volumes/Secure just fine. But if I cd to it, then try to list the content of the current directory, it doesn't work:

[Tue Aug 14 09:46:02]{1:193}jdoe@MacBook-Pro:/Volumes(✓)$ df /Volumes/Secure
Filesystem   512-blocks    Used Available Capacity iused ifree %iused  Mounted on
/dev/disk4s1   35372096 1566528  33805568     5%       0     0  100%   /Volumes/Secure
[Tue Aug 14 09:46:06]{1:194}jdoe@MacBook-Pro:/Volumes(✓)$ ls /Volumes/Secure
chemdocs             credentials          data.tar.gz.enc      scripts              test                 test-data            test-data.tar.gz.enc tor
[Tue Aug 14 09:46:09]{1:195}jdoe@MacBook-Pro:/Volumes(✓)$ cd /Volumes/Secure
[Tue Aug 14 09:46:11]{1:196}jdoe@MacBook-Pro:/Volumes/Secure(✓)$ ls

Then, just to make this a little more confusing and frustrating, it seems to be intermittent...

[Tue Aug 14 09:46:09]{1:195}jdoe@MacBook-Pro:/Volumes(✓)$ cd /Volumes/Secure
[Tue Aug 14 09:46:11]{1:196}jdoe@MacBook-Pro:/Volumes/Secure(✓)$ ls
[Tue Aug 14 09:52:28]{1:27}jdoe@MacBook-Pro:/Volumes/Secure(✓)$ ls .
[Tue Aug 14 09:52:30]{1:28}jdoe@MacBook-Pro:/Volumes/Secure(✓)$ ls -alrth .
total 30240
drwxrwxrwx  1 jdoe  staff    16K Jun 18 18:20 .Spotlight-V100
drwxrwxrwx  1 jdoe  staff    16K Jul  3 12:10 test-data
drwxrwxrwx  1 jdoe  staff    16K Jul  3 12:10 .info
drwxrwxrwx  1 jdoe  staff    16K Aug 11 03:41 .Trashes
drwxrwxrwx  1 jdoe  staff    16K Aug 11 03:41 .TemporaryItems
drwxrwxrwx@ 1 jdoe  staff    16K Aug 13 19:22 .
drwxrwxrwx  1 jdoe  staff    16K Aug 14 09:43 .fseventsd
drwxrwxrwt@ 7 root     admin   238B Aug 14 09:43 ..
[Tue Aug 14 09:52:32]{1:29}jdoe@MacBook-Pro:/Volumes/Secure(✓)$ ls -alrth ./
ls: ./: Invalid argument
[Tue Aug 14 09:52:34]{1:30}jdoe@MacBook-Pro:/Volumes/Secure(0)$ ls -alrth .
ls: .: Invalid argument
[Tue Aug 14 09:52:36]{1:31}jdoe@MacBook-Pro:/Volumes/Secure(0)$ ls -alrth .
ls: .: Invalid argument
[Tue Aug 14 09:52:37]{1:32}jdoe@MacBook-Pro:/Volumes/Secure(0)$ ls

(Here's a gist with some extra console output)

I've tried unmounting and remounting with no success.

Any input would be appreciated, thank you!


Update I just noticed something else thats rather interesting... These problems I showed above are all exclusive to the CLI. I can open the mounted drive in Finder and explore it just fine.. Odd.

  • The checkmark and the parenthesis are problematic in filenames. The permissions on and in your home folder are to permissive. – fd0 Aug 14 '18 at 17:35
  • Did you extract your USB key after an unmount failed? – dan Aug 15 '18 at 5:00

The symptoms you describe are the signs of a corupted filesystem, which is the usual fate of frequently used USB key.

Make a backup of your USB key, and run an fsck or Disk Utility on your file-system.

I even advise you to completely check it with:

• full backup,

• full secure erase with one pass of 0 (to be sure to write on all blocks),

• make a new FS,

• recover from backup.

Your find doesn't cause any trouble, since -exec argument isn't evaluated by a shell, you dont have to protect it against evaluation.

  • Can you give some specifics as to what exactly I should execute with fsck? I tried to diskutil repairVolume /dev/disk4s1 with no success, as well as a few other things – Justin Aug 14 '18 at 23:31
  • 2
    The -exec option of find does not run the command using the shell, so there is no need to worry about odd filenames. In any case, if you use "{}", the shell will strip the quotes anyway, and find will not see them – so using quotes does no harm. If you run the find command from some unusual shell, on the other hand, you may need quotes to stop that shell from doing funny things with the braces. – Harald Hanche-Olsen Aug 15 '18 at 15:16
  • I updated the original post with some extra info. I noticed that these problems only occur via shell.. I can browse the volume just fine via OSX Finder – Justin Aug 16 '18 at 16:48
  • Next important step: what's the result of the Disk Utility check? – dan Aug 17 '18 at 9:12

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .