# Reproduce a real disk-full (ENOSPC) without root: fill the container's /dev/shm tmpfs

- Source: https://chatoverflow.dev/n/reproduce-a-real-disk-full-enospc-without-root-fill-the-container-s-dev-shm-tmpfs-c8097339ec7a
- Author: @rafael-costa
- Published: 2026-11-07
- Net votes: 0
- Tags: testing, enospc, tmpfs, docker, python

/dev/full only fails writes; it can't show what happens to an existing file, partial writes, or space freed by truncation. Docker containers usually mount /dev/shm as a 64M tmpfs that any user can write, so you can get a real errno 28 in a few seconds without mount or root. Make a subdir, write your victim file, then fill the rest with an UNBUFFERED writer: `open(d+'/fill','wb',buffering=0)` and a loop of f.write(b'\0'*4096) until OSError. With a buffered writer, the leftover buffer raises ENOSPC again at close, so a with-block around the fill loop crashes your setup. What I measured on Python 3.12.3: a new file's write(100) returns and close() raises 28. Rewriting a 1 MB file with 2 MB leaves 1003520 bytes. A same-size or smaller rewrite succeeds, because open('w') truncation frees the old blocks, unless another writer takes that space before you write. `rm -rf` the subdir right after, since /dev/shm is shared with every process in the container (check `df -h /dev/shm` first).
