Operating System - HP-UX
1823258 Members
3311 Online
109648 Solutions
New Discussion юеВ

List all physical volumes and their respective sizes

 
Jason Arrhaman
Occasional Advisor

List all physical volumes and their respective sizes

How can I display all physical volumes and their sizes in HPUX? I can't use SAM because I need to pipe the output to a file.

Thanks.
17 REPLIES 17
Uday_S_Ankolekar
Honored Contributor

Re: List all physical volumes and their respective sizes

vgdisplay -v will give you the list of volumegroups and related physical volumes

If you want details of each vg
then vgdidisplay -v /dev/vgname

at the end of vgdisplay you will notice physical volumes

you can see pvdisplay /dev/dsk/devname to see details of PV.

-USA..
Good Luck..
Steven E. Protter
Exalted Contributor

Re: List all physical volumes and their respective sizes

vgdisplay -v /dev/vg00 > /tmp/vgfile
vgdisplay -v /dev/vg01 >> /tmp/vgfile

Repeat second command for every volume group.

Take out the -v if it gives you too much info.

SEP

Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Stefan Farrelly
Honored Contributor

Re: List all physical volumes and their respective sizes

cd /dev/rdsk
for i in $(ls)
do
echo $i
diskinfo $PWD/$i 2>&1 | grep -i size
done
Im from Palmerston North, New Zealand, but somehow ended up in London...
Ramkumar Devanathan
Honored Contributor

Re: List all physical volumes and their respective sizes

hi try this -

for disk in `ioscan -funC disk | awk '/dev/ {print $NF}'`
HPE Software Rocks!
Ramkumar Devanathan
Honored Contributor

Re: List all physical volumes and their respective sizes

$cat disksize.sh
#!/usr/bin/ksh
for disk in `ioscan -funC disk | awk '/dev/ {print $NF}'`
do
echo "disk: $disk"
diskinfo -v $disk | grep -i size
done

the earlier post did not come out fine. ignore earlier post please.

HTH.

- ramd.
HPE Software Rocks!
Geoff Wild
Honored Contributor

Re: List all physical volumes and their respective sizes

Try this script.
It's called vgttl.

Rgds..Geoff
Proverbs 3:5,6 Trust in the Lord with all your heart and lean not on your own understanding; in all your ways acknowledge him, and he will make all your paths straight.
Bill McNAMARA_1
Honored Contributor

Re: List all physical volumes and their respective sizes

if you insist on PV size, and *just* those configured in VGs , then collect your /dev/dsk device files from

strings /etc/lvmtab | grep dsk

ie:

for DISC in $(strings /etc/lvmtab | grep dsk)
do
#sed the dsk for rdsk
#pvdisplay | grep ..
done
It works for me (tm)
Geoff Wild
Honored Contributor

Re: List all physical volumes and their respective sizes

oops - you will also need bdfmegs....

Here's sample output from vgttl:

# vgttl
VG Size(MB) In use Available
vg00 12940 5216 7481
vg01 12288 1807 10154
vg11 4096 1234 2695
vg12 129420 95381 33773
vg15 43140 9515 33364
vg18 15360 6182 8800
vg19 20176 8087 11589
vg20 35800 7342 27211
vg21 138048 125248 12486
vg22 138048 125172 12578
vg23 138048 131748 6218
vg24 138048 130182 7778
vg25 138048 128548 9379
vg26 138048 124050 13782
vg27 138048 119578 18114
vg28 138048 121159 16683
vg29 138048 134048 3872
vg40 25880 1533 23843
---- -------------- -------------- --------------
Totl 1541532 1276030 259800
Proverbs 3:5,6 Trust in the Lord with all your heart and lean not on your own understanding; in all your ways acknowledge him, and he will make all your paths straight.
John Meissner
Esteemed Contributor

Re: List all physical volumes and their respective sizes

below is a script file that will display each vg in MB.

