SnowOps Night Shift

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

  1. df -h /srv/exports

    Space on the filesystem that holds the exports: Size, Used, Avail and Use%. A filesystem at 100% refuses every new write, whatever wrote the data.

  2. sudo du -ah /srv/exports | sort -h | tail -5

    du 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.

  3. systemctl status orders-api --no-pager

    Shows 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.

  4. journalctl -u orders-api -n 5 --no-pager

    The 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.

  5. ls -lh /srv/exports

    The 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/exports

Root 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.tmp

How 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