iotop

On this page 7

iotop is an interactive, top-like Linux monitoring utility that displays per-process and per-thread disk I/O in real time, showing how many bytes each task reads and writes per second and how much of its time it spends waiting on I/O. Where iostat reports load per device, iotop answers the more practical question an administrator asks during an incident: which process is hammering the disk right now.

The tool reads kernel task I/O accounting data, refreshes the display every second by default and sorts tasks by activity. It typically requires root privileges or the CAP_NET_ADMIN capability, because the data comes from a privileged kernel interface rather than from ordinary files in procfs.

How iotop collects per-task I/O data

iotop obtains its numbers from the taskstats interface, a Netlink-based channel through which the kernel exports per-task accounting. The kernel must be built with CONFIG_TASK_IO_ACCOUNTING, CONFIG_TASK_DELAY_ACCT and CONFIG_TASKSTATS, which mainstream distribution kernels enable. On each refresh, iotop queries every task, subtracts the previous counters and divides by the interval to produce rates.

Two different kinds of measurement appear on screen. Byte counters record how much data a task caused to be read from or written to the storage layer. Delay accounting records how long a task waited for block I/O completion and for swap-in, which iotop expresses as a percentage of wall-clock time. Since kernel 5.14, delay accounting is disabled by default and must be enabled with the delayacct boot parameter or the kernel.task_delayacct sysctl; otherwise the IO and SWAPIN columns stay empty or show a warning.

The following table lists the kernel prerequisites and what happens when each one is missing.

Kernel featureProvidesSymptom if missing
CONFIG_TASKSTATSNetlink channel for task statisticsiotop refuses to start
CONFIG_TASK_IO_ACCOUNTINGPer-task read and write byte countersBandwidth columns stay at zero
CONFIG_TASK_DELAY_ACCTBlock I/O and swap-in wait timesIO and SWAPIN columns unavailable
kernel.task_delayacct = 1Runtime activation of delay accountingWarning about disabled delay accounting
Kernel features required by iotop

Reading the iotop display

The iotop screen has a summary header and a task list. The header shows Total DISK READ and Total DISK WRITE, the sum of what tasks requested, and Actual DISK READ and Actual DISK WRITE, the traffic that the block layer actually sent to devices. The two pairs differ because of the page cache and write-back: a task can write many megabytes into cache that the kernel flushes later, or a single flush can combine writes from many tasks.

The task list contains one row per thread or process, with the columns described below.

ColumnMeaningInterpretation tip
TID or PIDThread or process identifierPress p to switch to processes
PRIOI/O scheduling class and levelbe/4 is the default best-effort level
DISK READRead rate requested by the taskCache hits do not count as disk reads
DISK WRITEWrite rate attributed to the taskOften charged at write-back time
SWAPINShare of time waiting for swap-inHigh values signal memory pressure
IOShare of time waiting for block I/ONear 99% means the task is I/O bound
COMMANDCommand line of the taskKernel threads appear in brackets
Columns in the iotop task list

Interactive keys control the view: o shows only tasks currently doing I/O, a switches to accumulated totals since iotop started, p groups threads into processes, the left and right arrows change the sort column, and i changes the I/O priority of a selected task through the same mechanism as ionice.

Useful command-line options

iotop also runs non-interactively, which makes it suitable for scripts, cron jobs and incident logs. Batch mode prints plain text that can be redirected to a file, and combining it with a fixed iteration count produces a short, reproducible snapshot.

OptionEffectTypical use
-oShow only tasks doing I/OReduce noise on busy servers
-bBatch mode without cursesLogging to a file
-n NUMStop after NUM iterationsBounded snapshots in scripts
-d SECSet the refresh delaySmooth out short bursts
-aShow accumulated I/OFind the largest total writer
-PShow processes, not threadsReadable output for multithreaded daemons
-tPrefix each line with a timestampCorrelating with application logs
Common iotop options

A typical capture during an incident is sudo iotop -botqqq -d 5 -n 12, which records one minute of activity in five-second steps, shows only active tasks with timestamps and suppresses repeated headers.

iotop is one instrument among several in the Linux monitoring toolbox, and each answers a different question. The decisive distinction is between per-device metrics, which show whether storage is saturated, and per-task metrics, which show who is responsible.

ToolGranularityMain question answered
iotopPer process or threadWho is generating disk I/O
iostatPer block deviceIs the device saturated or slow
top and htopPer process, CPU and memoryWho consumes CPU and memory
vmstatSystem-wideIs the system waiting on I/O or swap
pidstat -dPer processSame question with sar-style history
Pressure stall informationSystem or cgroupHow much work stalls on I/O
How iotop relates to neighboring tools

A sound workflow starts broad and narrows down: vmstat or pressure stall information reveals high I/O wait, iostat identifies the saturated device, and iotop then names the responsible process. Once the process is known, lsof shows which files it has open and strace shows the system calls behind the traffic.

Limitations and common mistakes

iotop numbers are accurate within their model, but the model has blind spots that cause frequent misdiagnosis. Most problems come from the gap between what a task requests and what reaches the device.

  • Write-back attribution: buffered writes are often flushed by kernel worker threads, so the real writer may look idle while a kworker thread appears busy.
  • Page cache hits are invisible, so a process reading heavily from cached files shows little or no disk read.
  • Network and FUSE file systems may not account traffic as block I/O, which hides NFS or SSHFS activity.
  • Short-lived processes can start and exit between refreshes and never appear on screen.
  • Containers share the host kernel, so iotop on the host sees container tasks, while iotop inside an unprivileged container usually cannot run.
  • Overhead grows with the number of threads, because iotop queries each task on every refresh.

Two implementations exist: the original Python iotop and a newer C implementation, often packaged as iotop-c, which is lighter and handles disabled delay accounting more gracefully. For historical analysis, neither replaces a recorder such as sar or an eBPF tool like biotop, because iotop keeps no history once it exits.

In everyday language

Think of a computer disk as a single checkout lane in a busy store. When the line gets long, everything slows down. The manager cannot tell who is holding things up just by looking at the lane. iotop is like a camera above the checkout. It labels every customer and shows how much each one puts on the belt.

The key takeaway is simple. When a Linux machine feels slow because the disk is overloaded, iotop shows which program is responsible. The administrator can then pause it, slow it down or fix it instead of guessing.

Seen in the real world

An operations engineer at an online retailer receives alerts that the product database responds in two seconds instead of the usual fifty milliseconds. vmstat shows I/O wait above 40 percent, and iostat reports the data volume at nearly full utilization, yet the database itself is not running unusual queries.

The engineer runs sudo iotop -oP and sees a log compression job writing about 180 MB/s with an IO wait of 95 percent, while the database processes sit in the IO column waiting their turn. The nightly job had been moved to business hours by a configuration change.

The engineer lowers the job priority with ionice -c3, which places it in the idle I/O class, and database latency returns to normal within a minute. The team then reschedules the job and adds a cgroup I/O limit, so the root cause was found in minutes rather than through hours of query tuning.