I'm having a trouble understanding how df
reports the size of filesystems:
$ df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sda3 924815840 63819748 813948260 8% /
--snip--
For the root partition here's how I interpret the results:
1K-blocks column this is the total size of the filesystem in 1K-block units. In other words, for /dev/sda3:
Total size of the filesystem (in bytes) = 1024 * 924815840
Reserved blocks size (in 1K units) = 924815840 - (63819748 + 813948260)
<Used>
and <Available>
columns only list the used blocks of regular users, excluding the reserved ones. Let's run df -h
now to check results:
Filesystem Size Used Avail Use% Mounted on
/dev/sda3 882G 61G 777G 8% /
I was puzzled by the G
, df
reports in Gib
though, not sure why they choose Gib
suffix instead of Gib
. Same for the 1K
, it's really 1Kib. Now, I don't want to play smart here, who got the time for human intelligence these days! If you convert the units as I computed them above, you'll see that the values match, hence my interpretation of the size reported by df
is right. The problem starts when you run fdisk
which reports totally different filysystem sizes:
Device Start End Sectors Size Type
/dev/sda3 72265728 1953523711 1881257984 897.1G Linux filesystem
The size is substantially higher here (897.1G) as opposed to the one reported by df
(882G), thank's fdisk
for giving me more space! But I would like to know which command is telling the truth?