1833163 Members
3668 Online
110051 Solutions
New Discussion

vgdisplay

 
SOLVED
Go to solution
Jonathan Caplette_1
Super Advisor

vgdisplay

hi guys,

I need to output to a file the result of vgdisplay -v command, but in this file I do not need the output of vg00. The problem is that I've other vg names than vg01, vg02... I don't know all the name of all the vg's that are configured on the machine.. How can I find them??

Thanks
11 REPLIES 11
G. Vrijhoeven
Honored Contributor
Solution

Re: vgdisplay

Hi,

ls /dev/*/group | awk -F/ '{ print $3}' | while read vgname
do
vgdisplay -v $vgname
done >>/tmp/vginfo.out

Gideon
Robert-Jan Goossens
Honored Contributor

Re: vgdisplay

Hi,

You can use the vgdisplay command ( no options)

# vgdisplay

or

# ll /dev/*/group

Regards,
Robert-Jan.
Pete Randall
Outstanding Contributor

Re: vgdisplay

Jonathan,

Perhaps something like this:

for i in `ll -d /dev/vg* |grep -v vg00`
do
vgdisplay -v $i
done



Pete

Pete
Steven E. Protter
Exalted Contributor

Re: vgdisplay

strings /etc/lvmtab

Will show all volume groups, followed by the disks in the volume groups.

If you followed the vg naming convention the query can be further refined.

strings /etc/lvmtab | grep vg

/dev/vg01
/dev/vg11

This output can then be used as the input to the vgdisplay -v command

strings /etc/lvmtab | grep vg > file

read -r aa
do
vgdisplay -v $aa
done < file

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
Jonathan Caplette_1
Super Advisor

Re: vgdisplay

Thanks you all...

All your answers are working find.. I'll use one of those in one script....

Thanks again!
Mark Grant
Honored Contributor

Re: vgdisplay

I might be being a bit pedantic here but it is possible that you have a volume group called vg00old or vg0000001 so to be absolutely sure, I think you are going to need a specific test such as

for i in `ls -d /dev/vg*`
do
[ $i = "/dev/vg00" ] || {
vgdisplay -v $i
}
done
Never preceed any demonstration with anything more predictive than "watch this"
Pete Randall
Outstanding Contributor

Re: vgdisplay

I think I need a little correction in my suggestion:

for i in `ll -d /dev/vg* |grep -v vg00 |sed s"/\/dev\///g"| sed s"/\///"`
do
vgdisplay -v $i
done



Pete

Pete
Thomas Schler_1
Trusted Contributor

Re: vgdisplay

Try this one line command:

strings lvmtab | grep -v dsk | grep -v vg00 | xargs vgdisplay -v {}
no users -- no problems
Thomas Schler_1
Trusted Contributor

Re: vgdisplay

According to Mark who is completely right, this one line command should work better:

strings lvmtab | grep -v dsk | grep -v '/dev/vg00$' | xargs vgdisplay -v
no users -- no problems
Pete Randall
Outstanding Contributor

Re: vgdisplay

Oops! One more time:

for i in `ls -d /dev/vg* |grep -v vg00 |sed s"/\/dev\///g"| sed s"/\///"`
do
vgdisplay -v $i
done



Pete

Pete
Mark Grant
Honored Contributor

Re: vgdisplay

Pete

Why are you trying so hard to get rid of that "/dev", vgdisplay doesn't mind if it's there or not!
Never preceed any demonstration with anything more predictive than "watch this"