-
Notifications
You must be signed in to change notification settings - Fork 930
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Clarification regarding swap: Possible to define swap volume? #6168
Comments
Ok as I've never had to fiddle with swap allocation before, I didn't know it was so easy to just create a volume on the zpool as a swap volume and then tell the host to use that instead of the disk. I basically just followed this guide: https://github.com/zfsonlinux/pkg-zfs/wiki/HOWTO-use-a-zvol-as-a-swap-device Problem solved I guess :) I'll leave this open for now in case the experts have any further relevant information to add here. |
OK maybe not solved after all. I found this issue: And after doing my own stress test I encountered the deadlock as described in this issue. I am now considering buying a dedicated (small) SSD drive to hold my swap. |
Swap devices are global so there is currently no way to use a separate swap file or device for specific containers and it's unclear that it's something which would ever be practical to implement due to how the kernel decides what to move to swap (and whether it can always track this down to a particular container). The main thing you can do through LXD is control the swapiness through Swap files/devices are pretty picky. They can't be stored on most copy on write filesystems (btrfs, zfs, ...) and as you've noticed, even when using a block device, they can be a bit picky as is the case on top of zvol. A dedicated partition tends to work best. Another option is using zram as swap, which effectively takes a bit of ram, compresses it and turns it into swap. That's sometimes a reasonable option for systems that aren't expected to hit the swap very often and yield reasonable performance so long as you don't completely run the system out of memory. |
Just to add some details I've found out over the last few days:
https://haydenjames.io/linux-performance-almost-always-add-swap-space/
|
LXD 3.16
Ubuntu Bionic
I've been reading up on swap limiting as I've encountered poor performance (unsurprisingly) in containers that need to swap to disk, as on my new systems the main OS is on spinning rust.
As the containers are zfs backed on an SSD, I've been looking around for information on whether it is possible to tell my containers/lxd to swap out to their zfs volume instead of the host OS disk?
I also tried for kicks and giggles to test out the limits.memory.swap = false option in my profile, but that seems to do nothing whatsoever. The container still swaps happily away to the host OS drive. Which I found interesting - possibly a kernel param I need to enable here?
lxc info shows no information regarding swap on my system - the container has 1GB of swap space available as seen in top/htop - where is this defined?
Thank you for your time as always :)
The text was updated successfully, but these errors were encountered: