The iotop command is top like utility for disk I/O. It watches I/O usage information output by the Linux kernel (requires v2.6.20 or later) and displays a table of current I/O usage by processes or threads on the system. This post expalins how to install and use iotop to find out what's stressing (or program names) on your hard drives under Linux operating systems.
Use the yum command to install iotop under RHEL / CentOS Linux, enter:
# yum install iotop
Loaded plugins: auto-update-debuginfo, product-id, protectbase, rhnplugin, subscription-manager Updating certificate-based repositories. Unable to read consumer identity 0 packages excluded due to repository protections Setting up Install Process Resolving Dependencies --> Running transaction check ---> Package iotop.noarch 0:0.3.2-3.el6 will be installed --> Finished Dependency Resolution Dependencies Resolved ============================================================================================================================================================================================= Package Arch Version Repository Size ============================================================================================================================================================================================= Installing: iotop noarch 0.3.2-3.el6 rhel-x86_64-server-6 49 k Transaction Summary ============================================================================================================================================================================================= Install 1 Package(s) Total download size: 49 k Installed size: 0 Is this ok [y/N]: y Downloading Packages: iotop-0.3.2-3.el6.noarch.rpm | 49 kB 00:00 Running rpm_check_debug Running Transaction Test Transaction Test Succeeded Running Transaction Installing : iotop-0.3.2-3.el6.noarch 1/1 Installed products updated. Verifying : iotop-0.3.2-3.el6.noarch 1/1 Installed: iotop.noarch 0:0.3.2-3.el6 Complete!
Debian / Ubuntu Linux user try apt-get command as follows to install the same:
$ sudo apt-get install iotop
[sudo] password for vivek: Reading package lists... Done Building dependency tree Reading state information... Done The following NEW packages will be installed: iotop 0 upgraded, 1 newly installed, 0 to remove and 12 not upgraded. Need to get 26.5 kB of archives. After this operation, 168 kB of additional disk space will be used. Get:1 http://debian.osuosl.org/debian/ squeeze/main iotop all 0.4-2+squeeze1 [26.5 kB] Fetched 26.5 kB in 1s (17.0 kB/s) Selecting previously deselected package iotop. (Reading database ... 256274 files and directories currently installed.) Unpacking iotop (from .../iotop_0.4-2+squeeze1_all.deb) ... Processing triggers for man-db ... Setting up iotop (0.4-2+squeeze1) ... Processing triggers for python-support ...
How do I use iotop command?
iotop command displays columns for the I/O bandwidth read and written by each process/thread during the sampling period. It also displays the percentage of time the thread/process spent while swapping in and while waiting on I/O. For each process, its I/O priority (class/level) is shown. In addition, the total I/O bandwidth read and written during the sampling period is displayed at the top of the interface. Type the following command to run iotop (must run as root):
$ sudo iotop
However, I recommend that you start iotop with --only option to see only processes or threads actually doing I/O, instead of showing all processes or threads (you can set this mode dynamically too see keyboard shortcut o for more info):
# iotop --only
Other supported options by iotop command:
-o, --only Only show processes or threads actually doing I/O, instead of showing all processes or threads. This can be dynamically toggled by pressing o. -b, --batch Turn on non-interactive mode. Useful for logging I/O usage over time. -n NUM, --iter=NUM Set the number of iterations before quitting (never quit by default). This is most useful in non-interactive mode. -d SEC, --delay=SEC Set the delay between iterations in seconds (1 second by default). Accepts non-integer values such as 1.1 seconds. -p PID, --pid=PID A list of processes/threads to monitor (all by default). -u USER, --user=USER A list of users to monitor (all by default) -P, --processes Only show processes. Normally iotop shows all threads. -a, --accumulated Show accumulated I/O instead of bandwidth. In this mode, iotop shows the amount of I/O processes have done since iotop started. -k, --kilobytes Use kilobytes instead of a human friendly unit. This mode is useful when scripting the batch mode of iotop. Instead of choosing the most appropriate unit iotop will dis‐ play all sizes in kilobytes. -t, --time Add a timestamp on each line (implies --batch). Each line will be prefixed by the current time. -q, --quiet suppress some lines of header (implies --batch). This option can be specified up to three times to remove header lines. -q column names are only printed on the first iteration, -qq column names are never printed, -qqq the I/O summary is never printed.
Important keyboard shortcuts for iotop command
- Hit the left and right arrow keys to change the sorting.
- Hit r to reverse the sorting order.
- Hit o only to see processes or threads actually doing I/O, instead of showing all processes or threads.
- Hit p only show processes. Normally iotop shows all threads.
- Hit a display accumulated I/O instead of bandwidth. In this mode, iotop shows the amount of I/O processes have done since iotop started.
- Ht i to change the priority of a thread or a process' thread(s) i.e. ionice.
- Hot q to quit iotop.
Check out related media
- How-to avoid sudden outburst of backup shell scripts / program disk I/O under Linux.
- How-to use iostat command to find out Linux Disk utilization.
- How-to use kSar and sar tool for identifying Linux bottlenecks for network, disk i/o, cpu and much more.
- 30 Handy Bash Shell Aliases For Linux / Unix / Mac OS X
- Top 30 Nmap Command Examples For Sys/Network Admins
- 25 PHP Security Best Practices For Sys Admins
- 20 Linux System Monitoring Tools Every SysAdmin Should Know
- 20 Linux Server Hardening Security Tips
- Linux: 20 Iptables Examples For New SysAdmins
- Top 20 OpenSSH Server Best Security Practices
- Top 20 Nginx WebServer Best Security Practices
- 20 Examples: Make Sure Unix / Linux Configuration Files Are Free From Syntax Errors
- 15 Greatest Open Source Terminal Applications Of 2012
- My 10 UNIX Command Line Mistakes
- Top 10 Open Source Web-Based Project Management Software
- Top 5 Email Client For Linux, Mac OS X, and Windows Users
- The Novice Guide To Buying A Linux Laptop