Disk Input/Output (I/O) activities, which include reading and writing, can significantly impact overall system's performance. While many system administrators focus on CPU activity when addressing performance issues, it is also essential to monitor disk activity and latency.
There are several Linux tools for monitoring disk activity, with iostat, iotop, and ioping being the most commonly used. iostat monitors the I/O of block devices, iotop observes the I/O of running processes, and ioping helps assess disk latency.
iostat, iotop and ioping can be installed and executed from the terminal.
Steps to monitor disk IO activity in Linux:
- Open the terminal.
- Install the sysstat package for your distribution.
$ sudo apt update && sudo apt install --assume-yes sysstat # Ubuntu and Debian derivatives $ sudo yum install --assumeyes sysstat # Red Hat and CentOS derivatives
- Use iostat to view I/O activity for all block devices.
$ iostat Linux 5.8.0-48-generic (host) Jumaat 09 Apr 2021 _x86_64_ (2 CPU) avg-cpu: %user %nice %system %iowait %steal %idle 0.25 0.01 0.18 0.01 0.00 99.54 Device tps kB_read/s kB_wrtn/s kB_dscd/s kB_read kB_wrtn kB_dscd loop0 0.00 0.02 0.00 0.00 1080 0 0 loop1 0.00 0.01 0.00 0.00 359 0 0 loop10 0.01 0.27 0.00 0.00 13555 0 0 loop11 0.00 0.00 0.00 0.00 14 0 0 loop2 0.00 0.02 0.00 0.00 1095 0 0 loop3 0.00 0.01 0.00 0.00 348 0 0 loop4 0.00 0.01 0.00 0.00 347 0 0 loop5 0.00 0.02 0.00 0.00 1073 0 0 loop6 0.00 0.01 0.00 0.00 350 0 0 loop7 0.01 0.28 0.00 0.00 13967 0 0 loop8 0.00 0.01 0.00 0.00 362 0 0 loop9 0.00 0.01 0.00 0.00 358 0 0 sda 2.95 16.00 95.17 0.00 800785 4762513 0 sdb 0.00 0.06 0.00 0.00 3233 12 0 sr0 0.00 0.00 0.00 0.00 2 0 0
- Use iostat to monitor I/O for a specific disk or block device at a set interval.
$ iostat /dev/sda -y 5 Linux 5.8.0-48-generic (host) Sabtu 10 Apr 2021 _x86_64_ (2 CPU) avg-cpu: %user %nice %system %iowait %steal %idle 3.67 0.00 2.73 0.00 0.00 93.60 Device tps kB_read/s kB_wrtn/s kB_dscd/s kB_read kB_wrtn kB_dscd sda 0.40 0.00 2.40 0.00 0 12 0 avg-cpu: %user %nice %system %iowait %steal %idle 4.73 0.00 2.52 0.00 0.00 92.75 Device tps kB_read/s kB_wrtn/s kB_dscd/s kB_read kB_wrtn kB_dscd sda 0.00 0.00 0.00 0.00 0 0 0 avg-cpu: %user %nice %system %iowait %steal %idle 3.70 0.00 3.28 0.00 0.00 93.02 Device tps kB_read/s kB_wrtn/s kB_dscd/s kB_read kB_wrtn kB_dscd sda 31.00 0.00 169.60 0.00 0 848 0
- Install iotop for your Linux distribution.
$ sudo apt update && sudo apt install --assume-yes iotop # Ubuntu and Debian derivatives $ sudo yum install --assumeyes iotop # Red Hat and CentOS derivatives
- Use iotop to monitor disk activity for all running processes in near real-time.
$ sudo iotop [sudo] password for user: Total DISK READ: 0.00 B/s | Total DISK WRITE: 0.00 B/s Current DISK READ: 0.00 B/s | Current DISK WRITE: 0.00 B/s TID PRIO USER DISK READ DISK WRITE SWAPIN IO> COMMAND 1 be/4 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % init splash 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] 4 be/0 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % [rcu_par_gp] 6 be/0 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % [kworker/0:0H] 9 be/0 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % [mm_percpu_wq] 10 be/4 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % [ksoftirqd/0] 11 be/4 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % [rcu_sched] 12 rt/4 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % [migration/0] 13 rt/4 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % [idle_inject/0] 14 be/4 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % [cpuhp/0] 15 be/4 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % [cpuhp/1] 16 rt/4 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % [idle_inject/1] 17 rt/4 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % [migration/1] 18 be/4 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % [ksoftirqd/1] 20 be/0 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % [kworker/1:0H-kblockd] 21 be/4 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % [kdevtmpfs] 22 be/0 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % [netns] 23 be/4 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % [rcu_tasks_kthre] 24 be/4 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % [rcu_tasks_rude_] 25 be/4 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % [rcu_tasks_trace]
- Use iotop to observe only processes with active I/O.
$ sudo iotop -o Total DISK READ: 0.00 B/s | Total DISK WRITE: 125.32 K/s Current DISK READ: 0.00 B/s | Current DISK WRITE: 148.82 K/s TID PRIO USER DISK READ DISK WRITE SWAPIN IO> COMMAND 7165 be/4 root 0.00 B/s 0.00 B/s 0.00 % 0.04 % [kworker/u256:1-events_freezable_power_] 316 be/3 root 0.00 B/s 125.32 K/s 0.00 % 0.03 % [jbd2/sda3-8]
- Install ioping for your Linux distribution.
$ sudo apt update && sudo apt install --assume-yes ioping # Ubuntu and Debian derivatives $ sudo yum install --assumeyes ioping # Red Hat and CentOS derivatives
- Utilize ioping to check disk latency.
$ sudo ioping /dev/sda 4 KiB <<< /dev/sda (block device 20 GiB): request=1 time=1.13 ms (warmup) 4 KiB <<< /dev/sda (block device 20 GiB): request=2 time=1.50 ms 4 KiB <<< /dev/sda (block device 20 GiB): request=3 time=2.49 ms 4 KiB <<< /dev/sda (block device 20 GiB): request=4 time=1.11 ms 4 KiB <<< /dev/sda (block device 20 GiB): request=5 time=807.4 us 4 KiB <<< /dev/sda (block device 20 GiB): request=6 time=2.02 ms

Author: Mohd Shakir Zakaria
Mohd Shakir Zakaria is a skilled cloud architect with a background in development, entrepreneurship, and open-source advocacy. As the founder of Simplified Guide, he helps others understand the complexities of computing, making tech concepts accessible to all.

Mohd Shakir Zakaria is a skilled cloud architect with a background in development, entrepreneurship, and open-source advocacy. As the founder of Simplified Guide, he helps others understand the complexities of computing, making tech concepts accessible to all.
Discuss the article:
Comment anonymously. Login not required.