1. 什么是LVM标签?
在你想开机启动时让逻辑卷被激活可用时,添加lvm标签是一个不错的选择。lvm标签允许那些被预先标记的实现这样的效果。
2. 配置文件
配置文件/etc/lvm/lvm.conf中有这样一段话:
# vim /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", "@*" ]
3. 添加LVM标签
1. vgchange 这个命令是用于添加或删除一个标签,请看下面的语法。在下面的例子中,标签“lvm_test_tag”被添加到"vg_test"逻辑组里。
# vgchange --addtag lvm_test_tag /dev/vg_test
Volume group "vg_test" successfully changed
2. 你可以确认上述操作是否正确
# vgs -o vg_tags /dev/vg_test
VG Tags
lvm_test_tag
3. 修改配置文件/etc/lvm/lvm.conf:在上面的配置文件的相关部分下面添加一个与例子相同的volume_list:
# vim /etc/lvm/lvm.conf
...
volume_list = ["vg_test","@lvm_test_tag"]
...
这样,带有“lvm_test_tag”标签的VGs就只会在开机启动时被激活
4. 删除LVM标签
1. 想要删除一个标签的话,用 -deltag标志,如下所示:
# vgchange --deltag lvm_test_tag /dev/vg_test
Volume group "vg_test" successfully changed
2. 确认一下是否删除了标签
# vgs -o vgtags /dev/vg_test
VG Tags
如果你仅仅是想为一个单一lv而不是整个逻辑组修改标签的话,请用lvchange代替vgchange
5. 为逻辑卷添加、删除LVM标签
如果遇到给个别逻辑卷而不是整个逻辑组添加标签的情况时,借鉴上面的命令,只要把vgchange改为lvchange就可以,只是用于显示LVM标签的命令不一样,如下所示:
# lvs -o lv_tags
LV Tags