This article is part of the following series.
- 6 performance tools you should know in Linux
- 5 Ways to Check disk size in Linux
- 4 Ways to Check Disk Partition with Examples in Linux
- How I Fixed a disk performance issue in Minutes – A Step by Step Guide to Optimize Linux System
In this blog post, I will share two primary methods to check disk IOPS (Input/Output Operations Per Second) in Linux, a critical metric for assessing the performance and health of your storage devices.
The first and most detailed method involves a command-line utility called iostat, which reports CPU and I/O statistics. The second method utilizes the sar command, another powerful tool for system monitoring and performance analysis. Both of these tools are readily available and simple to use. Let’s dive in!
Table of Contents
What are Disk IOPS in Linux?
“IOPS” is a measure of the number of read and write operations a storage device can perform per second.
It’s a crucial performance metric because it directly impacts the speed and responsiveness of any application that relies on that storage.
For instance, a high-performance database requires a storage device with high IOPS capability to process queries quickly and efficiently.
A high IOPS number signifies that a storage device can handle a large number of read and write operations in a very short amount of time.
Monitoring IOPS is also helpful for gauging the workload, health, and performance of your disk. A sudden drop in IOPS could indicate a problem with the storage system or an application. By identifying the root cause of the issue, you can take steps to resolve it and improve performance.
The total IOPS is the sum of reads per second (r/s) and writes per second (w/s).
See also: Mastering the Linux Command Line — Your Complete Free Training Guide
How to Check Disk IOPS in Linux
Here’s a step-by-step procedure to check the IOPS of your disks:
- Open a terminal window.
- List your disks: Use the
lsblkorfdisk -lcommand to list all the disks attached to your server. - Identify the target disk: Note the name of the disk you want to monitor (e.g.,
/dev/sda). - Start monitoring: Use one of the commands detailed below to begin monitoring I/O statistics.
Method 1: Checking Disk IOPS with iostat
The iostat command is the best tool for checking disk IOPS in real-time. It provides detailed statistics for all storage devices on your system and is invaluable for monitoring disk workload. This utility is part of the sysstat package.
Installation:
If you don’t have sysstat installed, you can add it with your distribution’s package manager:
- Debian/Ubuntu:
sudo apt-get install sysstat - CentOS/RHEL:
sudo yum install sysstat
iostat is a highly customizable command that provides in-depth statistics on transfer rates, read/write percentages, and more, which is particularly useful for pinpointing bottlenecks.
Basic Syntax:
iostat [options] [interval [count]]
- options: Specify the type of statistics to display (e.g.,
dfor disk,xfor extended stats). - interval: The time in seconds between each report.
- count: The total number of reports to generate. If omitted,
iostatwill run continuously until you pressCtrl+C.
Examples:
To display extended disk I/O statistics every 2 seconds for 5 reports:
iostat -xd 2 5
To monitor the IOPS for a specific device, like /dev/sda, with an interval of 3 seconds:
iostat -xd 3 /dev/sda
Example Output:
Device: rrqm/s wrqm/s r/s w/s rkB/s wkB/s avgrq-sz avgqu-sz await r_await w_await svctm %util
sda 0.00 0.00 100.00 50.00 50.00 100.00 10.00 3.00 0.00 0.00 0.00 0.00 5.00
In this example, the IOPS for device sda is r/s + w/s = 100 + 50 = 150.
Here’s a breakdown of the extended output columns:
- rrqm/s: The number of read requests merged per second.
- wrqm/s: The number of write requests merged per second.
- r/s: The number of read requests issued to the device per second.
- w/s: The number of write requests issued to the device per second.
- rkB/s: The number of kilobytes read from the device per second.
- wkB/s: The number of kilobytes written to the device per second.
- avgrq-sz: The average size (in sectors) of the requests that were issued to the device.
- avgqu-sz: The average queue length of the requests that were issued to the device.
- await: The average time (in milliseconds) for I/O requests to be served.
- svctm: The average service time (in milliseconds) for I/O requests that were issued to the device.
- %util: The percentage of CPU time during which I/O requests were issued to the device (bandwidth utilization for the device).
If you run iostat without the -x option, the IOPS value is displayed under the tps (transactions per second) column.
Method 2: Checking Disk IOPS with sar
The sar (System Activity Reporter) command is another excellent tool for monitoring system performance, including disk I/O. Like iostat, it is part of the sysstat package.
To view disk I/O statistics with sar, use the -d option:
sar -d
In the sar -d output, the tps column is equivalent to IOPS.
Example Output:
09:20:01 AM DEV tps rd_sec/s wr_sec/s avgrq-sz avgqu-sz await svctm %util
09:30:01 AM dev253-0 2.32 0.00 19.90 8.56 0.01 3.32 0.11 0.03
09:30:01 AM dev253-16 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
09:40:01 AM dev253-0 3.13 0.00 28.63 9.15 0.00 1.47 0.06 0.02
09:40:01 AM dev253-16 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
09:50:01 AM dev253-0 3.05 0.00 25.88 8.47 0.01 2.31 0.09 0.03
iostat vs. sar: Key Differences Explained
Both iostat (input/output statistics) and sar (System Activity Reporter) are part of the sysstat package and are used for performance monitoring. However, they serve different primary purposes and present data in distinct ways.
Here’s a breakdown of their main differences:
| Feature | iostat | sar |
|---|---|---|
| Primary Focus | Detailed, real-time I/O statistics for block devices and partitions. It also provides CPU utilization reports. | Comprehensive system activity reporting, covering a wide range of metrics like CPU, memory, network, I/O, and more. |
| Data Presentation | Primarily designed for real-time monitoring. When run with an interval, it shows statistics for that specific period. Without an interval, it shows the average since the last boot. | Excels at both real-time analysis and historical data reporting. It automatically collects and saves system activity logs. |
| Use Case | Ideal for troubleshooting I/O bottlenecks. It helps you see which devices are under heavy load and how they are performing at that moment. | Best for trend analysis and post-mortem troubleshooting. You can analyze system performance from a specific day or time to identify patterns or investigate past incidents. |
| Scope of Metrics | Specializes in I/O metrics like transactions per second (tps), kilobytes read/written per second, average queue length, and device utilization (%util). | Collects a very broad set of data. You can view CPU usage, memory and swap space utilization, network statistics, run queue and load averages, and I/O activity. |
| Output Format | The output is a snapshot of current or recent activity. It’s concise and focused on I/O and CPU performance. | Can display reports from log files stored in /var/log/sa/. This allows you to go back in time to review performance data. |
Summary and When to Use Each
- Use
iostatwhen: You need to get a detailed, real-time view of your disk I/O performance. It’s the go-to tool for actively diagnosing slow disk response times or identifying which storage device is becoming a bottleneck right now. - Use
sarwhen: You need to analyze system performance over time. If a server becomes slow at a particular time each day,sarallows you to review the historical data for CPU, memory, and I/O to understand what was happening during that period. Its ability to report on a wide array of system metrics makes it an essential tool for comprehensive performance analysis and capacity planning.
How to Address Disk I/O Issues in Linux
If you’re experiencing disk I/O problems, here are a few tips:
- Check Disk Health: Ensure your disks are in good condition. Damaged or worn-out disks will not perform optimally. You can use
smartmontoolsto check the health of your disks. - Proper Configuration: Verify that your disks are configured correctly to handle the expected load.
- Identify I/O-Heavy Processes with
iotop: If you suspect a specific process is causing high I/O, you can useiotop, a tool that shows you which processes are using the most I/O.
You can typically install iotop with sudo apt-get install iotop or sudo yum install iotop. Once installed, simply run iotop to see a list of processes and their I/O usage.
If you have any further questions, feel free to leave a comment below. Thanks for reading




iostat is my favorite command to check disk performance. Thanks.
The disk utilization is 100%. Does this mean that a problem there?
A disk utilization of 100% typically indicates that your storage drive is being fully used, and this can be a cause for concern depending on the context and duration.
while high disk utilization can be normal for short periods, especially during heavy tasks, consistently high usage can be indicative of a problem and should be investigated to ensure it doesn’t affect the longevity of your disk or the performance of your system.
Thanks!
I particularly appreciated the variety of tools and commands suggested in the article.
I ended up using iostat and iotop to get real-time updates on disk I/O usage by processes, and the insights I gained were invaluable in identifying resource-intensive applications.
Thanks for the sharing!
Cool. It works for me. Thanks Bro.
It works for me. Thanks.