df reports more space used than the total from du: the discrepancy quickly leads to a deletion, but it does not yet indicate where the blocks are or why the two measurements diverge. Before taking any action, ensure that you are querying the same file system, with the same unit and a successful traversal. The commands below modify nothing; they serve to qualify the discrepancy, not to promise recovering space.
The starting point counts as much as the result. A total calculated from a subdirectory does not necessarily represent all the volume displayed by df. Another mount may also cover part of the directory tree. Finally, on ext4, the available space and used space are not read in the same way. Proceed in this order and stop as soon as the scope is unclear.
Check that df and du refer to the same volume
Choose an existing path that is on the volume to be examined. In this example, /srv/data is a location to be replaced with your own path. Before launching a total, identify the mount point, its source, and its type:
findmnt -T /srv/data -o TARGET,SOURCE,FSTYPE,OPTIONS
The expected output is a line with the target (TARGET), the source, the file system type, and the options. -T searches for the file system containing the given path. If the target is /, the total from du should start from the root, not from /srv/data. If it is /srv/data, this point is the appropriate starting point. To understand this reading, consult the guide to check the mount point with findmnt.
Perform both measurements on the same host and within the same namespace of mounts. If the source is of type overlay or NFS, if a sub-path is a bind mount, or if you do not understand the displayed source, suspend the straightforward protocol: the reconciliation then requires an appropriate scope. Do not deduce ext4 from the name of a device.
A du traversal reads the directory tree and may call on a loaded server. Run it once in a suitable window, without a measurement loop. The suggested commands are read-only; do not delete anything to “test” the discrepancy.
Compare used blocks with a common unit
Take the exact value of TARGET read in the previous step. The next block only fits as is if that value is indeed /srv/data. This variable allows you to keep the same path in the following commands.
point='/srv/data'
df -B1 --output=source,fstype,size,used,avail,target -- "$point"
sudo du -x -s -B1 -- "$point"
printf 'Return code of du: %sn' "$?"
df displays in bytes the size (size), used blocks (used), and available blocks (avail) for the file system containing the path. Compare used to the total from du, not to size - avail. This latter difference concerns blocks that are not available to the user; it is not a measure equivalent to the blocks allocated to the traversed files.
In the du command, -s requests a single total, -B1 imposes bytes, and -x avoids descending into directories belonging to other file systems. The mode remains that of allocated blocks, not apparent size: du -b would change the measurement and is not suitable for this comparison. A folder name starting with a dot is included in the normal traversal; a glob like * may omit it before execution.
The returned code displayed must be zero to consider the traversal successful. Leave error messages visible: an access error makes the total incomplete. sudo grants du additional rights, but does not guarantee an error-free traversal or a comprehensive reading. Do not redirect errors to /dev/null. Significant activity during the measurement may also change the counters between the two commands; in this case, do not draw precise conclusions.
Do not seek a perfect equality to the byte. The comparison only makes sense if the starting point corresponds to the root of the volume displayed by df, if the traversal is successful, and if both tools measure the same scope. A bind mount located under this root may complicate this scope: -x does not constitute a universal exclusion of mounts when they expose the same file system.
Identify mounts that limit visibility
Once point is defined with the actually recorded target, display the mount and its descendants:
findmnt -R -M "$point" -o TARGET,SOURCE,FSTYPE
The expected output lists the selected mount point and the sub-mounts it contains. If another file system is mounted under the target, du -x does not traverse it. Thus, the total may leave aside files from this distinct volume, while the path remains visible in the tree.
A mount may also cover content that was previously in its target directory. The path then exposes the mounted file system, not the old entries located underneath. This is a potential visibility limit for the traversal; the output of findmnt does not prove that these old data still exist nor what space they occupy. Do not transform a mount covering assumption into a hidden files diagnosis.
Stop at this observation if the comparison depends on the covered content. Verifying this would require a separate procedure, outside this read-only diagnosis. Do not unmount the volume and do not change the mounts to try to confirm the assumption. The same caution applies to a bind mount: its appearance in the tree is not sufficient to know what blocks its traversal represents.
Distinguish ext4 reserve from used space
The ext4 reserve primarily concerns the availability of blocks. It does not mean that additional files are counted in used. This explanation does not apply as is to XFS, Btrfs, overlay, or NFS.
Only proceed to this verification if FSTYPE is ext4 and if SOURCE indeed identifies a local block device. Replace the name in angled brackets with the verified source; the command below is a read, not a value to be copied without control.
sudo env LC_ALL=C tune2fs -l /dev/VERIFIED_EXT4_DEVICE
The output from the superblock includes Reserved block count and Block size, among other things. Their product gives, in bytes, the configured reserve. There is no universal value to presume for your volume; record what the command shows. The reserved blocks allow privileged processes to continue operating when available space decreases.
On ext4, the available space may thus be less than what a simple subtraction between size and used blocks suggests. This may leave a discrepancy between size and used + avail without there being additional files to find. The configured reserve does not, by itself, reconcile all counters: internal reserves, quotas, or options may intervene. Do not say it automatically inflates used compared to du, nor attribute every remaining discrepancy to metadata. Ext4 typically deducts part of its overhead from the total announced blocks.
This command does not modify the reserve. Do not add any change options: the goal is to read a value, not to correct availability before understanding the counters.
Check the stability of readings
Encapsulate the du traversal with a read of df before and after, then check that the mount point has not changed:
df -B1 --output=source,fstype,size,used,avail,target -- "$point"
sudo du -x -s -B1 -- "$point"
printf 'Return code of du: %sn' "$?"
df -B1 --output=source,fstype,size,used,avail,target -- "$point"
findmnt -T "$point" -o TARGET,SOURCE,FSTYPE
Compare the two outputs of df and findmnt with the first reading. A different source, type, or target signals that the scope has changed; different used or avail values show that the counters have shifted. In both cases, the du traversal and the df readings do not describe an atomic photograph. This verification cannot freeze system activity; it serves to identify an unstable measurement, not to prove that identical values are exhaustive.
Choose the final diagnosis without exceeding the evidence
Take a targeted reading of the mount again if the discrepancy persists and you need to confirm the scope used for the total:
findmnt -T "$point" -o TARGET,SOURCE,FSTYPE
A target equal to the expected root and an unchanged source reinforce the scope of the check; they do not reveal the cause of a residual discrepancy. If the target is a subfolder, take the total from the root of the volume. If a mount covers part of the tree, note the visibility limit without concluding that hidden data exists. On ext4, distinguish the reserve that reduces availability from an excess of used blocks. If the discrepancy remains unexplained after these checks, stop: these commands justify no deletion.