• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • VCS
  • Interview Questions
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

CentOS / RHEL : How to add, delete and display LVM tags

by admin

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

Filed Under: CentOS/RHEL 6, CentOS/RHEL 7, Linux

Some more articles you might also be interested in …

  1. Linux OS Service ‘iptables’
  2. ping Command Examples in Linux
  3. Configure MySQL Router to Auto Restart of Failure using systemd
  4. How to Disable NetworkManager in CentOS/RHEL 8
  5. Hostname change not reflecting in sar report for CentOS/RHEL
  6. How to disable avahi-daemon service in CentOS/RHEL
  7. CentOS / RHEL : How to find the creation time of LVM volume
  8. “Warning: Missing charsets in String to FontSet conversion” – how to resolve the xclock warning message
  9. grub-mkconfig Command Options
  10. 5 Useful Examples of firewall-cmd command

You May Also Like

Primary Sidebar

Recent Posts

  • JavaFX ComboBox: Set a value to the combo box
  • Nginx load balancing
  • nginx 504 gateway time-out
  • Images preview with ngx_http_image_filter_module

© 2022 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright