Docs / Server Management / Monitoring Disk Space and Preventing Full Disk Issues

Monitoring Disk Space and Preventing Full Disk Issues

By Admin · Feb 25, 2026 · Updated Apr 23, 2026 · 89 views · 1 min read

Check Disk Usage

# Overview of all filesystems
df -h

# Check inode usage (running out of inodes is as bad as disk space)
df -i

# Size of current directory
du -sh .

# Top 10 largest directories
du -h --max-depth=1 / | sort -rh | head -10

Find Large Files

# Files over 100 MB
find / -type f -size +100M -exec ls -lh {} \; 2>/dev/null

# Largest files in /var
find /var -type f -exec du -h {} + 2>/dev/null | sort -rh | head -20

Common Space Consumers

LocationCauseSolution
/var/log/Log accumulationConfigure logrotate, clear old logs
/tmp/Temporary filesClean with tmpreaper or reboot
/var/lib/docker/Docker images/volumesdocker system prune -a
/var/cache/apt/Package cachesudo apt clean
/home/*/User filesReview and clean up

Automated Monitoring

Create /usr/local/bin/disk-alert.sh:

#!/bin/bash
THRESHOLD=85
USAGE=$(df / | tail -1 | awk '{print $5}' | tr -d '%')
if [ "$USAGE" -gt "$THRESHOLD" ]; then
    echo "WARNING: Disk usage is ${USAGE}% on $(hostname)" | mail -s "Disk Alert" admin@example.com
fi
chmod +x /usr/local/bin/disk-alert.sh
# Run hourly
echo "0 * * * * root /usr/local/bin/disk-alert.sh" >> /etc/crontab

Preventive Measures

  • Set up logrotate for all application logs
  • Schedule regular cleanup of temporary files
  • Use ncdu for interactive disk usage analysis
  • Monitor with alerting tools (Netdata, Prometheus)

Was this article helpful?