Operations 5 min read

Why Do du and df Report Different Disk Usage on Linux?

When managing Linux servers, the du and df commands often show mismatched disk usage figures, and this article explains the three main reasons—reserved space, phantom files, and uncounted data during mount operations—and how to diagnose and resolve each discrepancy.

MaGe Linux Operations
MaGe Linux Operations
MaGe Linux Operations
Why Do du and df Report Different Disk Usage on Linux?

Linux du/df Disk Usage Inconsistency Issue

When administering Linux servers you often need to check disk space. The typical commands are df -lh to view total and used space for each mounted filesystem, and du -sh [directory] to sum the size of all files under a specific directory.

Sometimes the numbers reported by df and du do not match. For example, du may show that the root directory uses 2 GB, while df reports that the root filesystem has already used 3 GB or more. This discrepancy can be caused by three main reasons:

1. Reserved Space

Ext* filesystems reserve a portion of the disk for emergency situations. The reserved amount can be viewed with tune2fs -l [dev_name] | grep "Reserved block count". This reserved space is counted as used by df, leading to higher usage figures. To adjust the reservation, use tune2fs -m [size] [dev_name].

2. Phantom Files (Deleted but Still Open)

du

sums the sizes of files that the filesystem records, while df reads usage information from the superblock. If a file is deleted while a process still holds an open file descriptor, du will no longer see the file, but the space remains allocated and df still counts it. Such files and the processes using them can be found with lsof | grep deleted. Once the processes terminate or are killed, the space is released.

3. Files Not Counted by du After Remounting

If a directory already contains data before it is mounted onto a new device, du will not see that data because the mount hides the underlying files. However, the space occupied by those hidden files is still accounted for by df. To expose and remove the hidden data, stop all processes using the directory (e.g., fuser -km [directory]), unmount the filesystem ( umount [directory]), delete the now-visible files, and then remount the device ( mount -t [type] [dev] [directory]).

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.

Operationsdudfdisk-usage
MaGe Linux Operations
Written by

MaGe Linux Operations

Founded in 2009, MaGe Education is a top Chinese high‑end IT training brand. Its graduates earn 12K+ RMB salaries, and the school has trained tens of thousands of students. It offers high‑pay courses in Linux cloud operations, Python full‑stack, automation, data analysis, AI, and Go high‑concurrency architecture. Thanks to quality courses and a solid reputation, it has talent partnerships with numerous internet firms.

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.