Index | Thread | Search

From:
"Theo de Raadt" <deraadt@openbsd.org>
Subject:
Re: make 'df -hi' more human readable
To:
Job Snijders <job@bsd.nl>
Cc:
tech@openbsd.org
Date:
Wed, 07 Jan 2026 08:00:17 -0700

Download raw body.

Thread
Job Snijders <job@bsd.nl> wrote:

1> On Wed, Jan 07, 2026 at 07:25:18AM -0700, Theo de Raadt wrote:
> > Job Snijders <job@bsd.nl> wrote:
> > > On Wed, Jan 07, 2026 at 11:51:42AM +0000, Crystal Kolipe wrote:
> > > > Whilst I like the general idea, the use of 1000 as a divisor instead
> > > > of 1024 seems very wrong.
> > > 
> > > I also tried using a 1024 divisor, but the results just drifted too far
> > > away from reality for my liking. For example, a power-of-2-based 'mega'
> > > is ~ 5% larger than a power-of-10-based 'mega'. To me it seems a 1024
> > > divisor might mislead the operator about inode availability.
> > 
> > I don't understand this. How many people are requiring precision for
> > the inode count? This is a scheme which intentionally drops 3 digits
> > of precision.
> 
> I use inode count to estimate how much runway I have on certain
> machines, between rounding up and the power-of-2/power-of-10 difference
> for large file systems it adds up.
> 
> -current:
> 
> 	$ df -hi /var/www/htdocs/rpki
> 	Filesystem     Size    Used   Avail Capacity  iused    ifree %iused  Mounted on
> 	/dev/sd0m      2.8T   62.7G    2.6T     3%  8630581 803356617    2%   /var/www/htdocs/rpki
> 
> With my patch:
> 
> 	$ ./obj/df -hi /var/www/htdocs/rpki
> 	Filesystem     Size    Used   Avail Capacity iused  ifree %iused  Mounted on
> 	/dev/sd0m      2.8T   62.6G    2.6T     3%    8.6M   803M    2%   /var/www/htdocs/rpki
> 
> With fmt_scaled(1):
> 
> 	$ ./obj/df -hi /var/www/htdocs/rpki
> 	Filesystem     Size    Used   Avail Capacity iused  ifree %iused  Mounted on
> 	/dev/sd0m      2.8T   62.7G    2.6T     3%    8.2M   766M    2%   /var/www/htdocs/rpki
> 
> With fmt_scaled(1) the df utility reports 37 million fewer inodes than
> actually are available, and worse, it reports 400K more inodes than
> actually are in use. In larger file system the deviation matters.

It is obviously better if it rounds DOWN, than if it rounds UP.

If it rounds down, your eyeball measure will be short at runtime.

I don't think it matters at all.  If you care deeply, you would not
throw away the precision.  Don't use the -h option.