0

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?

slm
  • 7,615
  • 16
  • 56
  • 76
RajSanpui
  • 183
  • 1
  • 1
  • 9

3 Answers3

6

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.

ewwhite
  • 197,159
  • 92
  • 443
  • 809
3

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.

Pascal Schmiel
  • 1,738
  • 12
  • 17
  • 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? – RajSanpui 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. – RajSanpui Jun 25 '13 at 14:35
2
$ fuser -m /mnt/point

or

$ lsof | grep mount_point|grep -vi grep |grep -vi lsof
Luigi
  • 311
  • 1
  • 4
  • 13