什么是 LVM 标签

如果我们希望在引导期间只激活一组特定的逻辑卷并可用,lvm 标签可以派上用场。
lvm标签可以让这些标签预先标记,达到效果。

删除 LVM 标签

  1. 要删除标签,将 -deltag 标志传递给 vgchange 命令,如下所示:
# vgchange --deltag lvm_test_tag /dev/data_vg
  Volume group "vg00" successfully changed
  1. 验证标签的删除:
# vgs -o vg_tags /dev/data_vg
    VG Tags

如果我们只想更改单个 lv 而不是整个卷组的标签,请使用 lvchange 而不是 vgchange。

CentOS/RHEL:如何添加、删除和显示 LVM 标签
之路 on it Road.com

添加 LVM 标签

  1. vgchange 用于通过以下语法添加或者删除标签。
    在下面的示例中,标签“lvm_test_tag”被添加到“data_vg”卷组:
# vgchange --addtag lvm_test_tag /dev/data_vg 
     Volume group "data_vg" successfully changed
  1. 我们可以使用命令 vgs 验证上述操作:
# vgs -o vg_tags /dev/vg00 
  VG Tags
  lvm_test_tag

3.修改配置文件/etc/lvm/lvm.conf,进入帖子中如上所示部分,添加类似于下例的volume_list行:

# vi /etc/lvm/lvm.conf
...
volume_list = ["@lvm_test_tag"]
...

这意味着带有标签“lvm_test_tag”的 VG 只会在重新启动时激活。

配置文件

导航到配置文件 /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", "@*" ]

添加、删除逻辑卷的 LVM 标签

在某些情况下,我们可能希望标记特定的逻辑卷而不是整个卷组。
这可以使用相同的命令来完成。
仅使用 lvchange 而不是 lvchange 并使用以下命令在逻辑卷上显示 LVM 标记:

# lvs -o lv_tags
  LV Tags
日期:2020-09-17 00:12:09 来源:oir作者:oir