Categories
SysOps

How do display physical volumes associated with the volume group

Display physical volumes associated with the volume group.

Display physical volumes.

$ pvdisplay --columns --noheadings --options pv_name | tr -d ' '
/dev/sdb
/dev/sdc
/dev/sdd
/dev/sde
/dev/sdf

Display volume groups.

$ sudo vgdisplay --columns --noheadings --options vg_name | tr -d ' '
vg_backup
vg_data

Display physical volumes associated with the volume group.

$ sudo pvdisplay --columns --noheadings --options pv_name --select vg_name=vg_backup | tr -d ' '
/dev/sdd
/dev/sde
/dev/sdf
$ sudo pvdisplay --columns --noheadings --options pv_name --select vg_name=vg_data | tr -d ' '
/dev/sdb
/dev/sdc

This method comes in handy when using ansible or other automation tools.