Hey everyone! I need some help configuring SWAP for LXD Containers on Ubuntu 22.04.2 with Linux 5.19 and LXD 5.14. Is this related to cgroupv2 only now with the latest Ubuntu/Linux versions? If it is, could someone guide me on the proper and easy way to get this done nowadays?
I’m curious about the current state of SWAP accounting in LXD/LXC with Ubuntu 22.04.2 and CGroupV2. I’ve come across various methods, but unfortunately, I haven’t been able to make it work on a fresh installation.
To give you an idea, here’s an example of my LXD containers configuration:
The issue is that when I check the container, there doesn’t seem to be any swap space available. It shows a size of zero.
I’ve tried using the swapaccount Linux option and experimenting with different values for the other options, but so far, no luck in getting the swap working in the LXD containers.
I’m curious why it’s not as straightforward as something like this (for example):
Any insights or suggestions would be greatly appreciated!
But generally speaking one should increase the limits.memory to the amount of overall memory required and then let the OS manage swapping centrally. However you can use the other settings you mentioned to indicate to the OS the propensity to swapping it should have.
We are also hitting this swap issue and it is very much a blocking issue for us. I will layout the scenario as much as possible.
Ubuntu 22.04 LXD host and containers
Using ubuntu 6.1.x mainline kernel
Hardware: Intel 13900k with 128G ram
Swap is enabled on host and set to 128G on fast nvme.
We have a container for remote ide (Jetbrain gateway) per developer
Each container has access to a gpu which can also do training/inference.
Container cannot see any swap regardless of toggle mentioned here or in other lxd posts/docs. Host is also showing zero swap usage from containers.
As such, we are getting linux process.fork() faults due to memory on the containers where there are some physical ram left and full 128g of swap available.
Whatever the developers are running, ide, python scripts, etc are using lots of ram and/or also allocating lots of virtual memory.
Without proper swap, a fully functional host with 100% swap available is brought to a halt unless we kill some processes to relief memory pressure. There are only 4 memory slots on this machine so we can’t expand further.