Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can I quickly see disk usage for my entire system?

Disk and filesystem management

How can I quickly see disk usage for my entire system?

by  bi  Posted    (Edited  )
The following script can be used to quickly see the layout of your filesystems on your disks, which disks are fully used and which have space available.

This script is in The AIX Survival Guide by Andreas Siegert published by Addison-Wesley, Copyright 1996.

The script first gives a summary of all disks, including its volume group, name, size of physical partitions, number of physical partitions that are used, number that are free, the hardware address, and the type of disk it is. Next, details of each disk and the logical volumes that are on the disk are given, including the number of logical partitions and distribution of the data on the disk.

Here is the script:

#!/usr/bin/ksh
# diskinfo

export LANG=C
export LC_MESSAGES=en_US

DoPV=0
DoFS=0
DoLV=0
DoNA=0

if [[ $# -ge 1 ]] ; then
for opt
do
case $opt in
-d) DoPV=1
;;
-f) DoFS=1
;;
-l) DoLV=1
;;
-n) DoNA=1
;;
*) echo "Unknown parameter $opt"
echo "Usage:\n$(basename $0) [-d][-f][-l][-n]"
echo " -d: disks and volume groups"
echo " -f: file systems"
echo " -l: logical volumes without file systems"
echo " -n: unallocated disks"
exit 1
;;
esac
done
else
DoPV=1
DoFS=1
DoLV=1
DoNA=1
fi

echo "Disk report for $(hostname -s) (machine id $(uname -m))\n"

disks=$(lspv | egrep -v None | cut -f1 -d\ )

[[ $DoPV -eq 1 ]] && {
echo "Disks and Volume groups"
echo " Physical partitions"
echo "VG PV size used free Location Description"
for d in $disks
do
(lsdev -Cl $d | sort -k 1; lspv $d ) |
awk '/Available/ {d=$1;loc=$3;
desc=substr($0,index($0,$4));
next}
/VOLUME GROUP/ {vg=$6;next}
/PP SIZE/ {sz=$3;next}
/FREE PP/ {free=$3;next}
/USED PP/ {used=$3;next}
END {printf("%-12s %-8s %4d %5d %5d %-12s %s\n",
vg,d, sz,used,free,loc,desc)}
'
done
echo ""
}

[[ $DoNA -eq 1 ]] && {
lspv | egrep None > /dev/null
if [[ $? -eq 0 ]] ; then
echo "Unallocated physical volumes:"
for d in $(lspv | egrep None | cut -f1 -d\ )
do
lsdev -Cl $d
done
else
echo "No unallocated physical volumes"
fi
echo ""
}

(( ($DoLV+$DoFS) >= 1 )) && {
echo "VG Disk LV LPs Distribution Mount Point"
for d in $disks
do
vg=$(lspv|awk "/$d/ {print \$3}")
(echo "$d $vg"
[[ DoFS -eq 1 ]] && lspv -l $d | tail +3 | egrep " /"
[[ DoLV -eq 1 ]] && lspv -l $d | tail +3 | egrep -v " /"
) | awk '{ if (NR==1) {
disk=$1
vg=$2
} else {
printf("%-12s %-8s %-12s %-5s %-15s %s\n",
vg,disk,$1,$2,$4,$5)
}
} '
done
echo ""
}
Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top