Find out what processes are writing to hard drive

Iotop is a good tool for what you want. It also allows one to display the accumulated amount of I/O on any of the DISK READ, DISK WRITE, SWAPIN, and IO (overall percentage). This is through a nifty interface:

  • You just press a on the keyboard, and it will sort the hungriest processes on top.
  • Reversing the order, you just press r.
  • If you want to sort by other colums, you just press the left/right key.

Like top, the presentation is rather busy. Another thing is that it doesn't have the myriad options that top has (e.g. I can't chose to hide any of the columns I'm uninterested in), but the tool is more than good enough for its specific purpose.


You can use lsof (man lsof). The following will return a list of all files that are open for writing:

lsof | grep -e "[[:digit:]]\+w"

Especially for low disk activity, it is necessary to use iotop in batch mode, to prevent short access lines from disappearing quickly. The answer by How do I log file system read/writes by filename in Linux? shows how to do this.

So far iotop is the best overall solution. The following command gives you a real-time output of all the processes using the disk.

iotop -bktoqqq -d .5

where: -b     is batch mode
       -k     is kilobytes/s
       -t     adds timestamp
       -o     only show processes or threads actually doing I/O
       -qqq   removes output headers
       -d .5  updates every .5 seconds

Once you have the process id, you can also find the files with

 lsof -p $PID

Tags:

Linux

Io

Process