Why Do du and df Report Different Disk Sizes on Linux?
This article explains why the Linux commands du and df often return mismatched root partition sizes, detailing five underlying reasons such as deleted open files, reserved space, hidden files, mounted directories, and the fundamental differences between how du and df calculate disk usage.
Using du and df to check root partition size
root# du -k -d 1 /
628 /run
41736 /etc
0 /dev
6761392 /root
6905636 /var
4 /media
4 /mnt
206096 /boot
2247520 /opt
30812 /home
0 /proc
16 /lost+found
10319996 /usr
0 /sys
4 /srv
168 /tmp
26514016 / df -k
Filesystem 1K-blocks Used Available Use% Mounted on
devtmpfs 1856388 0 1856388 0% /dev
tmpfs 1866776 0 1866776 0% /dev/shm
tmpfs 1866776 628 1866148 1% /run
tmpfs 1866776 0 1866776 0% /sys/fs/cgroup
/dev/vda1 41152812 26803328 12445776 69% /
tmpfs 373356 0 373356 0% /run/user/0du reports the root directory / size as 26,514,016 KB.
df reports the root directory / size as 26,803,328 KB.
df (Disk Free) calculates free space based on the filesystem's block allocation map, while du (Disk Used) sums the apparent sizes of files and directories, which can lead to differences.
Deleted files that are still held open by running processes are not counted by du, but df still sees the occupied blocks. Use lsof | grep deleted to locate such files.
Linux filesystems reserve a percentage (commonly 5%) of space for the root user; this reserved space is reflected in df but not in du.
When using du -sh *, hidden files (those beginning with a dot) are omitted, causing du to under‑report.
If a process has an open file that gets deleted, du will not count it, whereas df will still show the space as used.
When a data disk is mounted over a directory that already contains files, du cannot see the original files beneath the mount point, while df reports the space used on the underlying filesystem.
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.
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.
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.
