What’s the Real Difference Between Linux Buffers and Cache?
This article explains the definitions of Linux buffers and cache, how the free command reports them, and demonstrates through experiments that buffers can cache both reads and writes while cache primarily handles page caching for file reads and writes.
Buffer and Cache Definitions
Buffer : temporary storage for raw disk blocks before writing to disk, usually small (around 20 MB); the kernel aggregates writes for optimization.
Cache : page cache for data read from files, allowing fast memory retrieval on subsequent accesses.
Although Buffer primarily caches data to be written, it can also cache data read from disk; similarly, Cache can be used for writes.
free Command
The free command shows memory usage, including Buffers and Cache as part of buff/cache. Its data comes from /proc/meminfo, which is part of the /proc virtual filesystem.
$ free -h
total used free shared buff/cache available
Mem: 1.9G 1.0G 394M 2.6M 491M 728M
Swap: 0B 0B 0BIn man proc, Buffers are temporary storage for raw disk blocks, and Cached is the in‑memory page cache.
Experiments
Write Cache
Clear caches via /proc/sys/vm/drop_caches (write 3). Run vmstat 2 in terminal 1 and perform writes in terminal 2. Observe that cache grows while buffer stays roughly constant.
Read Buffer
After clearing caches again, run vmstat 2 and read data with dd in terminal 2. Both buffer and cache increase, but Buffer grows faster, showing that disk reads are cached in Buffer.
Reading files caches data in Cache ; reading from disk caches data in Buffer .
Conclusion
Buffer can cache data both for writing to disk and for reading from disk.
Cache can serve as page cache for both reading files and writing files.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
MaGe Linux Operations
Founded in 2009, MaGe Education is a top Chinese high‑end IT training brand. Its graduates earn 12K+ RMB salaries, and the school has trained tens of thousands of students. It offers high‑pay courses in Linux cloud operations, Python full‑stack, automation, data analysis, AI, and Go high‑concurrency architecture. Thanks to quality courses and a solid reputation, it has talent partnerships with numerous internet firms.
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.
