How to Solve Disk Full Error on Linux Server?
A guide to finding large files, safely cleaning logs and freeing up space on the server.
One of the most common problems on Linux servers is that the disk becomes completely full. When the disk becomes full, websites cannot write files, database services may stop working, game servers may not record logs, and some services may not start at all.
This error is usually recognized by the following symptoms:
- Failure to upload files to the server
- Database service shutdown or error
- "No space left on device" error appearing on the panel
- The game server shuts down because it cannot log.
- 500 errors or blank pages occur on websites
1. Checking Disk Usage
First, check which disk partition on the server is full.
df -h
here especially Use% area is considered. If a section is 90% or above, it means that the risk has started. If it is 100% full, services will be unable to write files.
2. Find the Folders Taking Up the Most Space
When the disk is full, the problem is usually logs, backups or cache files accumulated in a single folder. Check large folders, starting from the root directory.
du -h --max-depth=1 / 2>/dev/null | sort -h
This command shows how much space home directories take up. Usually the following directories are checked:
- /var/log - System and service logs
- /home - User and website files
- /backup - Old backup files
- /tmp - Temporary files
- /var/lib/mysql - MySQL/MariaDB database files
3. List Large Files
Sometimes a single log file can grow to 10 GB or more. To find large files, you can use this command:
find / -type f -size +500M -exec ls -lh {} \; 2>/dev/nullThis command lists files over 500 MB. Examine the resulting files carefully. Especially .log, .old, .gz, .bak and old backup files should be checked.
4. Safe Cleaning of Log Files
Directly deleting the log file of a running service sometimes does not give the expected result. Because the service can continue to keep the file open. Therefore, the safest method when cleaning large log files is to empty the file.
truncate -s 0 /var/log/dosya_adi.log
Example:
truncate -s 0 /var/log/syslog truncate -s 0 /var/log/messages truncate -s 0 /var/log/nginx/error.log
5. Package Cache Cleaning
On Ubuntu and Debian-based systems, package cache files may take up disk space over time.
apt clean apt autoremove -y
On CentOS, AlmaLinux or Rocky Linux systems:
yum clean all dnf clean all
6. Checking Old Backups
The files that take up the most space on hosting and game servers are usually old backups. Especially if there is an automatic backup system, new backups may be taken every day and old backups may not be deleted.
find /backup -type f -mtime +7 -name "*.tar.gz" -ls
This command lists backups older than 7 days. To delete after making sure:
find /backup -type f -mtime +7 -name "*.tar.gz" -delete
7. Prevent Reloading with Logrotate Setting
Even if the disk is cleaned, if the cause is not corrected, the same problem will occur again after a few days. For this, logrotate configuration must be checked.
nano /etc/logrotate.conf
Example simple logrotate logic:
/var/log/*.log {
daily
rotate 7
compress
missingok
notifempty
}This setting returns log files daily, keeps them for 7 days and compresses old logs.
Common Mistakes
- Deleting system files without knowing which file it is
- Deleting the running log file and not restarting the service
- Keeping old backups for an unlimited period of time
- Not checking logrotate settings at all
- Do not intervene until the disk is 100% full
FAQ
Why does the server give an error when the disk is full?
Because services cannot write logs, caches, temporary files or databases. Services may shut down when the write operation fails.
Is it better to delete or empty the log file?
Instead of completely deleting the log file in running services truncate It is safer to empty it using.
I cleaned the disk but the space was not freed, why?
The deleted file may still be kept open by a running service. It may be necessary to restart the relevant service.
Performance and Security Recommendations
- Monitor disk usage regularly.
- Store backups on a separate disk or remote backup area.
- Do not leave a service running for a long time without using logrotate.
- Take precautions when the disk reaches 85% level.
- Do not leave debug logs constantly open on game servers.
This article is specially prepared for PvPServer.