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 have a mounted partition, which I tried umounting and it's giving me an error. There is a chance that some process is accessing some files in that mounted partition.

How do I know, which process is accessing it, and which files?

Or better, another way to ask this question: How to know all the processes that are accessing a resource? Such as a file?

share|improve this question

3 Answers 3

up vote 6 down vote accepted

Run lsof /partitionname where "partitionname" is the name of the partition you're trying to unmount.

You can also use the fuser command for your more general question.

share|improve this answer
$ fuser -m /mnt/point

or

$ lsof | grep mount_point|grep -vi grep |grep -vi lsof
share|improve this answer

The tool you need is "lsof" (list open files) using this without any options shows you a list of all open resources including files, sockets and so on.

share|improve this answer
    
So you mean, going into the mounted partition and executing "lsof" works as a process explorer. Thanks. Is there any way to do the same on a single file? –  kingsmasher1 Jun 25 '13 at 14:28
    
it is not relevant where you exec it. it shows you all ressources that are open. if you want to filter out a specific one you can use lsof | grep whatever –  Pascal Schmiel Jun 25 '13 at 14:34
    
Seems like fuser suggested above helps. –  kingsmasher1 Jun 25 '13 at 14:35

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.