What is LVM tag
In a case where you want that only a particular set of logical volumes to be activated and available during boot, lvm tags can come in handy. Lvm tags can allow these tags to be marked beforehand and the effect achieved.
Configuration file
Navigate to the section show below in the configuration file /etc/lvm/lvm.comf :
# vi /etc/lvm/lvm.conf # If volume_list is defined, each LV is only activated if there is a # match against the list. # # "vgname" and "vgname/lvname" are matched exactly. # "@tag" matches any tag set in the LV or VG. # "@*" matches if any tag defined on the host is also set in the LV or VG # # If any host tags exist but volume_list is not defined, a default # single-entry list containing "@*" is assumed. # # volume_list = [ "vg1", "vg2/lvol1", "@tag1", "@*" ]
Add LVM tag
1. vgchange is used to add or delete a tag via the following syntax. In the example below, the tag “lvm_test_tag” is being added to the “data_vg” volume group:
# vgchange --addtag lvm_test_tag /dev/data_vg Volume group "data_vg" successfully changed
2. You can verify the above operation using the command vgs :
# vgs -o vg_tags /dev/vg00 VG Tags lvm_test_tag
3. Modify the configuration file /etc/lvm/lvm.conf and go to the section as shown above in the post and add a volume_list line similar to the example below:
# vi /etc/lvm/lvm.conf ... volume_list = ["@lvm_test_tag"] ...
This implies that the VGs with tag “lvm_test_tag” will only be activate on reboot.
Delete LVM tag
1. To delete a tag, pass the –deltag flag to the vgchange command as show below :
# vgchange --deltag lvm_test_tag /dev/data_vg Volume group "vg00" successfully changed
2. Verify the deletion of the tag :
# vgs -o vg_tags /dev/data_vg VG Tags
If you want to change tags for only a single lv and not the entire volume group, please use lvchange instead of vgchange.
Add, delete LVM tags for logical volumes
There may be a case, where you want to tag a particular logical volume instead of an entire volume group. This can be done using the same commands. Only use lvchange instead of lvchange and use below command to display LVM tags on logical volumes :
# lvs -o lv_tags LV Tags