I'm running OS X 10.6 Server, and I want to eject my external drive so I can do some disk maintenance such as defraging it. However when I try to eject the drive it fails saying the disk is in use. I can force eject it but that could cause corruption... How can I tell which application is using the drive and holding it open?


Try sudo lsof | grep /Volumes/External, where "External" would be the name of your external drive. Are you hosting any services' data off of that drive?

  • Just some shared folders, but I know that all the clients on the network had ejected those shares and the entire server. – jamone Jul 12 '10 at 11:59
  • Doesn't always matter. Sometimes the AFP/SMB/NFS/FTP/etc processes will leave open files just because the service is running. Best bet is to try to stop the service, then eject. That would be better than using the above command along with kill -9. You can stop a service via command line by something like sudo serveradmin stop smb, then start it by sudo serveradmin start smb, where "smb" is the name of the service. sudo serveradmin list will show them all. – churnd Jul 12 '10 at 15:37

lsof - List of open files

At your command promt just type sudo lsof to see a list of open files and their location and process id so that you can kill the process.

To refine it a little bit you could use sudo lsof | grep hard drive name.

Once you have the pid sudo kill -9 pid to kill the naughty process.


Easy way, the freeware "What's Keeping Me": http://www.hamsoftengineering.com/products/wkm/wkm.html

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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