Fundamentals 9 min read

What Do Linux Buffers and Cache Really Mean? A Deep Dive into Memory Metrics

This article explains the distinction between Linux Buffers and Cache, how they appear in the free command, their representation in /proc/meminfo, and demonstrates practical experiments using vmstat and dd to observe their behavior during read and write operations, concluding with clear usage guidelines.

IT Architects Alliance
IT Architects Alliance
IT Architects Alliance
What Do Linux Buffers and Cache Really Mean? A Deep Dive into Memory Metrics

Introduction

The Linux free command reports a memory column called "buffers/cache". This value is the sum of two distinct concepts: Buffers and Cache. Understanding their exact meaning is essential for interpreting system‑level performance data.

Buffers vs. Cache

Buffers : Memory used by the kernel's block I/O buffers, corresponding to the Buffers entry in /proc/meminfo. It temporarily stores raw disk blocks before they are written to the physical device.

Cache : The page cache and reclaimable slab memory, represented by the sum of Cached and SReclaimable in /proc/meminfo. It caches file data that has been read from disk and can also hold data being written to files.

Inspecting Definitions via man Pages

Running man free shows the description of the Buffers and Cache fields. The man proc page explains the /proc filesystem, which is the authoritative source for these metrics.

proc Filesystem Overview

The /proc virtual filesystem provides a live view of kernel data structures. Users can read files such as /proc/meminfo to obtain detailed memory statistics, and write to /proc/sys/vm/drop_caches to clear various caches for testing purposes.

Experimental Setup

OS: Ubuntu 18.04

CPU: 2 cores, RAM: 8 GB

Install sysstat ( apt install sysstat) for vmstat Two terminal windows connected to the same machine

Scenario 1 – Disk Write

Preparation

Clear existing caches in the first terminal:

echo 3 > /proc/sys/vm/drop_caches

Write Operation

In the second terminal, generate a 500 MB file using dd:

dd if=/dev/urandom of=/tmp/file bs=1M count=500

Observation

Run vmstat 1 in the first terminal and watch the buff, cache, bi and bo columns.

During the write, cache grows steadily while buff stays almost unchanged. I/O activity ( bo) spikes only after the cache has accumulated data, eventually matching the total 500 MB written.

Result Analysis

Cache holds the data being written to the file.

Block I/O counters increase only when the kernel flushes the cached data to disk.

Scenario 2 – Disk Write to a Raw Partition

Prerequisite: an unused block device /dev/sdb1. (Do not run on a single‑disk system.)

Preparation

echo 3 > /proc/sys/vm/drop_caches

Write Operation

dd if=/dev/urandom of=/dev/sdb1 bs=1M count=2048

Observation

Monitor vmstat in the first terminal.

Both buff and cache increase, but buff grows much faster, indicating that raw disk writes primarily use Buffers.

Scenario 3 – Disk Read

Preparation

echo 3 > /proc/sys/vm/drop_caches

Read Operation

dd if=/dev/sda1 of=/dev/null bs=1M count=1024

Observation

Watch vmstat while the read is in progress.

When bi (block reads) becomes non‑zero, cache rises continuously while buff remains stable, confirming that page cache is used for read operations.

Overall Conclusions

Buffers are used for both writing data to disk and caching data read from disk before it reaches the page cache.

Cache (page cache) stores file data for both read and write paths; it accelerates reads and can hold data awaiting write‑back.

In practice, write‑heavy workloads show rapid Buffer growth, whereas read‑heavy workloads increase Cache.

Understanding these metrics helps developers and operators tune Linux performance, interpret monitoring data correctly, and avoid misreading the "buffers/cache" column in tools like free or vmstat.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

performanceCacheMemory ManagementLinuxBuffersprocfs
IT Architects Alliance
Written by

IT Architects Alliance

Discussion and exchange on system, internet, large‑scale distributed, high‑availability, and high‑performance architectures, as well as big data, machine learning, AI, and architecture adjustments with internet technologies. Includes real‑world large‑scale architecture case studies. Open to architects who have ideas and enjoy sharing.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.