duf icon indicating copy to clipboard operation
duf copied to clipboard

Different percentage as df

Open martinszy opened this issue 5 years ago • 5 comments

So df says this: /dev/mapper/ubuntu--vg-root 232G 210G 9.8G 96% /

And duf says this: │ / │ 231.5G │ 209.9G │ 9.8G │ [##################..] 90.7% │ ext4 │ /dev/ubuntu--vg/root │

Why is this 90.7 vs 96 percentage difference?

This is on Ubuntu 20.04.1 with duf 3.1 and df 8.3.0

martinszy avatar Sep 30 '20 17:09 martinszy

The explanation is that the file systems reserves a certain amount of space and inodes for use by root (by default the amount of reserved space is 5%). Especially with bigger partitions this can be a significant amount of space that is not usable for services or users other than root.

df shows the same free/avail space, but then for some reason decides to exclude the reserved space from the percentage calculation. I always found that a bit weird, so I decided to ignore the reserved space in duf.

There's an argument to be had whether duf should deduct the reserved space when running as non-root. Opinions?

muesli avatar Sep 30 '20 17:09 muesli

So my calculations are that 95.7% is the real percentage of occupied space in the disk, according to the numbers both software are reporting. Why whould duf say theres only 90%? If you're deducting a 5% from the percentage why wouldn't you also do it from the occupied space?

If there's this reserved number, I think it should be reported separately and then added to the sum of space that is not available.

Thanks my opinion at this point, but I just found out about this 5% reserved space, why is that?

martinszy avatar Sep 30 '20 17:09 martinszy

209.9G / 231.5G = 90.66% used. You can read more about ext's reasons here: https://unix.stackexchange.com/questions/7950/reserved-space-for-root-on-a-filesystem-why

muesli avatar Sep 30 '20 18:09 muesli

I was calculating from the reported free space, that's where the difference comes from.

martinszy avatar Sep 30 '20 18:09 martinszy

Ah, I see! Yeah, there's definitely room for improvement here.

muesli avatar Sep 30 '20 19:09 muesli