Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?

share|improve this question
add comment

3 Answers

up vote 4 down vote accepted

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?

share|improve this answer
    
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
add comment

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.

share|improve this answer
add comment

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

share|improve this answer
add comment

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.