No swap on Debain with cgroupv2

How to enable swap support in lxc? (actually, I see same issue in LXD)
I have this in lxc/config “lxc.cgroup2.memory.max = 2G”
and this in grub " cgroup_enable=memory swapaccount=1"
uname = Linux LXCHOST 5.10.0-8-amd64 #1 SMP Debian 5.10.46-1 (2021-06-24) x86_64 GNU/Linux

root@lxc:~# free
total used free shared buff/cache available
Mem: 2097152 127228 1652728 1584 317196 1969924
Swap: 0 0 0

Do you see memory.swap.max in /sys/fs/cgroup ?

root@dmz103:/sys/fs/cgroup/lxc.payload.vbox# cat memory.swap.max

root@dmz103:/sys/fs/cgroup# ls /sys/fs/cgroup/memory.*
/sys/fs/cgroup/memory.numa_stat /sys/fs/cgroup/memory.pressure /sys/fs/cgroup/memory.stat

Hmm, what LXCFS version is that?

@brauner any idea?

root@dmz103:/sys/fs/cgroup# lxcfs -v
root@dmz103:/sys/fs/cgroup# dpkg -l|grep lxcfs
ii lxcfs 4.0.7-1


Under cgroup1, this config would result in:

root@redoc:~# free
              total        used        free      shared  buff/cache   available
Mem:        2097152       36416     2039748           0       20988     2060736
Swap:       2097152           0     2097152

lxc config

lxc version


Yes, when I use cgroup v1, I can see swap in lxc.
Do you recommend use cgroup v1 (instead of v2) ?

Hi, would you like share, how to mount/use cgroup v1 for lxc on debian sid (/sys/fs/cgroup is v2)?
Is it possible, mount cgroup v1 some where (other than /sys/fs/cgroup) for lxc/lxd only?

No, it’s not. If your system is cgroup2, you only get cgroup2.
You can pass a boot time parameter to have systemd switch back to cgroup1 though which will then let you run containers which require cgroup1 but that will have your entire system switch back.