Disk I/O is one of the common causes of poor Linux system performance. When applications perform a large number of read and write operations on the storage device, the system waits for the disk operations to complete, which affects the system performance. The top command is used to check whether the CPU is waiting for the disk operation to complete. The wa indicator indicates the percentage of time the CPU is waiting for I/O to complete. At the same time, you can use the ps command to find processes with high CPU consumption. This article describes how to use a variety of Linux commands to diagnose disk I/O performance problems. Common commands include iotop, iostat, vmstat, atop, dstat, and ioping. These commands can be used to monitor disk activity in real time and are easy to master.
iotop displays real-time disk I/O performance. Similar to the top function, IOTOP displays the list of I/O processes. Run the iotop command with the '--only or -o' option to see disk I/O activity:
# iotop --only
The above only shows the process or thread that is actually performing I/O.
The iostat command monitors system input/output statistics for devices and partitions. Monitor system I/O by observing how long the device is active (relative to its average transfer rate). Disk I/O information is available in the following ways:
# iotop -dxm
The vmstat command, which stands for virtual memory statistics, is a performance monitoring command that provides information about block IO and CPU activity in addition to providing memory. The first line of the report will contain the average I/O value since the last reboot, and subsequent lines will display real-time statistics:
# vmstat -d 1 5
atop command is a performance monitoring tool that reports all process activity on Linux system, every 10 seconds:
# atop | grep DSK
The dstat command is another handy tool for monitoring your system during performance tuning tests, benchmarking, or troubleshooting. Overcome the limitations of some other tools and add additional features for more counters and flexibility. The default reporting interval is 1 second:
# dstat --disk --io
Specific disk runs:
# dstat --disk --io -D sda
ioping is used to monitor I/O speed and latency in real time, with the ping command showing network latency. To give users an idea of how long it takes for the disk to respond to a request:
# ioping /dev/nvme0n1 -c4