Installation guide

Chapter 4. LVM Administration with CLI Commands
46
For example, if you have logical volumes that are mirrored between two sites within a single volume
group, you can tag the physical volumes according to where they are situated by tagging the physical
volumes with @site1 and @site2 tags and specify the following line in the lvm.conf file:
cling_tag_list = [ "@site1", "@site2" ]
For information on tagging physical volumes, see Appendix C, LVM Object Tags.
In the following example, the lvm.conf file has been modified to contain the following line:
cling_tag_list = [ "@A", "@B" ]
Also in this example, a volume group taft has been created that consists of the physical volumes
/dev/sdb1, /dev/sdc1, /dev/sdd1, /dev/sde1, /dev/sdf1, /dev/sdg1, and /dev/sdh1.
These physical volumes have been tagged with tags A, B, and C. The example does not use the C tag,
but this will show that LVM uses the tags to select which physical volumes to use for the mirror legs.
[root@taft-03 ~]# pvs -a -o +pv_tags /dev/sd[bcdefgh]1
PV VG Fmt Attr PSize PFree PV Tags
/dev/sdb1 taft lvm2 a- 135.66g 135.66g A
/dev/sdc1 taft lvm2 a- 135.66g 135.66g B
/dev/sdd1 taft lvm2 a- 135.66g 135.66g B
/dev/sde1 taft lvm2 a- 135.66g 135.66g C
/dev/sdf1 taft lvm2 a- 135.66g 135.66g C
/dev/sdg1 taft lvm2 a- 135.66g 135.66g A
/dev/sdh1 taft lvm2 a- 135.66g 135.66g A
The following command creates a 100GB mirrored volume from the volume group taft.
[root@taft-03 ~]# lvcreate -m 1 -n mirror --nosync -L 100G taft
The following command shows which devices are used for the mirror legs and mirror log.
[root@taft-03 ~]# lvs -a -o +devices
LV VG Attr LSize Log Copy% Devices
mirror taft Mwi-a- 100.00g mirror_mlog 100.00
mirror_mimage_0(0),mirror_mimage_1(0)
[mirror_mimage_0] taft iwi-ao 100.00g /dev/sdb1(0)
[mirror_mimage_1] taft iwi-ao 100.00g /dev/sdc1(0)
[mirror_mlog] taft lwi-ao 4.00m /dev/sdh1(0)
The following command extends the size of the mirrored volume, using the cling allocation policy to
indicate that the mirror legs should be extended using physical volumes with the same tag.
[root@taft-03 ~]# lvextend --alloc cling -L +100G taft/mirror
Extending 2 mirror images.
Extending logical volume mirror to 200.00 GiB
Logical volume mirror successfully resized
The following display command shows that the mirror legs have been extended using physical
volumes with the same tag as the leg. Note that the physical volumes with a tag of C were ignored.