Payments are experiencing issues due to temporary restrictions in Russia. If your payment does not go through, please submit a support request.Our support team is available 24/7 — we are always here to help with hosting and server issues.We are now accepting requests for dedicated server rental and colocation services in our data center.Reminder: we recommend enabling backups for additional data protection.A new VPS/VDS lineup with NVMe storage and improved performance is now available.Maintenance work on some servers has been completed. All services are operating normally.
Article3 min readViews0

Why df and du Report Different Disk Usage

How to identify the filesystem running out of space and compare its metrics with directory sizes without blindly deleting data.

Two drives in desktop server sleds
In this article

Free space is exhausted, although the site catalog appears small. In such a situation, the first step is to determine exactly what is being measured. df displays the state of the file system, while du traverses available files and directories. These results are related but do not necessarily match byte for byte.

First, locate the relevant partition

This example is calculated for Linux with GNU Coreutils. Here, /var is an example of an existing directory. If the issue pertains to a different path, substitute it accordingly. The commands below only read information, but traversing a large directory creates disk load.

df -hT /var

Check the file system type, total size, available space, and mount point. The site upload directory may reside on a separate volume; free space in the root then does not explain a write error to uploads. The -h parameter outputs human-readable units, so rounded values are unsuitable for precise balance calculations.

Descend the directory tree gradually

Start at one level to see major branches instead of generating thousands of lines:

du -xhd1 /var

The -x parameter prevents crossing into other file systems, while -d1 limits output depth. Nevertheless, the program still traverses the contents of the selected directories. Do not run multiple such traversals simultaneously on an overloaded server.

If a large subdirectory is found, repeat the check for it. Access denied messages indicate incomplete measurement. Do not suppress them by redirecting errors: first determine what permissions are required for the audit. Elevated privileges are needed only for reading inaccessible directories and must align with your role.

Why the numbers diverge

An open remote file continues to occupy space even though a standard directory traversal no longer sees it. Additional discrepancies arise from file system metadata, block reservations, snapshots, and compression features. For files with sparse regions, the visible size also differs from the actually allocated blocks.

Example: the panel shows a nearly full volume, while accessible directories occupy noticeably less space. This is a reason to check for open remote files and volume characteristics. Such a result alone does not prove a space leak or disk failure. However, if a single directory grows rapidly between two measurements, it is more useful to identify the process creating it and the purpose of the files.

What to pass to the administrator

Record the verified path, mount point, measurement time, and the largest directory. Include access denial messages. Do not attach the contents of client files: for the first stage, sizes and anonymized paths are sufficient.

After performing the agreed cleanup, run both commands again for the same paths. If du has decreased while df has barely changed, do not proceed to delete adjacent directories. Check whether a process is holding onto old data and wait for the application's built-in space-reclamation procedure to complete. A successful diagnostic result identifies a clear cause for the disk usage and a specific owner of the data, rather than just a temporarily green indicator.

Compare measurements taken close in time: an ongoing import can increase data even between the launch of two commands.

Discussion0

Share your experience and ask questions. Comments without links appear after editorial review.

No comments yet. Start the discussion.