linux-lvm.redhat.com archive mirror
 help / color / mirror / Atom feed
* [linux-lvm] Listing physical volumes in a volume group
@ 2007-08-03 14:19 Steeve McCauley
  2007-08-03 15:46 ` Milan Broz
  0 siblings, 1 reply; 4+ messages in thread
From: Steeve McCauley @ 2007-08-03 14:19 UTC (permalink / raw)
  To: linux-lvm


I would like to know if there is a canonical way to list the
physical volumes in a volume group, specifically to extract
the uuid for those PVs in a bash script.  I am able to do
something along the lines of,

PVS=$(vgdisplay -vv 2>&1 | grep "PV UUID" | awk '{print $3}')
PVUUID=$(pvs -o pv_uuid --noheadings /dev/sdx | awk '{print $1}')

and then look for PVUUID in the list of PVS.

for uuid in $PVS; do
   [ "$uuid" != "$PVUUID" ] && continue
   ...
done

but this relies on the output format of 'vgdisplay -vv' and
I want to be sure that I will always get the expected result.

Thanks,

steeve

-- 
Steeve McCauley
:wq

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [linux-lvm] Listing physical volumes in a volume group
  2007-08-03 14:19 [linux-lvm] Listing physical volumes in a volume group Steeve McCauley
@ 2007-08-03 15:46 ` Milan Broz
  2007-08-03 16:01   ` Steeve McCauley
  0 siblings, 1 reply; 4+ messages in thread
From: Milan Broz @ 2007-08-03 15:46 UTC (permalink / raw)
  To: LVM general discussion and development

Hi,

this will not help for using in script ?
(comma separated list of PVS & PV UUID  in VG)

vgs --separator , --noheadings -o pv_name,pv_uuid <vgname>

Milan
--
mbroz@redhat.com

Steeve McCauley wrote:
> I would like to know if there is a canonical way to list the
> physical volumes in a volume group, specifically to extract
> the uuid for those PVs in a bash script.  I am able to do
> something along the lines of,
> 
> PVS=$(vgdisplay -vv 2>&1 | grep "PV UUID" | awk '{print $3}')
> PVUUID=$(pvs -o pv_uuid --noheadings /dev/sdx | awk '{print $1}')
> 
> and then look for PVUUID in the list of PVS.
> 
> for uuid in $PVS; do
>    [ "$uuid" != "$PVUUID" ] && continue
>    ...
> done
> 
> but this relies on the output format of 'vgdisplay -vv' and
> I want to be sure that I will always get the expected result.
> 
> Thanks,
> 
> steeve
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [linux-lvm] Listing physical volumes in a volume group
  2007-08-03 15:46 ` Milan Broz
@ 2007-08-03 16:01   ` Steeve McCauley
  2007-08-07 20:24     ` Alasdair G Kergon
  0 siblings, 1 reply; 4+ messages in thread
From: Steeve McCauley @ 2007-08-03 16:01 UTC (permalink / raw)
  To: LVM general discussion and development


Milan,

Ah, I didn't realise one could use the pv_ column names
with the vgs utility.

That's much better.

Thanks,

steeve

Milan Broz wrote:
> Hi,
> 
> this will not help for using in script ?
> (comma separated list of PVS & PV UUID  in VG)
> 
> vgs --separator , --noheadings -o pv_name,pv_uuid <vgname>
> 
> Milan
> --
> mbroz@redhat.com
> 
> Steeve McCauley wrote:
>> I would like to know if there is a canonical way to list the
>> physical volumes in a volume group, specifically to extract
>> the uuid for those PVs in a bash script.  I am able to do
>> something along the lines of,
>>
>> PVS=$(vgdisplay -vv 2>&1 | grep "PV UUID" | awk '{print $3}')
>> PVUUID=$(pvs -o pv_uuid --noheadings /dev/sdx | awk '{print $1}')
>>
>> and then look for PVUUID in the list of PVS.
>>
>> for uuid in $PVS; do
>>    [ "$uuid" != "$PVUUID" ] && continue
>>    ...
>> done
>>
>> but this relies on the output format of 'vgdisplay -vv' and
>> I want to be sure that I will always get the expected result.
>>
>> Thanks,
>>
>> steeve
>>
> 
> _______________________________________________
> linux-lvm mailing list
> linux-lvm@redhat.com
> https://www.redhat.com/mailman/listinfo/linux-lvm
> read the LVM HOW-TO at http://tldp.org/HOWTO/LVM-HOWTO/
> 

-- 
Steeve McCauley
Director of Research and Development
Rackable Systems
407 McGill Street, Suite 1002
Montreal, Quebec, H2Y 2G3 (Canada)
Tel: 514-288-3343
http://www.rackable.com
:wq

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [linux-lvm] Listing physical volumes in a volume group
  2007-08-03 16:01   ` Steeve McCauley
@ 2007-08-07 20:24     ` Alasdair G Kergon
  0 siblings, 0 replies; 4+ messages in thread
From: Alasdair G Kergon @ 2007-08-07 20:24 UTC (permalink / raw)
  To: LVM general discussion and development

On Fri, Aug 03, 2007 at 12:01:13PM -0400, Steeve McCauley wrote:
> Ah, I didn't realise one could use the pv_ column names
> with the vgs utility.
 
pvs, vgs, and lvs simply set up different defaults before entering the
same reporting engine.  One such default is what prefix to add to column
names that are supplied without any prefix.  If you request -o name,
vgs would turn that into 'vg_name' whereas pvs would turn it into
'pv_name', for example.

Use '-o help' (in sufficiently recent versions) to see the list of
fields.

Alasdair
-- 
agk@redhat.com

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2007-08-07 20:24 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-08-03 14:19 [linux-lvm] Listing physical volumes in a volume group Steeve McCauley
2007-08-03 15:46 ` Milan Broz
2007-08-03 16:01   ` Steeve McCauley
2007-08-07 20:24     ` Alasdair G Kergon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).