Use swap memory of host on Ubuntu22.04

Hi, I found that my instance on Ubuntu22.04 can not use swap memory of host, when I set limits.memory config.
I found some reply on this topic (https://discuss.linuxcontainers.org/t/no-swap-in-containers-after-upgrading-to-jammy/15082), @Stephane said that

The likely difference between your systems is the use of cgroup2 on 22.04.
The swap is still present and will be used, but its reporting is the issue.

Downgrading to cgroup1 would definitely be interesting to try.

Today, should I Downgrading to cgroup1 if I want to use swap memory of host on Ubuntu22.04?

I upgrade my host system version because I want to use docker in unprivileged instance.(https://discuss.linuxcontainers.org/t/unprivileged-instance-can-not-use-docker-after-update-node-kernel-from-5-4-to-5-15/17150/18?u=libinkai)

I found some confusing phenomenon:
when I set instance limits.memory.swap=false, it can use swap
image

when limits.memory.swap=true, it can not use swap.
image

same as this topic: https://discuss.linuxcontainers.org/t/opposite-behavior-for-limits-memory-swap/16780/2

This is fixed in lxd 5.16 (currently in latest/candidate snap channel).

See https://github.com/canonical/lxd/pull/12044

Yes, lxd 5.16 fix this problem, thank you. :smile:

1 Like