df report incorrect free space for a filesystem (ext4)

I am facing an issue with wrong fs space reported by df.

We are talking about bare metal Ubuntu 14.04 server, with the / partition managed by LVM.

Size reported by df is different from the size reported by fs super-block. Also calculating size from du -skh (on directories related to / partition) proves that df is showing incorrect results.

This is what reported by df:

Filesystem                  Size  Used Avail Use% Mounted on
/dev/mapper/rootvg-lv_root   20G   16G  2.8G  86% /

This is what super-block reports (3616906*4096/1024**2=14128 MB free):

Last mounted on:          /
Filesystem magic number:  0xEF53
Filesystem state:         clean
Filesystem OS type:       Linux
Inode count:              1290240
Block count:              5242880 << exactly 20 GB
Reserved block count:     227170
Free blocks:              3616906 << around 14 GB free
Free inodes:              1201391
First block:              0
Block size:               4096
Fragment size:            4096

I did a strace for df and found that it uses the statfs syscall to get information about a particular fs (962132*4096/1024**2=3758 MB free):

statfs("/", {f_type="EXT2_SUPER_MAGIC", f_bsize=4096, f_blocks=5129119, f_bfree=**962132**, f_bavail=730866, f_files=1290240, f_ffree=1091851, f_fsid={-456623966, 1549023591}, f_namelen=255, f_frsize=4096}) = 0

Probably the problem with statfs or with a way how it fetches fs information.

To solve it I tried to remount / partition (mount / -orw,remount), but it didn't help.

My question - how can I fix df information without rebooting or disturbing normal operation of this server?

P.S.

  • there are no fd on hold by process (lsof +L1 | grep deleted)
  • I aware that 883 MB is reserved for user with UID 0
  • This is not a mount point masking issue (when mounted fs 'hide' files in mount point directory)

Solution 1:

in sake of fellows who stuck with same issue:

i solved it by issuing unmount /dev/mapper/rootvg-lv_root. it gave me an error, but after df reported correctly.

looks like umount refreshed some internal structs.

hope it help someone.