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

The Geek Diary

CONCEPTS | BASICS | HOWTO

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • Linux Services
    • VCS
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
    • Data Guard
  • DevOps
    • Docker
    • Shell Scripting
  • Interview Questions
  • 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. CentOS / RHEL : How to backup/restore configuration using authconfig
  2. Creating and Removing Files and Directories Under Linux
  3. How to configure iSCSI target using targetcli in CentOS / RHEL 7
  4. Understanding The /etc/sysconfig Directory
  5. How to configure the logging of failed login attempts for vsftpd
  6. Downloading a Specific Version of Package and Its Dependencies from Repository for Offline Installation Using YUM
  7. How to Set Environment Variables for a systemd Service in CentOS/RHEL 7
  8. CentOS / RHEL : Converting an Existing Root Filesystem to LVM Partition
  9. CentOS / RHEL 7 : How to setup yum repository using locally mounted DVD
  10. Linux OS Service ‘network’

You May Also Like

Primary Sidebar

Recent Posts

  • Oracle Database – Configuring Secure Application Roles
  • Extend rule sets by using factors in Oracle Database Vault
  • What are Command Rules in oracle Database
  • Using Rule Sets in Oracle Database Vault
  • Archives
  • Contact Us
  • Copyright

© 2021 · The Geek Diary