LXD 5.0: Create LXD Server on btrfs

Hello :wave:

I looking to install my own on-premise LXD server to store images on my ubuntu server. To make it ready for production, I choosen to use a dedicated disk with a single full btrfs partition on it (nvme M.2 ssd).

At this time I created the btrfs partition and adding this partition to my /etc/fstab using the options bellow:

/dev/disk/by-partlabel/LXD-STORAGE   brtfs   /data   defaults,nofail,discard,noatime,nodiratime,compress,autodefrag   0   0

The main use I want to achieve is to be able to have an LXD server that I can use as a repository. The development of container and their push will be done from another machine.

If I understood correctly, I have to create an LXD cluster in this case. So I’m about to follow this demo from @stgraber ber by adapting it to my use case. (probably RBAC + candid authentication on the server)

However, I did not find an example on how to configure the BTRFS storage. The documentation explains well the concepts and actions for storages and volumes. But I don’t know how to configure my disk (subvolumes and configuration with lxd)

If anyone has any explanation on this. Thanks in advance

lxc storage create <pool name> btrfs source=/data
lxc launch images:ubuntu/jammy -s <pool name>

should do it.

Ok. But for the moment I don’t have LXD initiated.

So, I founded the solution after a lot of try with lxd init. Sometime I have to use /dev/sdx when using an empty disk. In case I have already a disk using btrfs, I could use the mount point instead (here /data).

Thanks to your answer that is usefull to do this later.

I also understand that in my case (lower than 3 machines), a cluster wasn’t a good choice.

I’ve used btrfs for my LXD storage for quite some time but can recommend you switch to ZFS. It sounds like this is a dedicated disk and you have only just started so the switch should be easy.

The way btrfs handles quota is vastly different from ZFS and the way VMs work on LXD you’ll run into issues if you do not read the fine print on the docs and act on them.

The docs also recommend ZFS.

My NASes however runs great with btrfs and I am very happy with it :slight_smile:

1 Like

The docs actually recommend avoiding btrfs when using vms:

See 4th bullet down in btrfs section Storage configuration - LXD documentation

1 Like