Home > Back-end >  How does the df command calculate "used space" in percentage?
How does the df command calculate "used space" in percentage?

Time:11-25

Here's the output of

$df -k /
Filesystem     1kB-blocks     Used Available Use% Mounted on
/dev/sda2       470306374 94552036 351788872  22% /

Shouldn't it be (Used / Available) * 100? But the result I get is 26.8% instead of 22% in my system.

CodePudding user response:

No, free space would be (used / total), not divided by available. Available is the free space left.

In other words, 94,552,036 / (94,552,036 351,788,872), which is 94,552,036 / 446,340,908, or 0.2118, giving you the 22% you see (most likely rounding up, though you would have to look at the source code to be certain).

  • Related