Mastering Disk I/O: Types, Metrics, and Linux Monitoring Tools
This article explains what disks are, compares mechanical HDDs and SSDs, outlines disk classification by interface and architecture, defines key I/O performance metrics such as IOPS, throughput, utilization, and latency, and introduces Linux tools like iostat, iotop, and sar for monitoring and analysis.
What is a Disk
A disk is a persistent storage device. Based on the storage medium, disks are commonly divided into two categories: mechanical disks and solid‑state disks.
Mechanical Disk
Also known as Hard Disk Drive (HDD), a mechanical disk consists of platters and read/write heads. Data is stored in concentric tracks on the platters. Before reading or writing, the head must move to the correct track, which makes random I/O slower than sequential I/O.
Solid‑State Disk
Solid‑State Disk (SSD) is built from electronic components and does not require track seeking, so both sequential and random I/O perform much better than on mechanical disks.
Mechanical vs. Solid‑State Disks
For both types, random I/O is significantly slower than sequential I/O. Mechanical disks suffer from head‑seeking and platter rotation overhead, while SSDs incur erase‑before‑write penalties and garbage collection during random writes.
Mechanical disks have a minimum write unit of a sector, typically 512 bytes.
SSDs have a minimum write unit of a page, usually 4 KB or 8 KB.
Linux filesystems combine consecutive sectors or pages into logical blocks (commonly 4 KB) to improve efficiency.
Disk Classification by Interface
Disks can also be classified by interface, such as IDE, SCSI, SAS, SATA, and Fibre Channel. Different interfaces assign different device name prefixes (e.g.,
hdfor IDE,
sdfor SCSI/SATA).
Disk Architecture
When attached to a server, disks can be used as independent devices with partitions (e.g.,
/dev/sda1,
/dev/sda2) or combined into logical volumes such as RAID arrays (RAID0, RAID1, RAID5, RAID10) for performance and reliability. They can also be aggregated into network storage clusters accessed via NFS, SMB, iSCSI, etc.
In Linux, disks are block devices identified by major and minor numbers; the major number denotes the device type, while the minor number distinguishes multiple devices of the same type.
What is Disk I/O
Disk I/O refers to read and write operations between the computer system and storage devices. Data must be loaded from disk into memory before execution; the CPU issues read/write requests, and the operating system handles data transfer.
When a program accesses files, the OS provides system calls to open and read the data, similar to opening a book before reading its contents. The CPU may continue executing other instructions while waiting for I/O completion.
Note 1: When the CPU waits for disk operations, its utilization drops because it is idle, highlighting the impact of I/O on CPU performance. Note 2: Memory acts as a bridge between CPU and disk; programs load into memory, the CPU processes data, and results may be written back to disk.
Disk Performance Metrics
The common metrics for evaluating disk performance are IOPS, throughput, utilization, saturation, and response time.
IOPS – Input/Output Operations Per Second, indicating how many I/O requests a disk can handle.
Throughput – Amount of data transferred per second; measured by large sequential reads/writes.
Response Time – Time from issuing an I/O request to receiving the response.
Utilization – Percentage of time the disk is handling I/O; high values (e.g., >80%) may indicate a bottleneck.
Saturation – Degree to which the disk is busy; at 100% the disk cannot accept new I/O.
When analyzing these metrics, consider the read/write ratio, I/O type (random vs. sequential), and request size. For example, IOPS is more relevant for databases with many small random operations, while throughput matters for media files with large sequential transfers.
Observing Disk I/O
To monitor disk I/O, several Linux tools are commonly used.
4.1 Observe Disk Usage with iostat
iostat(part of the
sysstatpackage) reports disk activity statistics and CPU usage.
<code># iostat belongs to the sysstat package. Install it with:
yum install sysstat -y</code> <code>-c: display only CPU utilization
-d: display only disk I/O
-k: show output in KB/s
-t: include timestamps
-m: display in MB/s
-p: show per‑device statistics
-V: display version</code>Key fields in
iostatoutput include:
%util– Disk I/O utilization
r/s + w/s– IOPS
rkB/s + wkB/s– Throughput
r_await / w_await– Response time
4.2 Observe Process I/O with iotop
iotoplists processes sorted by I/O usage, similar to
top.
<code># Install iotop
yum -y install iotop</code> <code># iotop options
--version # show version
-h, --help # show help
-o, --only # show only processes actually doing I/O
-b, --batch # non‑interactive mode
-n NUM, --iter=NUM # number of iterations
-d SEC, --delay=SEC# delay between updates
-p PID, --pid=PID # monitor specific PID
-u USER, --user=USER # monitor processes of a user
-P, --processes # show processes (default shows threads)
-a, --accumulated # show accumulated I/O per thread
-k, --kilobytes # display in KB
-t, --time # prepend timestamp
-q, --quiet # suppress header lines</code> <code>$ iotop
Total DISK READ : 0.00 B/s | Total DISK WRITE : 7.85 K/s
Actual DISK READ: 0.00 B/s | Actual DISK WRITE: 0.00 B/s
TID PRIO USER DISK READ DISK WRITE SWAPIN %IO COMMAND
15055 be/3 root 0.00 B/s 7.85 K/s 0.00 % 0.00 % systemd-journald</code>4.3 Additional I/O Commands
sar can record historical I/O statistics. Example command:
<code># sar -d -p 1 2
# Output includes tps, rd_sec/s, wr_sec/s, avgrq‑sz, avgqu‑sz, await, svctm, %util</code>To view saved logs:
<code># sar -d -p -f /var/log/sa/sa16</code>Summary
This article covered disk types, Linux I/O concepts, performance metrics, and monitoring tools. IOPS, throughput, utilization, saturation, and response time are essential for evaluating disk performance. Tools like
iostatand
iotopprovide real‑time insights, while
saroffers historical analysis. Effective analysis requires correlating metrics with workload characteristics such as read/write ratio, I/O type, and request size.
Raymond Ops
Linux ops automation, cloud-native, Kubernetes, SRE, DevOps, Python, Golang and related tech discussions.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.