IBM Support

duvg - show space usage in AIX file systems, but sorted by Volume Group

How To


Summary

Show space usage in AIX file systems, but sorted by Volume Group

Objective

Banner_AIX

Environment

Here is an AIX shell script to show the amount of disk space used, but sorted by Volume Group.

I  use this to find the amount of space used by volume groups so that I can tell if a savevg might fit onto a tape or other backup device.
##############################################################################
#                                                                            #
# A simple script to estimate disk usage in filesystems in all volume groups #
#                                                                            #
#          Written by Gareth Coates gaz@uk.ibm.com in November 2019          #
#                                                                            #
#                       Copyright (c) IBM 2019                               #
#                                                                            #
##############################################################################

lsvg | while read VG
do


GB=$(lsvg -l $VG| awk ' !/N\/A|LV|$VG/ { print $7 }' | xargs df -gP | sumcol 3)

echo "
        Estimated disk usage in $VG filesystems is $GB GB
"
done
This script relies upon sumcol - please see this post in this blog.

(For the purists, yes, folks, I know that df and du are different, but I still find this a simple and useful tool)!

Steps

And here is the output: 
blue:/# duvg

        Estimated disk usage in rootvg filesystems is 52.31 GB


        Estimated disk usage in scratchvg filesystems is 7.56 GB


        Estimated disk usage in webvg filesystems is 22.19 GB


        Estimated disk usage in backupvg filesystems is 119.96 GB

This script could easily be ported to other flavors of Unix and to Linux. The particular syntax for the Volume Group would need to change and many flavors do not allow you to specify that the disk free space should be displayed in GB so you might need to change "df -gP".

Additional Information

You can contact me: 

Document Location

Worldwide

Operating System

AIX:All operating systems listed

[{"Business Unit":{"code":"BU058","label":"IBM Infrastructure w\/TPS"},"Product":{"code":"HW1A1","label":"IBM Power Systems"},"Component":"","Platform":[{"code":"PF002","label":"AIX"}],"Version":"All Versions","Edition":"","Line of Business":{"code":"LOB57","label":"Power"}}]

Document Information

Modified date:
03 May 2021

UID

ibm11118109