Installing iostat on Ubuntu/Debian:
The iostat command is not available on Ubuntu/Debian by default. But, you can easily install the sysstat package from the official package repository of Ubuntu/Debian using the APT package manager. iostat is a part of the sysstat package as I’ve mentioned before.
First, update the APT package repository cache with the following command:
Now, install the sysstat package with the following command:
sysstat package should be installed.
Installing iostat on CentOS 7:
iostat is not available on CentOS 7 by default. But, the sysstat package is available in the official package repository of CentOS 7. So, you can easily install it with the YUM package manager.
To install sysstat with the YUM package manager, run the following command:
Now, press y and then press <Enter> to continue.
Now, press y and then press <Enter> to accept the GPG key of the CentOS 7 package repository.
sysstat should be installed.
Installing iostat on Arch Linux:
iostat is not available on Arch Linux by default. But, the sysstat package is available in the official package repository of Arch Linux. So, you can easily install it with the Pacman package manager.
To install sysstat, run the following command:
Now, press y and then press <Enter> to continue.
sysstat should be installed.
Basic Usage of iostat:
You can monitor all the storage devices and disk partitions of your computer with iostat as follows:
As you can see, iostat generated a report of read/write speeds (in kilobytes/second or kB/s) and total reads/writes (in kB) of every storage devices and partitions at that time.
In the above command, iostat prints the statistics at the instance you ran iostat only. This is good for shell scripting and automation.
If you want to see real time statistics, then you can tell iostat to update the report every n seconds (let’s say 2 seconds) interval as follows:
As you can see, iostat is updating the report every 2 seconds.
Monitoring Specific Storage Devices or Partitions with iostat:
By default, iostat monitors all the storage devices of your computer. But, you can monitor specific storage devices (such as sda, sdb etc) or specific partitions (such as sda1, sda2, sdb4 etc) with iostat as well.
For example, to monitor the storage device sda only, run iostat as follows:
Or
As you can see, only the storage device sda is monitored.
You can also monitor multiple storage devices with iostat.
For example, to monitor the storage devices sda and sdb, run iostat as follows:
Or
If you want to monitor specific partitions, then you can do so as well.
For example, let’s say, you want to monitor the partitions sda1 and sda2, then run iostat as follows:
Or
As you can see, only the partitions sda1 and sda2 are monitored.
Monitoring LVM Devices with iostat:
You can monitor the LVM devices of your computer with the -N option of iostat.
To monitor the LVM devices of your Linux machine as well, run iostat as follows:
You can also monitor specific LVM logical volume as well.
For example, to monitor the LVM logical volume centos-root (let’s say), run iostat as follows:
Changing the Units of iostat:
By default, iostat generates reports in kilobytes (kB) unit. But there are options that you can use to change the unit.
For example, to change the unit to megabytes (MB), use the -m option of iostat.
You can also change the unit to human readable with the -h option of iostat. Human readable format will automatically pick the right unit depending on the available data.
To change the unit to megabytes, run iostat as follows:
To change the unit to human readable format, run iostat as follows:
I copied as file and as you can see, the unit is now in megabytes (MB).
It changed to kilobytes (kB) as soon as the file copy is over.
Extended Display of iostat:
If you want, you can display a lot more information about disk i/o with iostat. To do that, use the -x option of iostat.
For example, to display extended information about disk i/o, run iostat as follows:
You can find what each of these fields (rrqm/s, %wrqm etc) means in the man page of iostat.
Getting Help:
If you need more information on each of the supported options of iostat and what each of the fields of iostat means, I recommend you take a look at the man page of iostat.
You can access the man page of iostat with the following command:
So, that’s how you use iostat in Linux. Thanks for reading this article.