22
My server shows "No space left on device" error but df -h shows 40% free space. What is causing this and how to fix it?
Loading...
Q&A · Answered
My server shows "No space left on device" error but df -h shows 40% free space. What is causing this and how to fix it?
Accepted answer
This can happen due to inode exhaustion or filesystem issues. Here's how to diagnose and fix:
# Check inode usage
df -i
# Find directories with many files
find / -xdev -printf '%h
' | sort | uniq -c | sort -rn | head -20
# Find files larger than 100MB
find / -type f -size +100M -exec ls -lh {} \;
# Find largest directories
du -h --max-depth=1 / | sort -hr | head -20
# Clean apt cache
sudo apt clean
# Clean old kernels
sudo apt autoremove
# Clean logs
sudo journalctl --vacuum-time=7dSay what you tried, not only what worked — the next person needs the reasoning. Code goes in a fenced block.