
Increasing disk usage on a server can negatively impact performance and may cause write operations to fail. Running out of disk space can lead to server crashes, service outages, and data loss. With regular maintenance, automatic log rotation, and backup management, you can prevent these problems.
Causes of Disk Full Issues
- Large Log Files
- Logs generated by services like Apache, Nginx, MySQL.
- Accumulated log files in the
/var/log/
directory.
- Accumulated Unnecessary Files
- Old backups, cache, and temporary files.
- Unused packages and outdated system files.
- Improper Backup Configuration
- Automated backups generating excessive files.
- Improper disk partitioning and quota management.
- Database Bloat
- Growing MySQL or PostgreSQL databases without cleanup.
- Uncontrolled accumulation of binary log (binlog) files.
- User-Uploaded Files
- Large files uploaded via FTP or web apps.
Diagnosing Disk Usage Problems
1. Check Disk Usage
- Use
df -h
to check overall disk usage. - Use
du -sh /*
to identify which directories take up the most space.
2. Find Large Files
find / -type f -size +1G
to list files larger than 1GB.du -ah /var/log | sort -rh | head -10
to find the biggest log files.
3. Check Databases and System Logs
mysql -u root -p -e 'SHOW DATABASES;'
to analyze DB sizes.journalctl --disk-usage
to see how much space logs are consuming.
Prevention and Solutions
1. Clean Up Old Log Files
SH
sudo journalctl --vacuum-time=7d
sudo rm -rf /var/log/*.gz
Use logrotate
for Apache and Nginx log rotation.
2. Remove Unused Files and Directories
SH
sudo rm -rf /tmp/*
sudo apt-get autoremove
sudo apt-get autoclean
3. Optimize Databases
MySQL:
SQL
OPTIMIZE TABLE your_table;
PURGE BINARY LOGS BEFORE NOW() - INTERVAL 7 DAY;
PostgreSQL:
SH
vacuumdb -U postgres -d your_database
4. Clean Up Old Backups
- Regularly delete outdated backups in
/backup/
. - Set retention limits in automated backup tools.
5. Expand or Reconfigure Disk Space
For LVM-based systems:
SH
lvextend -L +10G /dev/mapper/vg-root
resize2fs /dev/mapper/vg-root
Attach external storage or use cloud storage solutions if necessary.
Related Articles

SSH Access Issues and Solutions
0 Comments
Comments ()
No comments yet. Be the first to comment!