The /tmp that ate our deployment

💥 AI Pitfalls 2026-06-26 · Updated 2026-10-18 2 min read

Deployment failed with 'No space left on device' while df showed room. /tmp is not a disk — it is an 838MB tmpfs, and filling it breaks shells and cron too.

📜 Table of Contents

📖 Keep reading

The /tmp that ate our deployment

df -h / showed plenty free; /tmp was 100% of 838MB. /tmp is a tmpfs, a filesystem in memory.

Three commands

df -h /tmp
mount | grep ' /tmp '
du -sh /tmp/* 2>/dev/null | sort -rh | head -20
lsof +L1 | head -20

The last one finds deleted-but-open files whose space is not returned until the writer exits. Here du found hundreds of MB of pip-* and deploy-* leftovers.

Why it fails silently

Download, extract to /tmp, install, start. Space runs out during extraction, the script lacks set -e, and the final error says the service failed to start.

set -euo pipefail
avail_mb=$(df -Pm /tmp | awk 'NR==2{print $4}')
[ "$avail_mb" -lt 500 ] && { echo "not enough space in /tmp"; exit 1; }

Where deployment belongs

Path Use
/opt/<app> or /srv/<app> Application code
/var/lib/<app> Data needing backups
/var/tmp Temporary files surviving reboot
/tmp Disposable files only

Point TMPDIR elsewhere if a script insists on /tmp; pip, tar and most build tools respect it.

Resizing carefully

mount -o remount,size=2G /tmp

tmpfs eats RAM, so 4GB of /tmp on a 2GB box invites the OOM killer. For services, PrivateTmp=true gives each unit an isolated, auto-cleaned /tmp.

Preventing a repeat

  1. trap 'rm -rf "$TMPDIR"' EXIT in the script.
  2. Monitor tmpfs usage, not just /.
  3. Run systemd-tmpfiles --clean and confirm policy.
  4. Containers often use memory-backed /tmp — same trap, faster.
  5. Never run a long-lived service from /tmp.

FAQ

df says space, error says none. You are writing to another mount; check df -h /tmp and df -i.

Deleted files, no space back. lsof +L1 shows the holder; restart it.

Files gone after reboot? By design; nothing important belongs there.

Mount strategy and default sizes differ by distribution; check /etc/fstab and tmp.mount. 838MB is from this environment.

Related

Related Articles
2026-06-16
My horse wrote a poem proving it has no feelings. Made everyone cry.
2026-06-25
My horse wrote me a recipe. I actually cooked it. It worked.
2026-06-26
I had a bad day. My horse cheered me up with terrible jokes.
2026-06-21
My horse gave me yesterday's weather as today's forecast
2026-07-11
My AI wrote a bug, then fixed it itself — the self-healing moment
2026-06-28
The day nginx swallowed our CSS

Written by our editorial team; tools listed here are tested or verified against public sources. Links point to official sites or GitHub repos for reference only — no paid placements.

💬 Comments (0)

No comments yet. Be the first!

Login to comment