Search code examples
linuxredhatlsof

RHEL Linux: Discover what processes are using a specific disk


I need to discover what processes are using a specific disk. This is a multipath disk but I cannot find a way of setting up a way to record to a log file what processes are running when a particular disk is being read or written to. I know the major:minor block IDs using lsblk then lsof but these only show current activity and as there currently is none, I cannot find out the process that uses this disk.

Any ideas anyone?


Solution

  • You can use lsof. Lsof revision lists on its standard output file information about files opened by processes. for example this command below will list all files that are opened for writing:

    lsof | grep -e "[[:digit:]]\+w > mylogfile.log"
    

    you can redirect the command to log file if you which with the redirect operator >