P1
Disk Space Exhausted — Linux Troubleshooting Guide
Diagnose and resolve a full disk on Linux. Covers finding large files, cleaning logs, package caches, and reclaiming space from deleted-but-open files.
15 min8 steps
Progress: 0/8 steps
0%
Get an overview of which filesystems are full and how much space is used.
df -h | sort -k5 -rn | head -10
Expected: List of mount points sorted by usage percentage. Look for any at 90%+ usage.
Identify which top-level directories are consuming the most space.
du -sh /* 2>/dev/null | sort -rh | head -15
Expected: Sorted list of directories by size. Common culprits: /var, /home, /tmp, /opt.
Search for individual large files that may be safe to remove.
find / -xdev -type f -size +100M -exec ls -lh {} \; 2>/dev/null | sort -k5 -rh | head -20Expected: List of files over 100MB with their paths and sizes.
This scan may take a while on large filesystems. Consider limiting to specific directories like /var or /tmp.
Truncate or remove old rotated log files that are consuming space.
journalctl --vacuum-size=100M && find /var/log -name '*.gz' -mtime +7 -delete && find /var/log -name '*.old' -delete
Expected: Freed space from systemd journal and old compressed log files.
Remove cached packages that are no longer needed.
apt-get clean && apt-get autoremove -y # Debian/Ubuntu
# OR: dnf clean all # RHEL/Fedora
Expected: Package cache cleared. Can free 100MB-2GB depending on system age.
Remove temporary files and anything older than 7 days in /tmp.
find /tmp -type f -atime +7 -delete && find /var/tmp -type f -atime +7 -delete
Expected: Old temporary files removed. Typical space savings: 50MB-1GB.
Make sure no running processes depend on files in /tmp before cleaning.
Files deleted but still held open by processes still consume disk space.
lsof +L1 2>/dev/null | grep deleted | sort -k7 -rn | head -10
Expected: List of deleted files still held open. Restart the owning process to free space.
Confirm that disk usage has dropped to an acceptable level.
df -h /
Expected: Root filesystem should now show less than 85% usage.