# man df
df - displays number of free disk blocks and free files
# /usr/bin/df [-F FSType] [-abeghklntVvZ] [-o FSType-specific_options] [block_device | directory | file | resource …]
The df utility displays the amount of disk space occupied by mounted or unmounted file systems, the amount of used and available space, and how much of the file system's total capacity has been used. The file system is specified by device, or by referring to a file or directory on the specified file system.
-b Prints the total number of kilobytes free.
-t Prints full listings with totals in sectors
-k Prints the allocation in kbytes for the total space allocated in the file system, the amount of space allocated to existing files, the total amount of space available for the creation of new files and the percentage of normally available space that is currently allocated to all files on the file system.
VxFS df command
# man df_vxfs
df_vxfs - report the number of free disk blocks and inodes for a VxFS file system
# /usr/lib/fs/vxfs/df [ -F vxfs ] [ generic_options ] [ -o { s | ckpt=ckpt_name | ckptall | snapstat | vols } ] [ directory | special ... ]
The df command prints the number of free blocks and free inodes in VxFS file systems or directories based on the counts kept in the super-blocks.
-b Prints the total number of sectors free ( 512bytes) [Note: -b has a different meaning in the Solaris native df command]
-t Report the total allocated block and the number of free sectors ( 512 bytes)
To determine the “true” available free space on a new created filesystem, consider the following example:
Create a new 2g filesystem with default block size of 1024 bytes and mount the file system
# vxassist -g testdg make volt 2g
# mkfs -F vxfs /dev/vx/rdsk/testdg/volt
version 7 layout
4194304 sectors, 2097152 blocks of size 1024, log size 16384 blocks
largefiles supported
where volume size (filesystem size) = 2g = 4194304 sectors = 2097152 Kbytes
# mount -F vxfs /dev/vx/dsk/testdg/volt /tmnt
For the default Solaris “/usr/bin/df” command we have:
# /usr/bin/df -k /tmnt
Filesystem kbytes used avail capacity Mounted on
/dev/vx/dsk/testdg/volt 2097152 18006 1949207 1% /tmnt
# /usr/bin/df -t /tmnt
/tmnt (/dev/vx/dsk/testdg/volt): 4158292 blocks 519784 files (value in sectors)
total: 4194304 blocks 519788 files (value in sectors)
# /usr/bin/df -b /tmnt
Filesystem avail
/dev/vx/dsk/testdg/volt 2079146 ( value in Kbytes)
The numbers in “BOLD” represent expected values , so only the “avail” fields from df -k is NOT consistent with a new filesystem ( where 2097172 -18006 = 2079146 not 1949207)
Using the alternative “/usr/lib/fs/vxfs/df” command we need to consider that VxFS dynamically allocates inodes from a pool of free blocks. The number of free inodes and blocks reported by "/usr/lib/fs/vxfs/df" is an estimate based on the number of free 8K or larger extents and the current ratio of allocated inodes to allocated blocks. (Extents smaller than 8K may not be usable for all types of allocation, so "/usr/lib/fs/vxfs/df" does not count free blocks in extents smaller than 8K.) Allocating additional blocks may therefore decrease the count of free inodes and vice versa. So we now have the following.
# /usr/lib/fs/vxfs/df -k /tmnt
Filesystem kbytes used avail capacity mounted on
/dev/vx/dsk/testdg/volt 2097152 147945 1949207 7% /tmnt
#/usr/lib/fs/vxfs/df -t /tmnt
/tmnt (/dev/vx/dsk/testdg/volt): 3898414 blocks 519784 files (value in sectors)
total: 4194304 blocks 519788 files (value in sectors)
#/usr/lib/fs/vxfs/df -b /tmnt
Filesystem avail
/tmnt 3898414 ( value in sectors)
Note: The value of “/usr/bin/df -b /tmnt” is in Kbytes and “/usr/lib/fs/vxfs/df -b” is in sectors.
The inodes on a Veritas File System (VxFS) file system are allocated dynamically, so the inode list is not fixed in size and grows dynamically on an as-needed basis. VxFS takes into account the estimated size of the inode list when it reports the available space in the "/usr/lib/fs/vxfs/df" output. All the values reported are consistence but it always deducts the estimated size of the ilist file before displays the value in df -k avail field which may sometimes causes confusion.
Confirm filesystem block size
# fstyp -v /dev/vx/rdsk/testdg/volt |grep ^bsize
bsize 1024 size 2097152 dsize 0 ninode 2097152 nau 0
From the "df -t" output, it displays an estimation of how many average file of size= bsize*4=4KB (or 8*512bytes) can be created for a newly file system using the true available free space. For each file an inode must exist in the dynamic ilist and each inode requires 256 bytes to store this information.
Estimated size of the inode list required to manage the average 4k files for a filesystem with 1K block size
= {(Estimated number of files from df -t) * (size of each inode in bytes)} /1024 Kbytes
= {519784 * 256 )}/1024 Kbytes
= 129946 Kbytes
Check the approximate size of the metadata using the ncheck command:
# ncheck -F vxfs -o block= /dev/vx/dsk/testdg/volt |tail -1
- - - - - 0/18712-0/2097151
All 1k blocks up to 18711 are being used for metadata already. Last line indicates the largest chuck of free space available on a filessytem. There will be some other small chuck of free space but they can be ignored for the estimation. (Please note that we are checking a newly created file system in our example. No space is allowed to any user file yet.)
Estimated used space = Estimate size of inode list file + size of metadata (Kbytes)
= 129946 Kbytes + 18711 Kbytes
= 148657 Kbytes
But the actual calculation is more complicated but it is a good estimate and very close to the avail value =147945 from the “# /usr/lib/fs/vxfs/df -k /tmnt” output above.
So in summary, we can use the default “/usr/bin/df -b” command to determine the true available free space (as it does not take any account of what space the ilist will require as it dynamically grows on usage of the filesystem.
O n a running system the output from “/usr/lib/fs/vxfs/df -k” gives a hint on how VxFS manages its own inode list to ensure there is adequate space available to grow the ilist. The “/usr/lib/fs/vxfs/df -k” become more accurate as the available free space drops which causes the estimated size of the inode list to become smaller.
ilist size for a new filesystem can be displayed as follows:
For a newly created filesystem, the default ilist size is 8192 bytes.
#echo "1fset.65i" |fsdb -F vxfs /dev/vx/dsk/testdg/volt | grep " size"
type IFILT mode 4000000777 nlink 1 uid 0 gid 0 size 8192
32 * 256 bytes = 8192 bytes (by default 32 empty inodes are created on a new filesystem)
After adding some empty files (74393) we have:
# cd /tmnt; ls | wc -l
74393
The actual ilist size = 74393 * 256 bytes = 19044608 bytes, but the estimated size of the ilist is much larger than it.
# df -k /tmnt
Filesystem kbytes used avail capacity Mounted on
/dev/vx/dsk/testdg/volt 2097152 335898 1651265 17% /tmnt
Estimated ilist size is:
(2097152 KByte - 335898 KByte) / 4 KB/inode * 256 bytes per inode / 1024 KB
= 110078 KB
# echo "1fset.65i" |fsdb -F vxfs /dev/vx/dsk/testdg/volt | grep " size"
type IFILT mode 4000000777 nlink 1 uid 0 gid 0 size 19136512
Actual ilist size is only 19136 KB.