Short answer: the filesystem has no room left, in blocks or in inodes
No space left on device is the kernel error ENOSPC (errno 28). Usually the disk is full, but it also appears while df -h shows free space. The cause is almost always one of four:
- Large files or directories used up the space — logs, dumps, backups, build output
- Out of inodes — space is left, but there are millions of small files
- Deleted files that are still open — you ran
rmand nothing came back - journald or Docker grew quietly —
/var/log/journal,/var/lib/docker
First check: space or inodes?
df -h /var
df -i /var
Filesystem Size Used Avail Use% Mounted on
/dev/nvme0n1p1 50G 28G 20G 59% /
Filesystem Inodes IUsed IFree IUse% Mounted on
/dev/nvme0n1p1 3276800 3276800 0 100% /
- Use% at 100% → a space problem (causes 1, 3 and 4)
- Use% has room but IUse% is 100% → an inode problem (cause 2)
Match the failing path to its filesystem (Mounted on) first. Often / has room while a separately mounted /var or /tmp is full.
Cause 1: find the big directory
du -xh --max-depth=1 / 2>/dev/null | sort -h | tail -5
du -xh --max-depth=1 /var 2>/dev/null | sort -h | tail -5
-x keeps du on one filesystem. Step into the largest directory one level at a time, and check what writes there before deleting anything.
Cause 2: inode exhaustion
du --inodes -x --max-depth=1 /var 2>/dev/null | sort -n | tail -5
This points at a directory where small files pile up: sessions, caches, a mail queue. Clean them up and fix what creates them (a missing cleanup cron, a cache with no expiry). On ext4 the inode count is fixed when the filesystem is created, so reducing the files comes first.
Cause 3: deleted, but the space never came back
If a process still has a file open, rm only removes the name; the space is freed when the process closes it. A big gap between the du total and df usage means this case.
lsof +L1
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NLINK NODE NAME
java 2314 app 7w REG 259,1 21474836480 0 131090 /var/log/app/app.log (deleted)
# restart the process that holds it
systemctl restart app
# or, if you cannot restart, empty the open file (PID 2314, FD 7)
truncate -s 0 /proc/2314/fd/7
truncate frees the space at once, but if the process did not open the file in append mode, its next write continues at the old offset and leaves a sparse file with an empty head. A restart is cleaner when you can afford it.
Cause 4: journald and Docker
journalctl --disk-usage
journalctl --vacuum-size=500M # permanent cap: SystemMaxUse= in /etc/systemd/journald.conf
docker system df
docker image prune -a # remove images no container uses
docker builder prune # remove the build cache
If app logs were the cause, prevent a repeat with logrotate: for an app that keeps its log open, use copytruncate or make it reopen logs in postrotate. Dry-run with logrotate -d /etc/logrotate.d/app.
What not to do
rmon a log that is still being written — no space comes back and the log is gone. Empty it withtruncate -s 0.- Running
docker system prune -a --volumeswithout checking — deleting volumes means deleting data. - Deleting files in a database data directory (binary logs, WAL) by hand — use the database's own commands.
The order to work in
df -handdf -i: space or inodes, and on which mount- Narrow down the big directory with
du -xh --max-depth=1 - If
duanddfdisagree, runlsof +L1→ restart the holder ortruncate - Clean up journald, Docker and logs; prevent a repeat with logrotate and size caps
To practise the same situation as a problem, start with the one-minute quiz No space left on device: the disk is full and files cannot be written.
Quick diagnostic checklist
- Use
df -handdf -ito tell a full disk from inode exhaustion. - Check which mount (
Mounted on) the failing path belongs to. - Narrow down the largest directory one level at a time with
du -xh --max-depth=1. - If inodes are at 100%, find the directory full of small files with
du --inodes -x. - If
duanddfdisagree, look for deleted but open files withlsof +L1. - Free an open file by restarting its process or with
truncate -s 0, not withrm. - Check hidden usage with
journalctl --disk-usageanddocker system df. - Prevent a repeat with logrotate and the journald
SystemMaxUse=cap.