Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Disk and filesystem management

How can I quickly see disk usage for my entire system? by bi
Posted: 13 Sep 02

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:

# diskinfo

export LANG=C
export LC_MESSAGES=en_US


if [[ $# -ge 1 ]] ; then
    for opt
        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

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
        (lsdev -Cl $d | sort -k 1; lspv $d ) |
        awk '/Available/   {d=$1;loc=$3;
            /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)}
    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\ )
            lsdev -Cl $d
        echo "No unallocated physical volumes"
    echo ""

(( ($DoLV+$DoFS) >= 1 )) && {
echo "VG           Disk     LV           LPs   Distribution       Mount Point"
for d in $disks
    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) {
            } else {
                printf("%-12s %-8s %-12s %-5s %-15s %s\n",
        } '
echo ""

Back to IBM: AIX FAQ Index
Back to IBM: AIX Forum

My Archive

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close