I am trying to repair permissions on my external HD. I cannot empty my trash when it is plugged in, because I get a bunch of "such file is in use". I read online that this might be resolved by repairing permissions on the drive. I am currently unable to unmount the drive because it is in use the second I restart or unplug and replug it in. I used lsof
to see what is using it but I am unable to understand this and can't seem to find a clear guide to learn what this means. The output is below:
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
mds 59 root 23r DIR 1,9 1701 5 /Volumes/SEAGATE
mds 59 root 31r DIR 1,9 1701 5 /Volumes/SEAGATE
Command
ps ax | egrep '[ /](PID|mds)'
Output
PID TT STAT TIME COMMAND
660 ?? Ss 0:12.49 /System/Library/Frameworks/CoreServices.framework/Frameworks/Metadata.framework/Support/mds
673 ?? Ss 0:08.68 /System/Library/Frameworks/CoreServices.framework/Frameworks/Metadata.framework/Versions/A/Support/mds_stores
Command
/usr/bin/sudo kill 660
Output
//new line$
Command
sudo lsof /dev/disk2s2
Output
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
mds 1599 root 11r DIR 1,8 1764 5 /Volumes/SEAGATE
In that order
If I run the bash file several times in a row I can get
PID TT STAT TIME COMMAND
1737 ?? Ss 0:00.69 /System/Library/Frameworks/CoreServices.framework/Frameworks/Metadata.framework/Support/mds
But the drive is still locked by mds
Just to show that the exception was added, here are screenshots:
Best Answer
Too fast diagnosis
Unfortunatly, from the description of your problem, this is wrong. What need to be repaired is the filesystem on your external disk
SEAGATE
.Analysis of
lsof
The output of your
lsof
command tells that the commandmds
(1st column) is actually reading your filesystem/volumes/SEAGATE
(last colume). To learn more about this fantastic command, just read the manual which is coming with MacOS X:mds
is a MacOS X server in charge of providing an access to the metadata of all your filesystems. Its most important clients areFinder
andSpotlight
.If you can't eject your external disk, this is legitimate and due to
mds
still reading it. If you nonetheless extract it, you will surely corrupt its filesystem.Free and repair the filesystem
Now that it is corrupted, here is how to fix this.
Open
System Preferences > Spotlight
selectPrivacy
window and add (+) your SEAGATE external disk to stopSpotlight
to try to index it.If
mds
is still running:You will have to kill it:
Check with
lsof
that yourSEAGATE
disk is now free:If this is OK, GOTO 4.
If killing
mds
doesn't free/Volumes/SEAGATE
then there is another process accessing this filesystem throughmds
. (This might be an anti-virus or a crapware. And this is quite another size of investigation). In this case, the fast path will be to stoplaunchd
from startingmds
.Proceed as follows:
Check that you don't have anymore
mds
process:Check with
lsof
that yourSEAGATE
disk is now free:This should be OK, GOTO 4.
Start
Disk Utility
and check your diskSEAGATE
. I suspect that some repairs will be needed. In this case repair it.Eject it, and check that you don't have any more any "file in use" error message.
Open
System Preferences > Spotlight
selectPrivacy
window and remove (-) your SEAGATE external disk to permitSpotlight
to index it.If you passed strep 3. where you had to stop
launchd
from startingmds
you will have to enable this function back (otherwise a lot of thing managing your filesystem will fail).Proceed as follows: