Iotop tool is a free open source free tool that monitor Disk Input/Output (IO) usage in Linux. Its helps system administrator to find a specific process that consumes more disk usage and helps in performance analysis.
Iotop tool is supported from 2.6.20 kernel. This tutorial explains how to install and use iotop in linux.
Prerequisites
Iotop installation requires below the minimum version of python and kernel.
Python >= 2.7
Linux kernel ≥ 2.6.20
Install iotop on Linux
Let's check how to install iotop on CentOS, Ubuntu, Fedora, Debian and Linux Mint.
On Ubuntu, Debian and Linux Mint
#sudo apt-get install iotop
On CentOS, Fedora and RHEL
#sudo yum -y install iotop or #sudo dnf install iotop
Another option would be by installing from source by downloading the gzipped or bzipped file and extract it. Then install using the 'setup.py' file. Iotop is written in Python, it is a prerequisite for iotop installation.
Use the following commands to extract and install iotop:
# tar -xjvf iotop-0.4.4.tar.bz2 # cd iotop-0.4.4/ # ./setup.py install
iotop Usage
The iotop command must be run as root user. As normal user, when you run this command, the following error appears:
$ iotop Netlink error: Operation not permitted (1) iotop requires root or the NET_ADMIN capability.
By default, iotop is an interactive command like top command.
Sample output:
Total DISK READ : 0.00 B/s | Total DISK WRITE : 0.00 B/s Actual DISK READ: 0.00 B/s | Actual 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 % systemd --switched-root --system --deserialize 17 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-kblockd] 8 be/0 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % [mm_percpu_wq] 9 be/4 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % [ksoftirqd/0] 10 be/4 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % [rcu_sched] 11 rt/4 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % [migration/0] 12 rt/4 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % [watchdog/0] 13 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 % [kdevtmpfs] 16 be/0 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % [netns] 17 be/4 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % [kauditd] 18 be/4 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % [khungtaskd] 19 be/4 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % [oom_reaper] 20 be/0 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % [writeback] 21 be/4 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % [kcompactd0] 22 be/5 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % [ksmd] 23 be/7 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % [khugepaged] 24 be/0 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % [crypto]
In this output, at the very top, the first line is divided into two columns.
The first column shows the total DISK READ
and the second column shows total DISK WRITE
per second.
The following lines correspond to each process performing IO operation. It lists the process ID, user ownership, disk read, disk write, process name,swapin (swap usage of each process) for each process in the system.
If you want to list only active processes, which are actually performing any disk I/O operation, press o while iotop is running (to toggle), or alternatively, run iotop with -o
option (iotop -o).
Total DISK READ : 0.00 B/s | Total DISK WRITE : 3.97 K/s Actual DISK READ: 0.00 B/s | Actual DISK WRITE: 59.50 K/s TID PRIO USER DISK READ DISK WRITE SWAPIN IO> COMMAND 1240 be/4 root 0.00 B/s 0.00 B/s 0.00 % 0.02 % rsyslogd -n [rs:main Q:Reg] 400 be/3 root 0.00 B/s 0.00 B/s 0.00 % 0.01 % [jbd2/sda-8] 1236 be/4 root 0.00 B/s 3.97 K/s 0.00 % 0.00 % rsyslogd -n [in:imjournal]
You can quit from iotop like top by pressing q
.
Following output is when running any io intense process, such as iozone.
Total DISK READ: 123.96 K/s | Total DISK WRITE: 14.16 M/s TID PRIO USER DISK READ DISK WRITE SWAPIN IO> COMMAND 468 be/3 root 0.00 B/s 104.59 K/s 0.00 % 56.66 % [jbd2/sda8-8] 7083 be/4 root 0.00 B/s 13.80 M/s 0.00 % 36.45 % ./iozone -a 5568 be/4 raghu 123.96 K/s 0.00 B/s 0.00 % 0.00 % totem /home/raghu/Downloads/01 - Harjinder Singh - Mere Ram Rai.mp3
Iotop Options
As stated above, the -o
option lists the processes actually performing disk I/O. The -b
option runs iotop in non-interactive, batch mode. It can be used for logging purposes.
The -n
options tells the number of iterations to be performed for batch mode:
# iotop -b -n1 Total DISK READ: 0.00 B/s | Total 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 2 be/4 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % [kthreadd] 3 be/4 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % [ksoftirqd/0] 2052 be/4 rtkit 0.00 B/s 0.00 B/s 0.00 % 0.00 % rtkit-daemon 2053 be/4 rtkit 0.00 B/s 0.00 B/s 0.00 % 0.00 % rtkit-daemon 6 rt/4 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % [migration/0] 7 rt/4 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % [watchdog/0] 8 rt/4 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % [migration/1] 2057 be/4 raghu 0.00 B/s 0.00 B/s 0.00 % 0.00 % gconfd-2 10 be/4 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % [ksoftirqd/1] 11 rt/4 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % [watchdog/1] ---Output Truncated---
The -u
option shows processes for a particular user.
# iotop -u raghu Total DISK READ: 0.00 B/s | Total DISK WRITE: 0.00 B/s TID PRIO USER DISK READ DISK WRITE SWAPIN IO> COMMAND 2057 be/4 raghu 0.00 B/s 0.00 B/s 0.00 % 0.00 % gconfd-2 2081 be/4 raghu 0.00 B/s 0.00 B/s 0.00 % 0.00 % gvfs-afc-volume-monitor 2082 be/4 raghu 0.00 B/s 0.00 B/s 0.00 % 0.00 % caja 2139 be/4 raghu 0.00 B/s 0.00 B/s 0.00 % 0.00 % clock-applet 2084 be/4 raghu 0.00 B/s 0.00 B/s 0.00 % 0.00 % matecomponent-activation-server --ac-activate --ior-output-fd=18 2087 be/4 raghu 0.00 B/s 0.00 B/s 0.00 % 0.00 % mate-bluetooth-applet 2088 be/4 raghu 0.00 B/s 0.00 B/s 0.00 % 0.00 % mate-volume-control-applet 7247 be/4 raghu 0.00 B/s 0.00 B/s 0.00 % 0.00 % chromium-browser --disable-new-tab-first-run --enable-user-scripts 2055 be/4 raghu 0.00 B/s 0.00 B/s 0.00 % 0.00 % gconf-helper
-d
option sets the delay between iterations.
# iotop -d 3
Finally, the --version
option prints the version number for iotop.
# iotop --version iotop 0.4.4
Iotop keyword shortcuts
Lets check some useful keyword shortcuts for using iotop.
Move left or right arrow key to change the sorting.
-h :- option to see information of usage.
-r :- option to reverse the sorting order.
-o :- option to check processes or thread.
-b :- option to Turn On non-interactive mode to enable logging I/O usage.
-p :- PID to list all processes/threads to monitor.
-u :- USER option to list all the users to monitor.
-P :- option to list only processes. Normally iotop displays all threads.
-a :- option to check accumulated I/O instead of bandwidth.
Conclusion
Iotop is very helpful for performance analysis when system using high disk IO or high swap usage. If you have any questions or feedback, feel free to leave a comment.