[Plugin] Swapfile for 6.9.1


Recommended Posts

21 hours ago, primeval_god said:

I am glad it is working for you. I am however not the one to thank. I did not actually write this plugin, I just to over when it was abandoned.

Ture.  Well thanks for taking over the app and keeping it viable than 😊

Link to comment
  • 1 month later...

Has anyone had success with swap working in 6.12? I've got a docker container that I use it for and I get the following when updating the container:

WARNING: Your kernel does not support swap limit capabilities or the cgroup is not mounted. Memory limited without swap.
WARNING: Your kernel does not support memory swappiness capabilities or the cgroup is not mounted. Memory swappiness discarded.

 

Link to comment
35 minutes ago, TheEyeTGuy said:

Has anyone had success with swap working in 6.12? I've got a docker container that I use it for and I get the following when updating the container:

WARNING: Your kernel does not support swap limit capabilities or the cgroup is not mounted. Memory limited without swap.
WARNING: Your kernel does not support memory swappiness capabilities or the cgroup is not mounted. Memory swappiness discarded.

 

So far as i know swap works just fine on 6.12, the issue is whether or not docker supports limiting swap access to containers. See my answer here.

 

Link to comment
2 hours ago, TheEyeTGuy said:

If it does work.

I am almost certain that it does, in that the only thing this plugin does is allow the management of a swapfile and enable swap in unraid.

 

2 hours ago, TheEyeTGuy said:

its not working for my docker containers.

Correct, unRAID 6.12 moved to cgroupv2 and for some reason docker is unable to set swap limits using it. I dont know if it is a configuration issue with docker or cgroups, a limitation of the docker version used, or something else.

 

2 hours ago, TheEyeTGuy said:

Bug in 6.12.x?

So far as I can tell its not a bug in this plugin. Its also unlikely to be considered a bug in unRAID as support for swap has never been an official feature.

If someone knows or can figure out what needs to be changed to restore swap limit support for docker in unRAID 6.12 we can likely get limetech to make a fix. Cgroup stuff however is way above my head.

Link to comment
1 hour ago, primeval_god said:

I am almost certain that it does, in that the only thing this plugin does is allow the management of a swapfile and enable swap in unraid.

 

Correct, unRAID 6.12 moved to cgroupv2 and for some reason docker is unable to set swap limits using it. I dont know if it is a configuration issue with docker or cgroups, a limitation of the docker version used, or something else.

 

So far as I can tell its not a bug in this plugin. Its also unlikely to be considered a bug in unRAID as support for swap has never been an official feature.

If someone knows or can figure out what needs to be changed to restore swap limit support for docker in unRAID 6.12 we can likely get limetech to make a fix. Cgroup stuff however is way above my head.

Thanks for your response. Sorry if I offended you with some of my wording, did not mean any offense.

 

Docker can't control memory either now though, which regardless of swap, I think is something that could be considered a bug.

 

Cgroup stuff is also above my head. I appreciate your quick responses. On an unrelated note, is your source code published anywhere? I'd just like to poke around, for my own curiosity.

 

Thanks!

Edited by TheEyeTGuy
Link to comment
1 hour ago, TheEyeTGuy said:

Thanks for your response. Sorry if I offended you with some of my wording, did not mean any offense.

 

Docker can't control memory either now though, which regardless of swap, I think is something that could be considered a bug.

 

Cgroup stuff is also above my head. I appreciate your quick responses. On an unrelated note, is your source code published anywhere? I'd just like to poke around, for my own curiosity.

 

Thanks!

No problem I did not mean to imply offense in my response, just trying to be specific as to where the issue is. The source for this plugin is here https://github.com/dcflachs/swapfile_plugin

Link to comment
17 hours ago, TheEyeTGuy said:

I can also confirm the docker container is not respecting its memory limit configuration (limited to 8 gigs, but uses more than that).

How are you measuring how much memory it is using? Is the number you are seeing purely RAM or RAM+SWAP? Just as I am not clear on why swap limits dont work, I am also not clear on how docker containers interact with swap when limits are not settable. It is possible that even with a memory limit set a container has access to unlimited (except by the amount available on the system) swap space. Another possibility, based on how memory limits without swap limits work when swap limiting is available, is that the container has access to as much swap as its configured memory limit (meaning in your case the container would be able to use 8G RAM + 8G SWAP). 

Link to comment
  • 2 weeks later...

Hey Guys, 

 

I got a "Out of Memory" Problem with my Unraid.

image.thumb.png.d31e06330d3386d1ee2d805ab97f061b.png

 

