Skip to contentSkip to conversation

df report incorrect free space for a filesystem (ext4)

DISCUSSION Tom 1 participant 1 message Aug 8, 2016

lore
Share & tools
lore

Tom

author
#0 lore raw

Greetings,

This is my first message to community - so please forgive me message format and mistakes I did :-)
I am writing to you, as I have a strong suspect that problem related to filesystem/kernel internals.

I are continuosly having problems with inconsistency of free space reported by df and calculating free size from SB. I are using LVM and ext4 for our volumes (/, /tmp, /opt and etc).
Here is an example of / volume on bare metal server.

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

Super-Block:
Last mounted on:          /
Filesystem magic number:  0xEF53
Filesystem state:         clean
Filesystem OS type:       Linux
Inode count:              1290240
Block count:              5242880
Reserved block count:     227170
Free blocks:              3616906
Free inodes:              1201391
First block:              0
Block size:               4096
Fragment size:            4096

df reports 2.8G free space for /, but by binding fs and calculating with du clearly seen that about ~12GB is free:

    root@none:~# mount -o bind / /tmp/root/
    root@none:~# du -sk /tmp/root/* | awk '{sum += $1} END {print sum}'
    8688976

I tried to remount the fs without any results:

    root@none:~# mount /dev/rootvg/lv_root -oremount,rw
    root@none:~# df -h
    Filesystem                  Size  Used Avail Use% Mounted on
    /dev/mapper/rootvg-lv_root   20G   17G  2.7G  86% /

The problem was resolved by remounting the fs with RO option:

    root@none:~# df -h
    Filesystem                  Size  Used Avail Use% Mounted on
    /dev/mapper/rootvg-lv_root   20G   17G  2.7G  86% /
    root@none:~# mount /dev/rootvg/lv_root -oremount,ro
    mount: / is busy
    root@none:~# mount /dev/rootvg/lv_root -oremount,rw
    root@none:~# df -h
    Filesystem                  Size  Used Avail Use% Mounted on
    /dev/mapper/rootvg-lv_root   20G  8.1G   11G  44% /

By looking for a solution, I found that this topic relatively hot and there are no clear and certain answers.
My questions are:
- what cause to df report wrong information?
- what can be done to proactively avoid it (usually we get an alert on partition and discover the problem)?

P.S.
Here is a link to question i created - http://serverfault.com/questions
/795324/df-report-incorrect-free-space-for-a-filesystem-ext4

Cheers,
Tom