Discussion:
[linux-lvm] logical "and" connection of lvm-tags?
Oliver Rath
2017-08-13 07:44:28 UTC
Permalink
Hi list,

Im playing around with lvm-Tags and would find it quite useful for
sorting lvms.

Now I tried the following

***@w541:~# lvchange --addtag @foo levg/t1
Logical volume levg/t1 changed.
***@w541:~# lvchange --addtag @foo levg/t3
Logical volume levg/t3 changed.
***@w541:~# lvchange --addtag @bar levg/t2
Logical volume levg/t2 changed.
***@w541:~# lvchange --addtag @bar levg/t3
Logical volume levg/t3 changed.
***@w541:~# lvs -o lv_name @foo
LV
t1
t3
***@w541:~# lvs -o lv_name @bar
LV
t2
t3
***@w541:~# lvs -o lv_name @foo @bar
LV
t1
t2
t3
***@w541:~# lvs -o lv_name @foo \& @bar
LV
t1
t2
t3
***@w541:~# lvs -o lv_name @foo and @bar
LV
t1
t2
t3

You see, i want to list all lvms which have @foo *and* @bar tags
included. Is this possible? I didnt found anything about combining in
the man pages.

Tfh!

Oliver
Peter Rajnoha
2017-08-14 06:59:22 UTC
Permalink
Post by Oliver Rath
Hi list,
Im playing around with lvm-Tags and would find it quite useful for
sorting lvms.
Now I tried the following
Logical volume levg/t1 changed.
Logical volume levg/t3 changed.
Logical volume levg/t2 changed.
Logical volume levg/t3 changed.
LV
t1
t3
LV
t2
t3
LV
t1
t2
t3
LV
t1
t2
t3
LV
t1
t2
t3
included. Is this possible? I didnt found anything about combining in
the man pages.
Hi,

you can use -S|--select option:

lvs -o lv_name -S 'tags=[foo,bar]'

See also "man 7 lvmreport" and the "Selection" section there for more
info, there also a help on how to use selection with string lists.
--
Peter
Oliver Rath
2017-08-14 14:08:06 UTC
Permalink
Hi Peter,

thank you very much! This solves completely my issue!

Regards,

Oliver
Post by Peter Rajnoha
Post by Oliver Rath
Hi list,
Im playing around with lvm-Tags and would find it quite useful for
sorting lvms.
Now I tried the following
Logical volume levg/t1 changed.
Logical volume levg/t3 changed.
Logical volume levg/t2 changed.
Logical volume levg/t3 changed.
LV
t1
t3
LV
t2
t3
LV
t1
t2
t3
LV
t1
t2
t3
LV
t1
t2
t3
included. Is this possible? I didnt found anything about combining in
the man pages.
Hi,
lvs -o lv_name -S 'tags=[foo,bar]'
See also "man 7 lvmreport" and the "Selection" section there for more
info, there also a help on how to use selection with string lists.
Loading...