1

I see from the LXD storage specs that LVM can be used as a backingstore. I've previously managed to get LVM working with LXC. This was very pleasing, since it allows quota-style control of disk consumption.

How do I achieve this with LXD?

From what I understand, storage.lvm_vg_name must point to my volume group. I've set this for a container by creating a profile, and applying that profile to the container. The entire profile config looks like this:

name: my-profile-name
config:
  raw.lxc: |
    storage.lvm_vg_name = lxc-volume-group
    lxc.start.auto = 1
    lxc.arch = amd64
    lxc.network.type = veth
    lxc.network.link = lxcbr0
    lxc.network.flags = up
    lxc.network.hwaddr = 00:16:3e:xx:xx:xx
    lxc.cgroup.cpu.shares = 1
    lxc.cgroup.memory.limit_in_bytes = 76895572
  security.privileged: "false"
devices: {}

The volume group should be available and working, according to pvdisplay on the host box:

  --- Physical volume ---
  PV Name               /dev/sdc5
  VG Name               lxc-volume-group
  PV Size               21.87 GiB / not usable 3.97 MiB
  Allocatable           yes
  PE Size               4.00 MiB
  Total PE              5599
  Free PE               901
  Allocated PE          4698
  PV UUID               what-ever

However after applying the profile and starting the container, it appears to be using file backing store:

me@my-box:~# ls /var/lib/lxd/containers/container-name/rootfs/
bin  boot  dev  etc  home  lib  lib64  lost+found  media  mnt  opt
proc  root  run  sbin  srv  sys  tmp  usr  var

What am I doing wrong?

ukosteopath
  • 443
  • 7
  • 14

2 Answers2

1

Note that we also ship a python script with LXD to do the initial VG configuration for you.

As for disk quotas, we have a new specification for it which we'll be implementing shortly and that will let you set disk quotas for any storage attached to a container which supports it.

While we still support LVM, our main focus and preference as far as storage backend go is ZFS nowadays as it allows such changes to happen live and also works better when moving containers and snapshots across the network.

The new storage quota feature will be supported on zfs, LVM and btrfs but will only be applied live for zfs and btrfs, LVM will require a container restart.

stgraber
  • 256
  • 1
  • 5
0

I'll answer my own question, in case it's of use to others.

According to an authoritative answer on the lxc-users mailing, list:

"The storage.lvm_vg_name is not a per-container config setting, it's for the whole daemon.

You set it using 'lxc config set storage.lvm_vg_name myvolgroup', and then lxd will use the volume group as storage for every new image and container that you create afterwards."

As a very rough summary, I used vgcreate to create a volume group, then lvcreate to create a volume within that group. This was followed by lxc config set storage.lvm_vg_name and lxc config set storage.lvm_thinpool_name appropriately.

It appears to work. However LXD feels a little too immature for my tastes at the moment, and I'm going to use plain LXC for now. I look forward to trying LXD again in a few months.

ukosteopath
  • 443
  • 7
  • 14