Disk Full

Full disk is one of the most frequent causes of malfunctions: sites not working, databases stop writing, error logs filling up. Here's how to fix it.

02

Quick check

bash
df -h

If a line shows 100% or close, that partition is full. The main partition is usually mounted on /.

03

Find what's taking space

Largest folders in root

bash
du -h / --max-depth=2 2>/dev/null | sort -rh | head -20

Enter the largest folder and analyze

bash
du -h /var --max-depth=2 2>/dev/null | sort -rh | head -10

Find the largest files

bash
find / -type f -size +100M 2>/dev/null | xargs ls -lh | sort -k5 -rh
04

Areas that fill up most often

1. System logs

bash
# Check log size
du -sh /var/log/

# Delete old logs (older than 7 days)
journalctl --vacuum-time=7d

# Limit logs to max 500MB
journalctl --vacuum-size=500M

# See largest logs
ls -lhS /var/log/

2. Nginx / Apache logs

bash
# Check size
du -sh /var/log/nginx/
du -sh /var/log/apache2/

# Empty a log (without deleting it)
> /var/log/nginx/access.log

# Configure automatic rotation
cat /etc/logrotate.d/nginx

3. Cache and packages

bash
# Debian/Ubuntu
apt clean
apt autoremove -y

# CentOS
dnf clean all

4. /tmp files

bash
du -sh /tmp/
rm -rf /tmp/*

5. MySQL logs

bash
du -sh /var/log/mysql/

# MySQL binary logs (can become huge)
ls -lh /var/lib/mysql/mysql-bin.*

# In MySQL, purge old binary logs
mysql -u root -p -e "PURGE BINARY LOGS BEFORE DATE(NOW() - INTERVAL 3 DAY);"

6. Unused Docker images

bash
# If you use Docker
docker system prune -a
docker volume prune
05

Emergency free space (quick)

bash
# Combined quick cleanup
apt clean && apt autoremove -y
journalctl --vacuum-size=200M
rm -rf /tmp/*
find /var/log -name "*.gz" -delete
find /var/log -name "*.old" -delete
06

Prevention: configure logrotate

Make sure automatic log rotation is active:

bash
# Check service
systemctl status logrotate

# Force manual rotation
logrotate -f /etc/logrotate.conf
07

Exhausted inodes

Sometimes df -h shows available space but disk is still "full". Check inodes:

bash
df -i

If a partition is at 100% inode, find the folder with too many small files:

bash
find / -xdev -printf '%h\n' 2>/dev/null | sort | uniq -c | sort -rn | head -10

Common causes: PHP sessions in /tmp, web cache files, email in spooler.

See the full guide: Disk Management

DeluxHost, fondata nel 2023, offre soluzioni di hosting di alta qualità per diverse esigenze digitali. Forniamo hosting condiviso, VPS e server dedicati con sicurezza avanzata e datacenter globali.

© DeluxHost, Tutti i diritti riservati. | Partita IVA: IT17734661006
Tutti i sistemi operativi