How to Quickly Identify and Free Up Hidden Disk Space on Linux Servers
This guide explains how to use Linux commands like df, du, find, lsof, and tune2fs to locate large directories, uncover deleted files that still occupy space, and adjust reserved root space, enabling you to resolve unexpected disk‑usage alerts efficiently.
Understanding Disk‑Space Alerts
When a server triggers a disk‑space warning, the first step is to verify the reported usage with df -Hl. The output shows total, used, and available space, but it may not reveal which directories or files are consuming the most space.
Finding Large Directories or Files
A straightforward method is to run du -hs * in the root directory, which lists each top‑level directory’s size. For deeper inspection, use the depth‑limited options:
du -h -d 2 | grep [GT] | sort -nr du -h --max-depth=2 | grep [GT] | sort -nrThese commands filter results to entries measured in gigabytes (G) or terabytes (T) and sort them in descending order, making the biggest consumers easy to spot.
Alternatively, find / -type f -size +1G -exec du -h {} \; searches the entire filesystem for files larger than 1 GB, offering a faster and more flexible approach than repeated du scans.
Detecting Deleted Files Still Holding Space
Sometimes the sum of sizes reported by du is far less than the usage shown by df. This discrepancy often means that deleted files are still open by a process, so their space isn’t released. To list such files, use: lsof +L1 The output will reveal files with a link count of zero; large entries (e.g., a 28 GB log file) indicate that the file was removed but remains allocated until the owning process releases it. Restarting the relevant service (e.g., Tomcat) frees the space.
Reserved Space for the Root User
Linux filesystems reserve a percentage of disk space (default 5%) for the root user to ensure critical services can continue operating when the disk is nearly full. This reserved space can appear as “missing” space in df output.
You can adjust the reservation with tune2fs -m 1 /dev/vda1, reducing the reserved percentage to 1 %. After applying the change, the previously hidden space becomes available for regular use.
Signed-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.
Liangxu Linux
Liangxu, a self‑taught IT professional now working as a Linux development engineer at a Fortune 500 multinational, shares extensive Linux knowledge—fundamentals, applications, tools, plus Git, databases, Raspberry Pi, etc. (Reply “Linux” to receive essential resources.)
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.
