如何理解vmstat的IO输出?block device含义及数值无变化疑问
Hey there! Let's break down your questions about vmstat on Ubuntu step by step.
A block device is any storage device that the OS reads from and writes to in fixed-size "blocks" (usually 1KB on Ubuntu, though this can vary). It's not limited to just local physical disks—this category includes:
- Local spinning HDDs or SSDs (like
/dev/sda,/dev/nvme0n1) - LVM logical volumes, RAID arrays
- Network-attached block storage (like iSCSI targets)
- Even loop devices (used for mounting ISO files, for example)
The key point is: it's a device that interacts with the system at the block level, unlike file-level storage (like NFS shares, which are handled by the network filesystem layer instead of the block device layer).
This is super common, and usually boils down to one of these scenarios:
- Linux's page cache is doing its job: Linux automatically caches frequently accessed files in RAM to speed up operations. If the large file you copied was already cached in memory, the copy operation would happen entirely in RAM—no actual disk read/write needed. To test this, clear the cache first (you'll need sudo privileges):
Then run your copy command while monitoringsudo echo 3 > /proc/sys/vm/drop_cachesvmstatin real time (usevmstat 1to refresh every second). - You're not monitoring in real time: By default,
vmstatonly outputs a single snapshot of system stats. If you just ranvmstatonce before and after the copy, you might miss the transient IO activity. Usevmstat [interval] [count](e.g.,vmstat 1 10) to get continuous updates. - The file is on a non-block device storage: If you're copying files on an NFS/SMB share or other file-level network storage,
vmstat's block device stats won't track that activity—since those aren't block devices. For those, you'd need tools likenfsstatinstead.
vmstat's IO output First, let's look at a typical vmstat output (run vmstat 1 to get real-time data):
procs -----------memory---------- ---swap-- -----io---- -system-- ------cpu----- r b swpd free buff cache si so bi bo in cs us sy id wa st 0 0 0 789240 14520 2105600 0 0 0 0 189 521 2 1 97 0 0
Focus on the -----io---- section and the wa CPU column:
bi: Blocks received from block devices (units: blocks per second). This counts data being read from disk (or other block devices) into system memory. A consistently high value means your system is doing a lot of disk reads.bo: Blocks sent to block devices (units: blocks per second). This counts data being written from memory to disk. High values here mean heavy disk write activity.wa(under CPU): Percentage of CPU time spent waiting for I/O operations to complete. If this number is consistently above 10-15%, it's a sign that your disk subsystem is a bottleneck—your CPU is sitting idle waiting for disk operations to finish.
A quick tip: For more granular per-device IO stats, install the sysstat package and use iostat -x 1—it'll show you read/write speeds, latency, and utilization for each individual block device.
内容的提问来源于stack exchange,提问作者Joey Yi Zhao

