df -k on a Veritas File System (VxFS) free space is not the same as available space

Article:TECH72506  |  Created: 2009-01-18  |  Updated: 2012-04-05  |  Article URL http://www.symantec.com/docs/TECH72506
Article Type
Technical Solution

Product(s)

Issue



df -k on a Veritas File System (VxFS) free space is not the same as available space


Solution



Due to the dynamic inode allocation functionality on a Veritas File System (VxFS), free space is not the same as available space.  This can lead to confusion when calculating space limits on VxFS.  For example on a newly created file system:

bash-3.00# mkfs -F vxfs /dev/vx/rdsk/datadg/testvol
   version 7 layout
   8388608 sectors, 4194304 blocks of size 1024, log size 16384 blocks
   largefiles supported
bash-3.00# mount -F vxfs /dev/vx/dsk/datadg/testvol /testvol
bash-3.00# df -k /testvol
Filesystem            kbytes    used   avail capacity  Mounted on
/dev/vx/dsk/datadg/testvol
                    4194304   18520 3914805     1%    /testvol

In this example we created a VxFS file system on a 4G device creating 4194304 1k blocks.  VxFS will use some of this space for structural data such as the Intent Log, Free Extent Bitmaps, Superblocks, etc.  When you calculate space available, it seems to be off: used (18520k) + avail (3914805k) = 3933325k yet the file system size is 260979k larger.  Where did this extra space go?

The answers lies in how VxFS calculates 'avail' space for the statvfs or statvfs64 system call:

bash-3.00# truss -v all -t statvfs df -k /testvol
statvfs64("/testvol", 0x0804737C)               = 0
       bsize=8192       frsize=1024      blocks=4194304  bfree=4175784
       bavail=3914805   files=1043948    ffree=1043944   favail=1043944
       fsid=0x3949471   basetype=vxfs    namemax=255
       flag=ST_NOTRUNC
       fstr=""
Filesystem            kbytes    used   avail capacity  Mounted on
/dev/vx/dsk/datadg/testvol
                    4194304   18520 3914805     1%    /testvol

VxFS will make some assumptions on how many files will be used in this file system based on an industry standard average of 4 blocks of data per inode.  Each VxFS inode consumes 256 bytes for structure and in our sample file system that has bfree=4175784  blocks free so for the purpose of calculation VxFS assumes 4175784 / 4 = 1043946 inodes will be created on this file system.  1043946 * 256 = 267250176 or 260986 blocks which explains the different between blocks avail and blocks free.  It is possible to use the free space available for file data if a smaller number of files is used.  To accurately find the total amount of free space on Solaris would be to use the 'df -b' command.
 


Legacy ID



327970


Article URL http://www.symantec.com/docs/TECH72506


Terms of use for this information are found in Legal Notices