Operations 6 min read

How to Diagnose and Free Unexpected Linux Disk Space Usage

Learn step‑by‑step Linux techniques to locate hidden disk consumers—using df, du, find, lsof, and tune2fs—to resolve mismatched usage reports, delete lingering open files, and adjust reserved space, ensuring your server’s storage stays under control.

Liangxu Linux
Liangxu Linux
Liangxu Linux
How to Diagnose and Free Unexpected Linux Disk Space Usage

Background

During routine server maintenance, administrators often receive alerts that disk space is running low. The first step is to verify the current usage with df -Hl, which shows the total, used, and available space on each mounted filesystem.

Finding Large Directories and Files

A simple but slow method is to run du -hs * in the root directory and then repeat the process in sub‑directories until the culprit is found.

A more efficient approach uses du with depth limits and filters for large sizes:

du -h -d 2 | grep [GT] | sort -nr
du -h --max-depth=2 | grep [GT] | sort -nr

These commands list directories up to two levels deep, keep only those whose size is expressed in gigabytes (G) or terabytes (T), and sort them in descending order.

Alternatively, find can directly locate large files:

find / -type f -size +1G -exec du -h {} \;
find

is generally faster and more flexible than du for this purpose.

When df and du Totals Differ

Sometimes the sum of sizes reported by du is far less than the usage shown by df. This discrepancy is often caused by files that have been deleted but are still held open by a running process.

To identify such files, use lsof +L1: lsof +L1 The output may reveal, for example, a 28 GB log file that has been removed from the filesystem but remains open, consuming space.

Stopping or restarting the associated service (e.g., a Tomcat application) releases the file descriptor and frees the space.

Reserved Space for the Root User

Linux filesystems reserve a percentage of total space (default 5%) for the root user to ensure critical services can continue operating when the disk is otherwise full.

If this reserved space appears to be “missing” from the usable capacity, you can adjust it with tune2fs: tune2fs -m 1 /dev/vda1 Setting the reserved percentage to 1 % reduces the hidden allocation, as shown in the before/after screenshots.

Conclusion

By combining df, du, find, lsof, and tune2fs, you can quickly pinpoint the directories or files that consume unexpected disk space, resolve discrepancies caused by deleted but open files, and fine‑tune reserved space to keep your Linux server storage healthy.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

Linuxcommand-linedisk-managementfindlsofduserver operations
Liangxu Linux
Written by

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.)

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.