Why do I get No space left on device when ls shows almost nothing?
A filesystem refuses new writes when it is full, and the program writing gets No space left on device. df shows how full each filesystem is. If the files you can see do not add up, look for hidden ones: ls skips names that start with a dot, while du -a counts every file. In this incident a retry loop left one hidden temporary file that took the whole export disk.
What it looks like
- Writes fail with No space left on device.
- df shows the filesystem at 100%.
- ls of the folder looks small.
- Restarting the program does not help.
Commands that find the cause
df -h /srv/exportsSpace on the filesystem that holds the exports: Size, Used, Avail and Use%. A filesystem at 100% refuses every new write, whatever wrote the data.
sudo du -ah /srv/exports | sort -h | tail -5du measures what each file really takes, including hidden ones; sorted by size, the largest are last. Use it to find what is using the space df reports.
systemctl status orders-api --no-pagerShows whether a service is running, since when, its main process and the last few log lines. active (running) means systemd sees it as healthy; the logs under it can still show errors.
journalctl -u orders-api -n 5 --no-pagerThe service's own log, newest last. Each failed request is one line with the error the operating system returned. Read the error text, not just the word ERROR.
ls -lh /srv/exportsThe files in the export folder with sizes. ls hides names that start with a dot unless you add -a, so a listing can look small while the disk is full.
What the evidence looked like
Recorded on a real system when this incident was captured for the game.
$ df -h /srv/exports
Filesystem Size Used Avail Use% Mounted on
/dev/loop0 41M 41M 0 100% /srv/exportsRoot cause
A retry loop wrote one hidden 40 MB temporary file that filled /srv/exports; deleting it freed the disk.
The fix
Delete the one file that is filling the disk:
sudo rm /srv/exports/.export-retry.tmpHow to prevent it
Alert on disk use before it reaches 100%, put temporary files on their own filesystem with cleanup, and make retries write in place or give up after a limit.
More incident guides
- systemd service keeps restarting after a deploy
- Address already in use: find what holds a port on Linux
- Linux name or service not known after a config change
- Too many open files in a systemd service
- CrashLoopBackOff after a config change
- Service returns 503 while every pod is Running
- OOMKilled and exit code 137
- Pods fail to start after a Secret change
- Requests fail after adding a NetworkPolicy
- Healthy pods restarted by a liveness probe
- Slow service with low CPU and no restarts
- Rollout stuck on ImagePullBackOff
- Pods stuck Pending with insufficient CPU
- Docker container exits immediately after a config change
- Docker port mapping not working, empty reply
- Docker container cannot connect to the database host
- Docker volume permission denied
- Docker container exit code 137, killed for memory