Feature request: create LXD storage pool WITHOUT consuming the whole disk

Hi, I tried to setup a new LXD server and one of the first steps is to create a storage pool. I’m using LVM elsewhere on this server and I’m most familiar with it as a tool for portioning out disk space. So I tried to create a new LXD pool as follows:

lxc storage create vs_slow lvm source=vg_slow lvm.vg.force_reuse=true size=4TB

However, this appears not to respect the “size” flag and instead generates a new thinpool which takes over the whole volume group! Is this expected? (Other storage drivers appear to respect the size flag?)

It appears that you can work around this using something like the following procedure:

  • Figure out how much free space there is:
    vgdisplay vg_slow
  • Figure out how large you want the thinpool to be and subtract that from the free space
  • Allocate a temporary lv which fills up the the remaining space computed as above
  • Create the new thinpool, which will fill up the whole vg
  • Erase the temporary lv, this leaves the thinpool at the desired size

This is obviously error prone and long winded, so it would be desirable to be able to specify the size of the thinvolume at creation and have that respected

Note that it’s simple to grow/extend the size of a thinpool to use MORE space and this can be done online. However, a current limitation of lvm thinpools is that they cannot be shrunk (at all), only grown. This obviously interacts badly with the current situation where lxd grabs all of the space, as it cannot be shrunk later.

Thanks for your consideration on this

1 Like


This sounds like a bug to me, please can you log an issue at https://github.com/lxc/lxd/issues please.

Normally size on the pool is only used when creating loop-backed pools, but in the scenario you describe it makes sense for the lvm driver to only create a logical volume of the specified size in the volume group for use as the thinpool.

Opened issue:

Is there any way to re-open this issue and connect with the bug github issue above?

On latest LXD (5.17) I can still reproduce this issue:

lxc storage create vs_fast lvm source=vg_fast lvm.vg.force_reuse=true size=1TB

Error: Cannot specify size when using an existing thin pool

LXD is no longer part of Linux Containers, so support for LXD is now on Canonical’s forum.

Yes please open a post over at Support - Ubuntu Community Hub and please include the output of sudo lvs before you run the lxc storage ... command.

I suspect the reason you are getting the error is because the thin pool logical volume exists already, as opposed to just the volume group existing.

The change in Creating an LVM thin storage pool on an existing volume group with a `size` setting should set the LV thin volume size · Issue #11672 · canonical/lxd · GitHub allow the size property to be specified if the volume group exists, but the thin pool logical volume doesn’t yet exist, in which case LXD will create it using the specified size. However in cases where the thin pool logical volume exists, size cannot be specified because LXD won’t resize the thin pool logical volume.