Skip to contentSkip to conversation

findmnt/df discrepancy

DISCUSSION Bruce Dubbs 4 participants 4 messages Feb 12, 2014 – Feb 21, 2014 Util-Linux package

lore
Share & tools
lore
#0 lore raw

I've noticed a discrepancy in percent free between findmnt and df:

$ df -h|grep /tmp
/dev/sdb5        9.8G  8.3G  967M  90% /tmp
$ findmnt --df|grep /tmp
/dev/sdb5  ext4  9.7G  8.3G  967M  85% /tmp

Actually, the discrepancy seems to be df as 8.3/9.8 is 84.7%.
Can anyone here explain the difference? Should it be submitted to coreutils as a bug?

-- Bruce

#1 lore raw
Quoted 10 lines · Bruce Dubbs

I've noticed a discrepancy in percent free between findmnt and df:

$ df -h|grep /tmp
/dev/sdb5        9.8G  8.3G  967M  90% /tmp
$ findmnt --df|grep /tmp
/dev/sdb5  ext4  9.7G  8.3G  967M  85% /tmp

Actually, the discrepancy seems to be df as 8.3/9.8 is 84.7%. Can anyone here explain the difference? Should it be submitted to coreutils as a bug?

It's the reserved space on the filesystem. On an ext4 FS where the reserved space is 0%, df and findmnt (mostly) agree:

$ df -h | grep Gluttony
 /dev/sdb2             1.8T  701G     1.1T  39% /mnt/Gluttony
$ findmnt --df | grep Gluttony
 /dev/sdb2     ext4    1.8T  700.1G   1.1T  39% /mnt/Gluttony
#2 lore raw

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

Quoted 2 lines · Dave Reisner

It's the reserved space on the filesystem. On an ext4 FS where the reserved space is 0%, df and findmnt (mostly) agree:

Why would findmnt report a different value? It is the kernel that adjusts the numbers it returns in statfs(), which both should be using.

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.14 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQEcBAEBCgAGBQJS/ublAAoJEI5FoCIzSKrwhYwH/RQeM8f0vTACy6bRGzCtFyPy YJL4/GAJk2B4tTPGqcAUFaByu5XR760unjMvk6TRUjgvPtJN35oaF0SwYqA68o7Q GviH5+21hztANKQz/JO6RZPbzueEttSlCsAjNbhuFmY/+ysMkxGA9inlNyE14MU0 pGOfTtpw0vAAJFX0+7gjGZZkOsm8yYH4yhb0ERoQACYZxrcFLRaqxV+V3eKhtZuo tFvP2mNXCPk4AyP9oXaepPESBaZmmPNh81FvZBAarZURKefPJDw5TJslZmeLAO1O fWUmEa+xBexX7jSwqgdeIYk0Inci+X2kTx5dckkQM9LcnVqJ67nYufb+IDzQoow= =USil
-----END PGP SIGNATURE-----

maintainer
#3 lore raw
Quoted 9 lines · Phillip Susi

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

Quoted 2 lines · Dave Reisner

It's the reserved space on the filesystem. On an ext4 FS where the reserved space is 0%, df and findmnt (mostly) agree:

Why would findmnt report a different value? It is the kernel that adjusts the numbers it returns in statfs(), which both should be using.

I have added a new option --bytes to findmnt(8) (we already have the same option in lsblk(8)), so now it's more obvious:

        $ df --block-size=1 /dev/sda5
        Filesystem         1B-blocks        Used   Available Use% Mounted on
        /dev/sda5        66650419200 39057010688 24184123392  62% /home
        $ findmnt --df --bytes
        /dev/sda5
        SOURCE    FSTYPE        SIZE        USED       AVAIL USE% TARGET
        /dev/sda5 ext4   66650419200 39057010688 24184123392  59% /home

so yes, both use the same numbers from statvfs(), but findmnt(8) counts USE% from the USED field, but df(1) counts Use% from the Available column.

The conversion to human readable sizes is another story:

        $ findmnt --df  /dev/sda5
        SOURCE    FSTYPE  SIZE  USED AVAIL USE% TARGET
        /dev/sda5 ext4   62.1G 36.4G 22.5G  59% /home
        $ df -h /dev/sda5
        master
        Filesystem      Size  Used Avail Use% Mounted on
        /dev/sda5        63G   37G   23G  62% /home

for example available space:

        $ echo "24184123392 / (1024 * 1024 * 1024)" | bc -l
        22.52322006225585937500

Karel

Signature · 2 lines
 Karel Zak  <[email protected]>
 http://karelzak.blogspot.com