How can i remap volumegroup as storage pool in lxc

Hi All,

I am facing an issue where I cannot remap the volume groups previously mapped as storage pools in LXD after I uninstall the LXD without explicitly removing storage pools.

  • I have installed LXD using snap and mapped one of the volume groups named “l1_md1_lvm” as storage pool in lxd.
  • Now I have removed the lxd snap calling snap remove lxd without explicitly removing the storage pool.
  • Install back the LXD using snap and map the same volumegroup back to lxd as storage pool. It fails saying “Error: Volume group “op1_md1_lvm” is already used by LXD”

Any troubleshooting steps would be of great help

Try the force_reuse option:

https://documentation.ubuntu.com/lxd/en/latest/reference/storage_lvm/#storage-lvm-pool-conf:lvm.vg.force_reuse

1 Like

This sounds like something wasn’t cleaned up properly when uninstalling the snap. Did you encounter any errors during the removal of the LXD snap? Where there any left over volumes in the volume group which were not managed by LXD?
Would be interesting to know if you can reproduce this issue.

There error is happening if there is still the lxd_pool tag set on the volume group.

There is a specific config key you can set to force the reuse of a particular volume group.
Set lvm.vg.force_reuse=true when you create the storage pool. See https://documentation.ubuntu.com/lxd/en/latest/reference/storage_lvm/?&_ga=2.6559476.715357458.1714980284-1260639990.1714405379#storage-lvm-pool-conf:lvm.vg.force_reuse.

Well i dont remember seeing any errors when I triggered “snap remove lxd”.

I tried deleting the volumegroup and creating a new one then I am able to map it properly to lxd.

LXD will not destroy external storage pool devices during snap removal (only internal loop file based pools).

So the existing volume group will be left over, and can be re-used by doing:

lxc storage create foo lvm source=<existing vg> lvm.vg.force_reuse=true
2 Likes