muesli / duf

Disk Usage/Free Utility - a better 'df' alternative
Other
12.72k stars 395 forks source link

Different percentage as df #44

Open martinszy opened 3 years ago

martinszy commented 3 years ago

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

muesli commented 3 years ago

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?

martinszy commented 3 years ago

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?

muesli commented 3 years ago

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

martinszy commented 3 years ago

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

muesli commented 3 years ago

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