[lug] df discrepancies between used, available and total size

Anthony Foiani tkil at scrye.com
Fri Jan 6 00:47:19 MST 2012


karl horlen <horlenkarl at yahoo.com> writes:

> example:
>
> size:769G
> used:197M (yeah that's an M)
> avail: 730G
>
> that's like a 39G discrepancy (wasted space) on my /home lv partition.  wtf?

Various unix filesystems traditionally reserved some space for the
root user (so that a regular user couldn't fill up the entire disk).
The traditional value was 5%, which is in line with the numbers you
show here:

  (769-730)/769 = 5.07%
  (12-11.1)/12  = 7.50%
  (15-14)/15    = 6.67%

> is this normal?.

Yes.

> i can't recall seeing such wide gaps on servers i've installed /
> managed over the years.  was i not paying close enough attention?
> am i missing something?

Well, when the disks were smaller, the reserve was smaller as well.

> is there space set aside / reserved when the partition is relatively
> empty?

Assuming this is ext2 (or ext3 or ext4), then yes, it's reserved.
Dunno about XFS and other alternate FSs.  BTRFS, in particular, has a
very wonky concept of "free space".

> just wondering if i should be checking for something or if someone
> can enlighten me about that 39G missing space

It's just 5% of a large hard drive.  Note that some things have also
gotten larger since then; if you ever need to dump your entire RAM
image to disk, you probably do want mulitple GB reserved.

I don't recall exactly how to fix it, but the command is "tune2fs" for
the ext* filesystems.  [Scans manpage...]

       -m reserved-blocks-percentage
              Set the percentage of the filesystem which may only be
              allocated by privileged processes.  Reserving some
              number of filesystem blocks for use by privileged
              processes is done to avoid filesystem fragmentation,
              and to allow system daemons, such as syslogd(8), to
              continue to function correctly after non-privileged
              processes are prevented from writing to the filesystem.
              Normally, the default percentage of reserved blocks is
              5%.

       -r reserved-blocks-count
              Set the number of reserved filesystem blocks.

So something like you could do this to reserve only 1%:

  sudo tune2fs -m 1 /dev/whatever 

You might have to do that with the FS offline, but maybe not.

Or you can do the math on your block size and the amount of reserve
you want to have around.  There are probably guides available for
that...

Happy hacking,
t.



More information about the LUG mailing list