1

is there any lvm.conf editor?

I'm trying to set global_filter, use_lvmtad and some other options, currently using sed:

sed -i /etc/lvm/lvm.conf \
      -e "s/use_lvmetad = 1/use_lvmetad = 0/" \
      -e "/^ *[^#] *global_filter/d" \
      -e "/^devices {/a\        global_filter = [ \"r|/dev/drbd.*|\", \"r|/dev/dm-.*|\", \"r|/dev/zd.*|\" ]"

but I don't like this too much, is there any better way?

I found only lvmconfig tool, but it can only display certain configuration sections, and can't edit them.

kvaps
  • 2,589
  • 1
  • 21
  • 20

2 Answers2

1

It seems that augtool is exactly what I was looking for.

These two packages should be enough to proper processing lvm.conf file:

apt install augeas-tools augeas-lenses

Example usage:

augtool print /files/etc/lvm/lvm.conf

And you should get the whole parse tree on stdout.

If the parser fails you won’t get any output, print the error message using:

augtool print /files/etc/lvm/lvm.conf/error

The augtool equivalent for the sed command from the original question:

augtool -s <<EOT
set /files/etc/lvm/lvm.conf/global/dict/use_lvmetad/int "0"
rm /files/etc/lvm/lvm.conf/devices/dict/global_filter
set /files/etc/lvm/lvm.conf/devices/dict/global_filter/list/0/str "r|^/dev/drbd.*|"
set /files/etc/lvm/lvm.conf/devices/dict/global_filter/list/1/str "r|/dev/dm-.*|"
set /files/etc/lvm/lvm.conf/devices/dict/global_filter/list/2/str "r|/dev/zd.*|"
EOT
kvaps
  • 2,589
  • 1
  • 21
  • 20
0

If you using Ubuntu variant then you can use the LVM GUI to configure and manage the LVM. Refer this link