[Plugin] Swapfile for 6.9.1


Recommended Posts

Swapfile (Unraid 6.9.0 and up)

This plugin adds swapfile creation and management to unRAID. This is a fork of the original "Swap File Plugin for unRAID" by @theone. The goal of this fork is to revamp the plugin for unRAID 6.9.0 and add support for swapfile creation on BTRFS drives.

 

Notes:

  • You must remove the original Swap File Plugin before installing this plugin.
  • This plugin no longer contains the feature to auto-update on startup.
  • Dont forget to check the help text.

 

Limitations:

  • When using BTRFS swapfiles should only be placed on single disk BTRFS drives. BTRFS drive pools with RAID will not work correctly.
  • When using a BTRFS disk the swapfile must be in a subvolume. The plugin will automatically create a subvolume if it is allowed to create the folder in which the swapfile will be placed. Better handling of this requirement will be added soon.
Edited by primeval_god
Link to comment
18 hours ago, tk40 said:

This is interesting. . .Under what situations is this useful? How does Unraid manage swap files by default?

 

I'd foresee this being useful for memory constrained environments, especially when there's *fast* storage available.

 

Say you have a system that's limited to 16GB of ram, whether that's because you're limited to dual channel memory on your platform, or because finding memory for your system just isn't cheap/easy (unbuffered ECC DIMMs can be difficult sometimes). You still want to use RAM transcoding, prefer to keep larger chunks in RAM with your preferred downloader to save writes to your NVME device, etc, but if you find that you're doing a couple transcodes at the same time you have a large-ish download coming through, you're bound to run out of RAM.

 

Having a swap saves you from those situations - these days, and especially with PCIe gen 4, storage is approaching (far closer than ever before at least) RAM-like speeds. If you run a system that would only ever need 8-16GB of RAM like 90-95% of the time, it doesn't make much sense to double your memory when you can simply utilize NVMe storage you've already got to cover the gap. 

 

Link to comment
19 hours ago, tk40 said:

This is interesting. . .Under what situations is this useful? How does Unraid manage swap files by default?

The default for UnRaid is to run without a swap file as it is not needed for built-in functionality.    It only becomes potentially necessary when adding new application functionality to the basic built-in capabilities that can demand more RAM in aggregate than is physically present.

  • Thanks 1
Link to comment
11 hours ago, itimpi said:
11 hours ago, EricD said:

Could this be used to allow usenet to download directly to ram, and when the ram is full to continue via the swapfile?

Probably not as the swap file is only used to swap out applications

Actually I believe that when ram space is low any pages in ram (except maybe for some kernel stuff) are eligible to be written to swap. Theoretically if you have a swapfile active and are writing data to tmpfs those pages could make there way into the swapfile. That said i dont imagine performance would be that great, my experience with very large swapfiles (as big or bigger than system ram) hasnt been great. Might be worth trying though.

Link to comment
3 minutes ago, Adriano Frare said:

I forget that  remove the original Swap File Plugin before installing this plugin. And now, I the new app dont create swapfile and not save configuration. How I solve ?

 

Thanks

I suggest uninstalling both the new and old swap plugins, rebooting, and then installing the new plugin. That should clear things out.

Link to comment
14 hours ago, primeval_god said:

I suggest uninstalling both the new and old swap plugins, rebooting, and then installing the new plugin. That should clear things out.

 

Dear friend,

 

image.thumb.png.b31a6cf1236b3122d8a0a9cacae77279.png

 

I put information but not save and this software information that file swap exist. Is there access log of plugin and verify problem ?

 

Thanks for all.

Link to comment
13 hours ago, Adriano Frare said:

 

Dear friend,

 

image.thumb.png.b31a6cf1236b3122d8a0a9cacae77279.png

 

I put information but not save and this software information that file swap exist. Is there access log of plugin and verify problem ?

 

Thanks for all.

I have the same problem. Don't see anything useful in the logs, as far as I can tell. Clicking save just resets everything. Swap file is never marked in use, no matter what I do. Unraid 6.9.2.

 

All I get in logs is:

Jun 8 21:04:30 Tower emhttpd: cmd: /usr/local/emhttp/plugins/swapfile/scripts/rc.swapfile start
Jun 8 21:04:30 Tower rc.swapfile[48338]: Creating swap file / please wait ...
Jun 8 21:04:30 Tower rc.swapfile[48344]: Swap file / created and started

Edited by JibbsIsMe
Link to comment

Saving works now, but now I get the error: swapfile must not be copy-on-write

I am trying to put it on a "Pool Device" named "working" by using /mnt/working. It is a single disk. I am thinking that this might break one of the limitations mentioned in the first post, but I'm not sure.

Link to comment
1 hour ago, JibbsIsMe said:

Saving works now, but now I get the error: swapfile must not be copy-on-write

I am trying to put it on a "Pool Device" named "working" by using /mnt/working. It is a single disk. I am thinking that this might break one of the limitations mentioned in the first post, but I'm not sure.

No i think you have it correct, if using a BTRFS file system it MUST be a single device (rather than a BTRFS RAID pool). In this case you are hitting one of the limitations of the UI/Help that i havent figured out how to address (mostly inform the user of) yet. For swapfile to be used on BTRFS they must be placed in a non-COW subvolume of a BTRFS file system. I assume you are trying to do something like this 

/mnt/working/swapfile

where swapfile is in the file name field and /mnt/working is in the path field. Instead you should have something like this

/mnt/working/swapfile_dir/swapfile

where swapfile_dir is a BTRFS subvolume (swapfile_dir can be whatever folder name you want). To achieve this put /mnt/working/swapfile_dir  (note no trailing /) in the path field and the plugin will create the subvolume for you if no swapfile_dir folder exists. I am still trying to figure out the best way to guide the user through these steps in the plugin interface but i havent had much time to look at it.

Link to comment
7 hours ago, JibbsIsMe said:

You were exactly right! Subvolume is not a familiar term for me, if it said subfolder I might have understood better.

Yeah thats part of what i need to figure out how to express in the plugin interface. It looks like a simple subfolder, but when we are talking about BTRFS it has to be a subvolume which is created differently than a normal subfolder. That is why it is important to let the plugin create the subfolder when the underlying filesystem is BTRFS. That said creating the subvolume manually is possible just a pain. 

Link to comment
  • 2 weeks later...

Thank you for this. A couple of questions.

 

What happens if I set "Delete Swap file upon Stop" to No? Is there any undesirable effect from this? I'm thinking from the perspective of avoiding unnecessary writes to an SSD.

 

After setup, my status says swap file exists but not in use. I hope this means that the swap is ready to be used when needed and I don't have to do anything else?

Link to comment
On 6/20/2021 at 1:13 PM, Debarka Banik said:

What happens if I set "Delete Swap file upon Stop" to No? Is there any undesirable effect from this?

That is how I use it. I am honestly not certain of the advantages of deleting it every on stop. This plugin is a fork of an existing swapfile plugin and that setting was carried over.

 

On 6/20/2021 at 1:13 PM, Debarka Banik said:

After setup, my status says swap file exists but not in use. I hope this means that the swap is ready to be used when needed and I don't have to do anything else?

Unfortunately that likely means that something went wrong in attempting to start swap, check your logs for messages logged by the swapfile plugin.

  • Thanks 1
Link to comment
  • 1 month later...
  • 2 months later...

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.