Skip to content
KYND Dev

4 Ways I Monitor and Detect Bottlenecks in Linux Hard Drives

Linux2 min read

As a Linux user, monitoring hard drive performance is crucial for maintaining smooth system operation. Over the years, I’ve adopted four tools to monitor and detect bottlenecks in my Linux hard drives: iostat, ioping, iotop, and glances. Each tool provides unique insights into disk performance. Here’s how I use them effectively:


1. Monitoring Disk Activity with iostat

iostat is one of the first tools I turn to for an overview of disk performance. It provides metrics such as CPU usage, transactions per second (TPS), and data read/write rates.

How to Install and Run

1sudo apt install sysstat
2iostat

Sample Output

1Linux 5.4.0-200-generic (aithe209) 12/04/2024 _x86_64_ (80 CPU)
2
3avg-cpu: %user %nice %system %iowait %steal %idle
4 1.81 0.00 0.69 3.48 0.00 94.02
5
6Device tps kB_read/s kB_wrtn/s kB_dscd/s kB_read kB_wrtn kB_dscd
7sda 88.74 2814.06 423.50 0.00 5022715628 755889088 0
8nvme0n1 4.71 62.00 75.84 962.53 110653383 135366169 1717987804

Insights

  • %iowait: Time the CPU spends waiting for disk I/O. High values here suggest a potential I/O bottleneck.
  • TPS and Throughput: Look for high TPS with low throughput, which could indicate inefficient I/O patterns.
  • Disk-Specific Metrics: Focus on individual devices like sda or nvme0n1 for targeted analysis.

For a Single Disk

1iostat -m -p sda

This command gives a more focused view of a specific disk, including read/write rates in MB/s.


2. Discovering I/O Latency with ioping

ioping measures I/O latency, providing a real-time look at how fast your disks respond to requests. It’s particularly useful for spotting slow disks.

How to Install and Run

1sudo apt install ioping
2sudo ioping /dev/sda

Sample Output

14 KiB <<< /dev/sda (block device 16.4 TiB): request=1 time=31.4 ms
24 KiB <<< /dev/sda (block device 16.4 TiB): request=2 time=31.4 ms
34 KiB <<< /dev/sda (block device 16.4 TiB): request=14 time=34.1 ms (slow)
44 KiB <<< /dev/sdb (block device 16.4 TiB): request=2 time=207.1 ms (very slow)

Insights

  • Latency Variability: Requests with high latency (e.g., 207.1 ms) can indicate disk performance issues.
  • Slow vs. Fast Requests: Frequent slow requests might point to mechanical delays in HDDs or contention in SSDs.

3. Monitoring Disk Usage with iotop

Similar to top for CPU, iotop provides a real-time view of disk I/O usage by processes. It’s perfect for identifying I/O-intensive applications.

How to Install and Run

1sudo apt install iotop
2sudo iotop

What to Look For

  • Processes with High I/O Usage: These are often the culprits of bottlenecks.
  • Read/Write Speeds: Track if processes are exceeding expected disk throughput.

Why I Use It

iotop is especially useful during troubleshooting, as it directly links disk activity to specific processes, helping me optimize or debug applications.


4. Comprehensive Monitoring with glances

glances is a versatile monitoring tool that provides an overview of system performance, including CPU, memory, network, and disk I/O.

How to Install and Run

1sudo apt install glances
2glances

Sample Output

1DISK I/O R/s W/s
2sda 2814.06 423.50
3MEM [||| 5.1%] active: 56.3G
4CPU [ 0.3%] iowait: 0.0%
5SWAP [||| 4.9%]

Insights

  • Real-Time I/O: Disk read/write speeds (e.g., R/s and W/s) give immediate feedback on workload intensity.
  • CPU I/O Wait: Look for non-zero %iowait, which signals potential disk bottlenecks.
  • Memory and Caching: Ensure enough free memory to avoid swapping, which impacts disk performance.

When to Use Each Tool

  • Quick Overview: Start with iostat to identify system-wide trends.
  • Latency Checks: Use ioping to pinpoint slow disks.
  • Application-Specific Analysis: Switch to iotop to find I/O-heavy processes.
  • Comprehensive Monitoring: Finish with glances for an all-in-one view.

By combining these four tools—iostat, ioping, iotop, and glances— I can detect bottlenecks early and ensure my hard drives operate efficiently. Whether you’re troubleshooting performance issues or optimizing your system, these tools are must-haves in any Linux toolkit.