How to Quickly Identify and Resolve Disk Space Exhaustion on Linux
This guide explains how to verify disk alerts, locate large directories and files using df, du, and find commands, handle discrepancies caused by deleted files, and adjust system-reserved space to efficiently free up disk space on Linux servers.
Most common alerts are memory or CPU, but disk alerts can also occur. When a disk full alert appears, first verify it with df -Hl to see which partition is full.
How to Locate Large Disk Space Consumers
To locate large directories, run du -hs at the root, or use du -d 2 or du --max-depth=2 combined with grep and sort -nr to filter big directories.
du -h -d 2 | grep [GT] | sort -nr
du -h --max-depth=2 | grep [GT] | sort -nrFor faster results, the find command can directly locate files larger than 1 GB:
find / -type f -size +1G -exec du -h {} \;Inconsistent Disk Space Reports
If the size reported by du or find differs from df, it may be due to deleted files that still hold space. Use lsof +L1 to list such files.
lsof +L1Often a deleted log file still occupies dozens of gigabytes; restarting the related service (e.g., Tomcat) releases the space.
System-Reserved Disk Space
Sometimes the used and available space reported by df does not sum to the total because the system reserves a percentage (default 5 %) for the root user. Adjust the reserved space with tune2fs -m 1 /dev/vda1 to keep only 1 GB.
tune2fs -m 1 /dev/vda1Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Su San Talks Tech
Su San, former staff at several leading tech companies, is a top creator on Juejin and a premium creator on CSDN, and runs the free coding practice site www.susan.net.cn.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
