A disk shows free space but you get "No space left on device". Why?
IntermediateConceptFilesystem Hierarchy, Inodes & Links
Answer
Most likely the filesystem ran out of inodes, typically from millions of tiny files (session files, mail queue, cache).
df -i
sudo find /var -xdev -type f | cut -d/ -f2-3 | sort | uniq -c | sort -rn | head
ext4 fixes the inode count at mkfs time (-i bytes-per-inode or -N); XFS allocates inodes dynamically, so it rarely hits this. Other causes: reserved blocks for root, or a deleted-but-open file.