How to Monitor Disk IO in a Linux System

Disk monitoring is a critical task for maintaining optimal performance in Linux systems. The disk I/O subsystem is often the slowest component and can become a bottleneck that affects overall system performance. When processes wait for I/O operations to complete, it directly impacts system responsiveness.

Effective disk monitoring helps identify which processes are causing I/O bottlenecks and determines the root cause of performance issues. In this article, we'll explore essential tools like iostat and iotop to monitor disk I/O performance in Linux systems.

Installing iotop

The iotop tool is available in most Linux distribution repositories and can be easily installed using the system's package manager.

Fedora/RHEL/CentOS 8

sudo dnf install iotop

Debian/Ubuntu

sudo apt install iotop

RHEL/CentOS 6/7

sudo yum install iotop

Using iotop to Monitor Disk I/O

The iotop command provides real-time monitoring of disk I/O usage by individual processes and threads. Run it without parameters to see current I/O activity:

sudo iotop
Total DISK READ :      18.27 K/s   |  Total DISK WRITE :       0.00 B/s
Actual DISK READ:      18.27 K/s   |  Actual DISK WRITE:      14.61 K/s
    TID  PRIO  USER     DISK READ   DISK WRITE   SWAPIN     IO%     COMMAND                                                                                                
    509  be/3  root        0.00 B/s    0.00 B/s     0.00 %   3.91 %   [jbd2/dm-0-8]
 247269  be/4  root        0.00 B/s    0.00 B/s     0.00 %   0.21 %   [kworker/0:2]
   2507  be/4  user       18.27 K/s    0.00 B/s     3.57 %   0.00 %   gnome-terminal
      1  be/4  root        0.00 B/s    0.00 B/s     0.00 %   0.00 %   systemd --switched-root
      2  be/4  root        0.00 B/s    0.00 B/s     0.00 %   0.00 %   [kthreadd]
      3  be/0  root        0.00 B/s    0.00 B/s     0.00 %   0.00 %   [rcu_gp]

The output shows Total DISK READ/WRITE rates at the top, followed by per-process statistics including Thread ID (TID), I/O priority (PRIO), user, read/write rates, swap activity, and I/O percentage.

Installing iostat

The iostat command is part of the sysstat package, which provides comprehensive system monitoring tools.

Fedora/RHEL/CentOS 8

sudo dnf install sysstat

Debian/Ubuntu

sudo apt install sysstat

RHEL/CentOS 6/7

sudo yum install sysstat

Using iostat to Monitor Disk I/O

The iostat command displays both CPU and disk I/O statistics. Run it without arguments to see system-wide statistics:

iostat
Linux 4.19.32-1-MANJARO        Thursday 18 April 2022  _x86_64_    (8 CPU)

avg-cpu:  %user   %nice  %system  %iowait   %steal   %idle
          29.45    0.02    16.47     0.12     0.00    53.94

Device            tps    kB_read/s  kB_wrtn/s  kB_dscd/s   kB_read   kB_wrtn  kB_dscd
nvme0n1          6.68      126.95     124.97       0.00  58420014  57507206        0
sda              0.18        6.77      80.24       0.00   3115036  36924764        0
loop0            0.00        0.00       0.00       0.00      2160         0        0
scd0             0.00        0.00       0.00       0.00         1         0        0
zram0            7.74        9.36      21.58       0.00   2924188   6738944        0

Key Metrics

Metric Description
%iowait Percentage of time CPU was idle waiting for I/O
tps Transfers per second (IOPS)
kB_read/s Kilobytes read per second
kB_wrtn/s Kilobytes written per second

Advanced Options

Both tools offer additional options for detailed monitoring:

# Show only processes with I/O activity
sudo iotop -o

# Display I/O stats every 2 seconds
iostat -x 2

# Monitor specific device
iostat -x nvme0n1 2

Conclusion

Effective disk I/O monitoring using iostat and iotop is essential for maintaining system performance. These tools help identify I/O bottlenecks, monitor per-process disk usage, and provide crucial metrics for system optimization. Regular monitoring prevents performance degradation and ensures optimal system responsiveness.

Updated on: 2026-03-17T09:01:39+05:30

747 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements