[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Problem with df utility
From: |
Bob Proulx |
Subject: |
Re: Problem with df utility |
Date: |
Mon, 3 May 2004 22:50:30 -0600 |
User-agent: |
Mutt/1.3.28i |
Reji K Mathew wrote:
> While I am running a df command the output I am getting have some
> mismatches.
>
> The total space, available space and used space are not matching.
Uh, I can't resist saying that if they were to match then one of the
columns would be redundant and would not need to be displayed. Just
joking. :-)
> I am attaching the df output with this mail.
>
> Filesystem Size Used Avail Use% Mounted on
> /dev/cciss/c0d0p2 3.0G 2.5G 327M 89% /
> /dev/cciss/c0d0p1 38M 3.8M 32M 11% /boot
> /dev/cciss/c0d0p3 4.9G 4.3G 424M 92% /oracle
> /dev/cciss/c0d0p5 24G 21G 2.3G 90% /oracle/data1
> /dev/cciss/c0d0p7 24G 22G 1.0G 96% /oracle/data2
> /dev/cciss/c0d0p13 24G 19G 3.8G 84% /oracle/data3
> /dev/cciss/c0d0p14 24G 21G 2.7G 88% /oracle/data4
> /dev/cciss/c0d0p9 29G 21G 7.2G 74% /oracle/index1
> /dev/cciss/c0d0p11 19G 17G 2.2G 88% /oracle/index2
> /dev/cciss/c0d0p15 6.9G 6.0G 588M 92% /tmp
>
> Can you give an explanation for this problem.
I don't see any problems with that output. But a common confusion is
that people forget about the filesystem's "minfree" value.
Here is an example:
df -l /mnt/a
Filesystem 1k-blocks Used Available Use% Mounted on
/dev/sda8 61156396 31912492 26137340 55% /mnt/a
echo '31912492+26137340' | bc -ql
58049832 # non-system space
echo '(61156396-58049832)' | bc -ql
3106564 # system reserved space
echo '(61156396-58049832)/61156396' | bc -ql
.05079704173542208079 # percentage of minfree, 5% in this case
I have a 5% minfree reserved for system use. That will not show up as
available space.
When the filesystem is created 5%-10% of the total disk space will be
reserved by the filesystem as 'minfree'. This is available only to
root processes and not to non-root processes. The amount of minfree
is dependent upon the defaults of the particular mkfs. You probably
have 5% unless you changed it. Also some disk space will be used by
Inodes in some filesystems. On others it is dynamic.
Secondly the 'df' command is just returning data from the statfs(2)
call.
struct statfs {
long f_type; /* type of filesystem (see below) */
long f_bsize; /* optimal transfer block size */
long f_blocks; /* total data blocks in file system */
long f_bfree; /* free blocks in fs */
long f_bavail; /* free blocks avail to non-superuser */
long f_files; /* total file nodes in file system */
long f_ffree; /* free file nodes in fs */
fsid_t f_fsid; /* file system id */
long f_namelen; /* maximum length of filenames */
long f_spare[6]; /* spare for later */
};
So disk is usually total - minfree - inodes - free but the command
does not compute it. The df command is just reporting what the
filesystem has precomputed for those values.
Also remember that when approaching a completely full disk the
performance of the filesystem can degrade exponentially. It is then
difficult for the filesystem to find free disk blocks and won't be
able to automatically produce defragmented physical layout. A small
percentage of minfree is required to ensure reasonable performance. I
believe this plus ensuring root having a little extra when users
filled the disk were the original reasons for minfree. It used to be
10% but has been reduced to 5% in recent years because of the much
larger disk capacity.
Bob