LXD on LVM - thinpool setup
No matter what I tried I couldn't convince "lxd init" to create, or configure an existing, LVM thinpool for it's use!
So I ended up doing it rather more manually...
Basic requirements before getting started at all:
apt install lxd thin-provisioning-tools
Then create a thinpool, in this case using all of the remaining space on the "local" volume group:
lvcreate --type thin-pool --thinpool LXDPool -l 100%FREE local
Now we can do the lxd init bit, here's transcript of that process for me (the lines without a typed answer used the default):
# lxd init
Would you like to use LXD clustering? (yes/no) [default=no]:
Do you want to configure a new storage pool? (yes/no) [default=yes]: no
Would you like to connect to a MAAS server? (yes/no) [default=no]:
Would you like to create a new local network bridge? (yes/no) [default=yes]:
What should the new bridge be called? [default=lxdbr0]:
What IPv4 address should be used? (CIDR subnet notation, “auto” or “none”) [default=auto]:
What IPv6 address should be used? (CIDR subnet notation, “auto” or “none”) [default=auto]:
Would you like LXD to be available over the network? (yes/no) [default=no]:
Would you like stale cached images to be updated automatically? (yes/no) [default=yes]
Would you like a YAML "lxd init" preseed to be printed? (yes/no) [default=no]: yes
config: {}
cluster: null
networks:
- config:
ipv4.address: auto
ipv6.address: auto
description: ""
managed: false
name: lxdbr0
type: ""
storage_pools: []
profiles:
- config: {}
description: ""
devices:
eth0:
name: eth0
nictype: bridged
parent: lxdbr0
type: nic
name: default
During that process I chose not to create a storage pool. Instead that had to be done afterwards:
lxc storage create default lvm source=local lvm.thinpool_name=LXDPool
Not forgetting that the name "default" is actually just a name, so you also need to set it as the actual default:
lxc profile device add default root disk path=/ pool=default
After that new containers can be created as normal with lxc launch and they will be allocated space from the LVM thinpool.