Understanding Disk Full Errors
When disk is 100% full, you may see:
- "No space left on device"
- Unable to write logs or files
- Services crashing
- Unable to SSH or run commands (though SSH often still works)
Step 1: Check Disk Usage
df -hShows usage per filesystem. Look for 100% or 90%+:
Filesystem Size Used Avail Use% Mounted on
/dev/vda1 20G 20G 0 100% /Step 2: Find Large Files
Find largest files on system:
# Top 20 largest files
sudo find / -type f -size +100M -exec ls -lh {} ; 2>/dev/null | sort -k5 -hr | head -20Or use ncdu (interactive tool):
sudo apt install ncdu -y
sudo ncdu /Step 3: Common Space Wasters
Log Files
# Check log sizes
du -sh /var/log/
# Rotate/clear logs
sudo journalctl --vacuum-size=200M
sudo truncate -s 0 /var/log/*.logPackage Cache
# Ubuntu/Debian
sudo apt clean
sudo apt autoremove -y
# CentOS/RHEL
sudo yum clean allOld Kernels
# Ubuntu
sudo apt autoremove --purge
# CentOS
sudo package-cleanup --oldkernels --count=2Docker
docker system prune -a -fBackup Files
# Find old backups
find /home -name "*.tar.gz" -mtime +30 -delete
find /home -name "*.zip" -mtime +30 -deleteStep 4: Check Inode Usage
You can run out of inodes (file metadata) before disk space:
df -iIf 100% inodes, delete many small files:
find /home -type f -size 0 -delete # Delete empty files
find /var/spool/postfix/maildrop -type f -delete # Clear mail queueStep 5: Emergency Cleanup
If you cannot run commands, try:
# Delete/tmp contents
sudo rm -rf /tmp/*
# Truncate large log files
sudo truncate -s 0 /var/log/syslog
sudo truncate -s 0 /var/log/auth.log⚠️ Always investigate what filled the disk to prevent recurrence.