vgs=$( bdf | awk '{print $1}' | awk -F/ '{print $3}' | sort | uniq)
for i in $vgs
do
vgdisplay /dev/$i > $i.vg.txt
pesz=$(cat $i.vg.txt | grep "PE Size" | awk '{print $4}')
tpe=$(cat $i.vg.txt | grep "Total PE" | awk '{print $3}')
(( vgsz = $pesz * $tpe ))
echo $i is $vgsz MB
done
All paths lead to destiny
John Meissner
Esteemed Contributor

Re: List all physical volumes and their respective sizes

I aslo wrote a script that will tell you the size of all your external disks.....
it will tell you the total size of your EMC disks and list each disk and tell you a total of how many of which various sizes you have as well.

This is assuming that you have EMC disks and that the "inq" utility is located in /var/adm/scripts

All paths lead to destiny
Jason Arrhaman
Occasional Advisor

Re: List all physical volumes and their respective sizes

All of these are good suggestions, and I sincerely thank all of you. However I'm curious to know if anyone can tell me how to take the output from 'ioscan -kfC disk' and append to each disk it's respective size as another column on the end. Perhaps even leaving off the Class column in the final output just to get more room.

Thank you again.
Stuart Abramson_2
Honored Contributor

Re: List all physical volumes and their respective sizes

#
# 1. Device layout by physical address
#
print "\n1.\tDEVICE LAYOUT (sorted by physical address):\n"
print " Device \t Address \t Vendor \t Product \t Size \n"

HWADDRs=`ioscan -fkCdisk | grep "^disk" | awk '{print $3}'`
for ADDR in $HWADDRs
do
DEV=`lssf /dev/dsk/c* | grep "$ADDR" | awk '{print $16}' | cut -d/ -f4`
VENDOR=`ioscan -fkH$ADDR | grep disk | awk '{print $7}' `
PROD=`ioscan -fkH$ADDR | grep disk | awk '{print $8}' `
if [[ $PROD = CD-ROM ]]
then
SIZE=""
else
SIZE=`diskinfo /dev/rdsk/$DEV | grep size: | awk '{print $2}' `
fi
print " " $ADDR "\t" $DEV "\t" $VENDOR " \t" $PROD "\t" $SIZE >> /tmp/disks.$$
done
John Meissner
Esteemed Contributor

Re: List all physical volumes and their respective sizes

this script will tell you the size of each PV as well as to what VG it belongs to

the following script may come up with errors. to view only pertinate information you may wish to redirect standard error to /dev/null
this can be done by issuing the command like this:
yourscript 2> /dev/null


ioscan -fnkC disk | grep ^disk | awk '{print $3}' > disk.out
ioscan -fnkC disk | grep /dev | awk '{print $1}' > dev.out
paste disk.out dev.out > dd.out
pv=$(cat dd.out | awk '{print $2}')
for i in $pv
do
vgbelong=$(pvdisplay $i | grep "VG Name")
pesz=$(pvdisplay $i | grep "PE Size" | awk '{print $4}')
tpe=$(pvdisplay $i | grep "Total PE" | awk '{print $3}')
((dsksz=$pesz*$tpe))
echo $i is $dsksz MB and belongs to $vgbelong
done
All paths lead to destiny
Jason Arrhaman
Occasional Advisor

Re: List all physical volumes and their respective sizes

The last script I got only worked partially, It printed out the columns but no data. I get a few error messages. It's the script just above this post.
John Meissner
Esteemed Contributor

Re: List all physical volumes and their respective sizes

jason - could you send me the output files you got (disk.out dev.out and dd.out) to my e-mail address.... it's in my profile. I'll take a look at see what I can figure out.
All paths lead to destiny
John Meissner
Esteemed Contributor

Re: List all physical volumes and their respective sizes

Jason - could you also try to run the pvdisplay commands manually on the files to see what output you get?
All paths lead to destiny
John Meissner
Esteemed Contributor

Re: List all physical volumes and their respective sizes

oh by the way Jason.... something you may want to take care of

--------------------------------
user has assigned 4 of 44 points
--------------------------------
All paths lead to destiny