This post was originally published on go2linux.org on March 30, 2009. The domain is no longer mine, but I am the original author. I am republishing it here on garron.me with corrections and improvements.

Continuing with my review of performance tools, I will now introduce you to iotop, a top-like tool that shows in real time the data being written to and read from disk, as well as the average speed of those I/O operations.

If you administer servers, you need to know which processes are reading and writing to the disk so you can improve performance.

Installing it

iotop is available in the repositories of all major distributions:

# Debian / Ubuntu
sudo apt install iotop

# Fedora / RHEL / CentOS
sudo dnf install iotop

# Arch Linux
sudo pacman -S iotop

Using it

iotop [OPTIONS]

The main options are:

-o, --only Only show processes or threads actually doing I/O, instead of showing all processes. Can be toggled interactively by pressing o.

-d SEC, --delay=SEC Set the delay between iterations in seconds (default is 1). Accepts non-integer values like 1.1.

-b, --batch Non-interactive mode. Useful for logging I/O usage over time.

I like to use it with the -o switch to see only the processes that are actually writing or reading the disk. Combining it with -b gives a nice output for logging over time:

iotop -o -b

Sample output:

  PID USER      DISK READ  DISK WRITE   SWAPIN    IO    COMMAND
 2894 ggarron        0 B/s   19.26 K/s  0.00 %  0.00 % firefox
Total DISK READ: 0 B/s | Total DISK WRITE: 211.87 K/s
  PID USER      DISK READ  DISK WRITE   SWAPIN    IO    COMMAND
  571 root           0 B/s  211.87 K/s  0.00 %  2.01 % [kjournald]
Total DISK READ: 0 B/s | Total DISK WRITE: 0 B/s