Setup lxd with LVM thin provision


Can somebody show full step by step manual to setup lxd with lvm thin provision storage pool please?:frowning:

I show my setup
/dev/sda - my root partition on which I install some soft (nginx, lxd and other soft)
/dev/sdb - clean disk which I want to use for lxc containers, not mounted (I create PV and VG group on this disk), that all

What should I do next?

Can I setup my thin provision in “lxd init”
Or I must create storage pool after “lxd init”

Please show me full path from begin and end please

Earlier I do LV (end block device), and give it to lvm storage pool, but I think i doing this not right

LXD defaults to thin provisioning on LVM.
lxd init allows you to either pass a block device which will be turned into a PV, then VG created on top of it, then thin pool. Or you can feed LXD an existing empty VG for it to consume.

LXD does not support sharing a VG with something else due to the risk of name collisions.

I should in section “existing block device” say “use /dev/sdb”?

Assuming /dev/sdb is an unused block device that you want LXD to format as a PV and use to setup a LVM pool, yes.

Okay, thank you

Where i may setup default size of containers, if I use thin pool? Default it’s 10gb for each container

lxc storage set default volume.size 20GiB assuming the pool is called default (per lxc storage pool list).


1 Like

If I feed existing empty VG and then I want to extend this vg (add in this VG some PV) is this ok?

Yep, that’s fine, LXD doesn’t look at the PVs once things are first created.

Can you explain please about LVM metadata?

Sometime ago my metadata has 99.9% and all my containers has broken. I can’t do something with this problem

Why metadata is growing? How to control metadata?

@stgraber can you explain what relationship have lxc containers on lvm storage and Lon metadata? In which cases metadata grow?


Please can you clarify your question, are you referring to LVM meta data, if so then this is an internal mechanism LVM uses to keep track of extents in the logical volumes and is not directly controlled by LXD.

I think create every day snapshots of all containers (about 20 containers) and do not deleting this about a 15-20 days may be ending oversize of LVM metadata
In this containers we have postgres or something (many changed files\transactions)

What do you think about this?

If you need a customised LVM setup different from LVM’s defaults, you can create a volume group manually and then instruct LXD to use it by specifying when creating the storage pool with a source=<vg name> flag.