7

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)
13
  • What is the problem you want to fix? Aug 7, 2016 at 11:26
  • Our monitoring is rely on df output. All I want - correct information to be reported by df.
    – Tom Lime
    Aug 7, 2016 at 11:31
  • 4
    Possible duplicate of du vs. df difference
    – user9517
    Aug 7, 2016 at 14:01
  • 2
    @KarenB Unlinked files would cause du-vs-df inconsistency, but shouldn't cause df to be wrong.
    – Barmar
    Aug 9, 2016 at 19:00
  • 1
    What does du -skh --apparent-size / would show? Can you allocate a 3gb file while only 2.8GB reported free by df on / with fallocate -l 3GB /test.file or will it say fallocate failed: No space left on device?
    – Anubioz
    Aug 10, 2016 at 8:25

1 Answer 1

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.

1
  • Helped to me, should be promoted to answer IMHO. Apr 19, 2017 at 14:40

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .