LXD 3.0 + cgroup v2 + debian 9

Hi!

I did not find any information on how to do this. LXD builded from source, no snap.

How to switch LXD to cgroup v2 on debian 9? I try this:
/etc/default/grub:
GRUB_CMDLINE_LINUX="cgroup_no_v1=io,memory systemd.legacy_systemd_cgroup_controller=0"

After that there was a catalog:
cgroup on /sys/fs/cgroup/systemd type cgroup2 (rw,nosuid,nodev,noexec,relatime)
and /sys/fs/cgroup/systemd/lxc (magically created somehow)

I manually add IO and memory controllers into it:
echo '+io +memory' > /sys/fs/cgroup/systemd/cgroup.subtree_control

Then when I try to run the container the following happens:

lxc init ... c1
lxc config edit c1
devices:
  root:
    limits.read: 1MB
    limits.write: 1MB
    path: /
    pool: default
    type: disk
lxc start c1
lxc info --show-log c1
lxc c1 20190926152501.663 WARN     cgfsng - cgroups/cgfsng.c:get_hierarchy:204 - There is no useable blkio controller
lxc c1 20190926152501.663 ERROR    cgfsng - cgroups/cgfsng.c:cg_legacy_set_data:2191 - Failed to setup limits for the "blkio" controller. The controller seems to be unused by "cgfsng" cgroup driver or not enabled on the cgroup hierarchy
lxc c1 20190926152501.663 WARN     cgfsng - cgroups/cgfsng.c:__cg_legacy_setup_limits:2228 - Failed to set "blkio.throttle.read_bps_device" to "253:7 1000000"
lxc c1 20190926152501.663 ERROR    start - start.c:lxc_spawn:1723 - Failed to setup cgroup limits for container "c1"

What I must do for correct using cgroup v2 with LXD 3.0?

I was also wondering if cgroup v2 are supported or not, I found some PR to suggest it should at least not break but that support was not ready yet. Any official statement about this?

That’s about it, LXD will not fail on a cgroupv2-only system, but you also won’t be able to actually use any of the limits at this time.

1 Like

Good to know, thanks for the update.

Has the situation changed since? I’ve just installed LXD 4.2 from snap on Debian 10 and I’d like to use cgroup v2 only with it.

Yeah, LXD has full support for cgroup2 now.

And does it provide any specific configuration file/command for cgroup2? Such as lxc config set cgroup2.whatever or something? Or am I supposed to script the required bash commands to find lxc processes IDs and add them to a custom hierarchy?

Just use the same limits.* config options as you normally would.