Jorge told me that i can try a Swap File / Plugin.

But I dont have a clue what that Plugin exactly does and what Cons I might get when using it.

 

Would this Plugin help me get rid of that Error?

If yes, maybe someone here can tell me what I need to do without breaking my Config/Machine?

I'm really afraid of losing it :(

 

Thank you in advance

 

Link to comment
On 7/23/2023 at 4:02 AM, Zeench said:

But I dont have a clue what that Plugin exactly does and what Cons I might get when using it.

If you are not familiar with swap you should do some googling to better understand computer memory systems (linux specifically). The basic idea though is that the OS can take the least recently used memory pages and move them from RAM into a file on a disk (the swapfile) in order to free up RAM. When the pages stored in the file are needed they get moved back into RAM and something else gets swapped out to disk.

The downside of this is that swapping data out to disk has a significant performance penalty. That is typically not a big deal for normal swap usage where swap contains rarely used data and you are mainly protecting against an app occasional using a ton of memory for a short time. Swap is not a good substituted for additional RAM on a system that is consistently memory constrained however.

 

On 7/23/2023 at 4:02 AM, Zeench said:

Would this Plugin help me get rid of that Error?

Yes it would, how well it performs however depends on exactly why you are running out of memory. If Jorge thinks it could help though its definitely worth a try. There is not really any risk to using this plugin that i can think of. You will need an xfs or btrfs formatted cache drive (preferably sdd) in your system to host the swap file.

Edited by primeval_god
  • Like 1
Link to comment

Ty for the answer.

 

The Plugin wont work for me. It doesnt install the swapfile properly i guess.

image.thumb.png.b1a7a5411708f0f1d4de714c1c22c3e2.png

When i clock "Save below.... and install" it still shows the red X on the left side.

 

What did i do wrong?

I read in the help that it wont work on cachepools.

Im not running a pool, but i do run 2 seperate caches.

image.thumb.png.481a53b75c267e3c828edc01c3462772.png

 

What do i do wrong? Can u help me out here.

Thx again.

Link to comment
32 minutes ago, Zeench said:

What did i do wrong?

I read in the help that it wont work on cachepools.

Im not running a pool, but i do run 2 seperate caches.

What do i do wrong? Can u help me out here.

Thx again.

The swapfile cannot be placed in the root directory of a cache drive on BTRFS. It must be placed in a subvolume. Best to specify a directory that does not already exist and allow the plugin to create the subvolume itself. I would suggest something like '/mnt/cache/system/swap/' Click the little help icon next to the location for further information on swapfile placement.

I would also recommend setting swappiness to something lower than 10 (i use 1) and setting 'start swapfile during array mount' to true. Finally you will need to click the start button to start the swapfile for the first time.

Link to comment
On 7/26/2023 at 6:08 PM, primeval_god said:

The swapfile cannot be placed in the root directory of a cache drive on BTRFS. It must be placed in a subvolume. Best to specify a directory that does not already exist and allow the plugin to create the subvolume itself. I would suggest something like '/mnt/cache/system/swap/' Click the little help icon next to the location for further information on swapfile placement.

I would also recommend setting swappiness to something lower than 10 (i use 1) and setting 'start swapfile during array mount' to true. Finally you will need to click the start button to start the swapfile for the first time.

Thank you very much.

The File got created, but it cant be used for some reason.

When i click start, nothing happens, just a quick reload of the plugin site...

Edited by Zeench
Link to comment
46 minutes ago, DrSpaldo said:

Does the swap file size count as a total across the entire system or is the number inputted per docker? 

So far as the setting of this plugin are concerned the swap file size is the total amount of swap available to the system. 

48 minutes ago, DrSpaldo said:

What swap file size would you recommend if I had 48 gigs total ram?

I dont consider myself an expert on swap in linux. The amount of swap you need is less about your total amount of ram an more about your ram usage. In general you would want to keep your swap usage low. I wouldnt think you would need more than a few GB of swapspace. 2G-4G maybe?

Link to comment
17 hours ago, primeval_god said:

That would seem to indicate that the swapfile is active. On the command line you can run 'swapon -s' to confirm. Weird the that webpage does not update.

image.png.20c20915a518c83328c35f5752a31d79.png

 

Strange, it really seems to be in use.

But the Page still shows 

image.png.ffa2c7f9f46f1381925ec06d97cb29d4.png

 

While you guys were writing about the size.

I put mine  to 10GB, it doesnt have negative side effects to have it this big, right?

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.