How to Analyse Disk I/O in Linux Through Command Line

Why Disk I/O

Disk I/O comprises of input/output or read/write operation within a physical disk. Disk i/o is very easy to handle and determines which device (Hard disk) is having the busiest I/o activities. It is the rate of speed of data transfer between the hard disk drive and RAM. It is used to measure the active disk I/O time. It measures the performance and thereby characterizes the storage devices like HDDs, SSDs and SAN. It continuously monitors the Read and Write operations of the disk on your system and sets threshold. You will get alerted when it hit a certain limit.


How to install iotop

Let’s check how to install iotop in Linux systems.

To install iotop on RHEL/Centos you need to enable EPL or REPOFORGE repository.

1) To install iotop on RHEL/Centos use the following command.

# yum install iotop

2) To install iotop on Debian/Ubuntu use the following command.

# sudo apt_get install iotop

3) To install iotop on openSUSE.

# zypper install iotop


Monitoring Linux Disk I/O

Basically, type top command determines the load on your server. If the output is high and not satisfactory, we go through the disk I/O activity by using iotop or iostat commands

To monitor disk I/O with iotop, use the following command.

# sudo  iotop


You will get a list of running processes along with their current disk I/O usage. The usage of iotop without any argument like above shows a list of all processes, regardless of their disk I/o activities.


Commands at runtime

1) The right and left arrows allows you to change the column while viewing iotop results.

2)The processes get sorted in reverse order when you hit ‘r’.


Monitoring Disk I/O per-process

If you want to monitor only the process that are actually doing disk I/O, try the following command.

# sudo iotop -o


The column heading gives explanation itself. But there are two things we should consider here.

1) IO – The IO column shows I/O (includes disk and swap) utilization for each process.

2) SWAPIN – The SWAPIN column shows the usage of each process.


Set alert of disk I/O activity in Linux systems

The cron job scheduling is a useful tool to run iotop for every minute to trace out the I/O activities and send alerts to an email address. For certain intervals like 1 Second iotop keeps updating the values. Cron is a background process and saves the output to a file.

The basic iotop command to monitor the Disk I/O via cron is the following.

# iotop –botqqq –iter=60


Useful flags for cron script

The ‘b flag allows you to run iotop in batch mode. It will print just one set of results.

The ‘-o’ flag will show the process that is actually doing disk I/O.

The ‘–iter=#’ option used to set the number of samples iotop returns when run. According to your requirement on the samples you can change the ‘—iter’ value.

The ‘-q’ flag used to prevent iotop from displaying headers after the first run.

The ‘t’ flag will create a timestamp to results.


Setup cron script

1) Login to your server as root and create a file.

#  /etc/cron.d/iotop

2) Write the following line  into that file

***** root  iotop –botqqq –iter=5 >> /var/log/iotop

Save the file. The cron.d entry will allow iotop to run every minute and all activity gets logged to /var/log/iotop


If you need any further help please contact our support department.