← Home

Learning note

Why /var Deserves Its Own Partition

I recently had a practical lesson as to why it is advisable to place the /𝘷𝘢𝘳 directory on its own disk partition on production Linux servers.

I had a server where the root filesystem was 38 GB and sitting at 99% usage. My services had also started feeling sluggish. On investigating I found this ⤵️

/𝘷𝘢𝘳 -> 25 GB
/𝘷𝘢𝘳/𝘭𝘪𝘣 → 25 GB
/𝘷𝘢𝘳/𝘭𝘪𝘣/𝘤𝘰𝘯𝘵𝘢𝘪𝘯𝘦𝘳𝘥 → 24 GB

Most of that was container image and layer data. After cleaning up unused images and build cache, I brought the filesystem down to about 54% usage ✅

Now, the interesting part was not the cleanup itself but connecting this incident to something I had previously learned about Linux partitioning 👉

/𝘷𝘢𝘳 contains data that tends to change and grow: logs, caches, application state, package data, container data, and so on. So if /𝗏𝖺𝗋 shares the root filesystem, something growing rapidly under /𝗏𝖺𝗋 can eventually crowd out everything else that filesystem needs such as /𝘶𝘴𝘳, /𝘦𝘵𝘤, /𝘩𝘰𝘮𝘦, etc.

So, keeping /𝗏𝖺𝗋 on a separate partition from / gives it its own capacity boundary.🚧

⚠️ It is worth being precise here though: partitioning /𝗏𝖺𝗋 does not stop it from filling up. Services writing there can still hit ENOSPC ("No space left on device"). The benefit here is isolation.

This was one of those Linux concepts that made much more sense after seeing it happen on a real server.