Skip to content

Q&A · Answered

How to fix "No space left on device" error on Linux

asked 9 months, 1 week ago 748 views 1 answer
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?

1 Answer

One accepted
26

Accepted answer

Not confirmed since it was written, 9 months, 1 week ago

This can happen due to inode exhaustion or filesystem issues. Here's how to diagnose and fix:

Check inode usage

# Check inode usage
df -i
# Find directories with many files
find / -xdev -printf '%h
' | sort | uniq -c | sort -rn | head -20

Find and remove large files

# 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 up common space consumers

# Clean apt cache
sudo apt clean
# Clean old kernels
sudo apt autoremove
# Clean logs
sudo journalctl --vacuum-time=7d

Your answer

Say what you tried, not only what worked — the next person needs the reasoning. Code goes in a fenced block.

Shown beside your answer and never checked, so it cannot be a name someone already has here.

No account needed to answer. Sign in instead and it carries your name and earns reputation.