Situatie
Running out of disk space on Linux can occur due to large log files, old backups, unused software, or a cluttered temporary folder. When this happens, your system may slow down or stop functioning entirely. Resolving this issue promptly ensures your server or system operates smoothly.
Solutie
Step 1: Check Disk Space Usage
Start by identifying which directories or files are consuming the most space. Use the following command to see an overview of disk usage:
df -h
This shows all mounted filesystems and their usage in a human-readable format. To pinpoint the problematic directories, use:
du -sh /* 2>/dev/null
Step 2: Clear Log Files
Log files in /var/log can grow significantly. Navigate to the log directory and identify large files:
Clear unnecessary log files or truncate large ones:
sudo truncate -s 0 /var/log/<logfile_name>
Step 3: Remove Unused Packages
Unused packages and their dependencies can occupy valuable space. Clean up your package manager:
For systems using apt:
For systems using dnf or yum:
Step 4: Delete Temporary Files
Temporary files can accumulate over time in /tmp and /var/tmp. Safely delete them using:
Step 5: Check and Remove Old Backups
If you have old backups stored locally, they could be taking up significant space. Locate backup files in common directories like /home, /backup, or /root:
find / -type f -name “*.bak” -o -name “*.old”
Carefully delete unnecessary backups:
sudo rm /path/to/backup
Leave A Comment?