Jump to content
theone

Swap File Plugin for unRAID v5 and v6

90 posts in this topic Last Reply

Recommended Posts

i felt adventurous today so i uninstalled this plug... upgraded to 6.1.2.. checked everything was fine

and then installed the plugin again

everything installed fine

 

Sep 17 18:12:18 P8H67 emhttp: cmd: /usr/local/emhttp/plugins/dynamix.plugin.manager/scripts/plugin install https://raw.githubusercontent.com/theone11/swapfile_plugin/master/swapfile.plg (Other emhttp)

Sep 17 18:12:20 P8H67 logger: plugin: creating: /tmp/swapfile-install - from INLINE content

Sep 17 18:12:20 P8H67 logger: plugin: running: /tmp/swapfile-install

 

gui comes up

but starting the plugin is a no go

 

Sep 17 18:12:56 P8H67 emhttp: run_cmd: invalid cmd: /etc/rc.d/rc.swapfile start (Other emhttp)

 

so if you could look into this :)

 

 

updated the unraid version to right version

Share this post


Link to post

Sep 17 18:12:56 P8H67 emhttp: run_cmd: invalid cmd: /etc/rc.d/rc.swapfile start (Other emhttp)

 

It is the new security changes implemented in unRAID 6.1 - Working on it...

 

Share this post


Link to post

i felt adventurous today so i uninstalled this plug... upgraded to 6.2

6.2? The latest public release as of today is 6.1.2.

Share this post


Link to post

Updated Plugin:

 

2015.09.17

  - Add unRAID 6.1 compatibility and keep backward compatibility

 

Share this post


Link to post

Works :)

 

top - 10:01:53 up 21:32,  1 user,  load average: 2.59, 2.95, 2.99
Tasks: 289 total,   3 running, 286 sleeping,   0 stopped,   0 zombie
Cpu(s): 22.8%us, 44.7%sy,  0.0%ni, 31.8%id,  0.7%wa,  0.0%hi,  0.0%si,  0.0%st
Mem:   8177440k total,  8106480k used,    70960k free,   147872k buffers
Swap:  4194300k total,   311112k used,  3883188k free,  3601232k cached

 

Thanks Theone

 

 

Share this post


Link to post

i felt adventurous today so i uninstalled this plug... upgraded to 6.2

6.2? The latest public release as of today is 6.1.2.

 

LOL got carried away...

Share this post


Link to post

Just updated to latest unRAID version and needed to reboot.

 

Swapfile was a disaster.  I have my swapfile on a SSD managed by unassigned devices.  The plugin needs to start later in the bootup sequence.  unassigned devices had this problem as well and moved to a different trigger.

 

essentially - needs to wait until all devices are mounted and available - otherwise it tries to make the swapfile in ram, runs out of space and causes everything else to fail.

 

Had to disable for now

 

Thanks

Myk

 

Share this post


Link to post

Just updated to latest unRAID version and needed to reboot.

 

Swapfile was a disaster.  I have my swapfile on a SSD managed by unassigned devices.  The plugin needs to start later in the bootup sequence.  unassigned devices had this problem as well and moved to a different trigger.

 

essentially - needs to wait until all devices are mounted and available - otherwise it tries to make the swapfile in ram, runs out of space and causes everything else to fail.

 

Had to disable for now

 

Thanks

Myk

 

I will change the start event from "disks_mounted" to "started" and "unmounting_disks" to "stopping_svcs" like I did for the virtualbox plugin and Limetech do for the Docker and VMs.

 

Share this post


Link to post

Plugin updated:

 

2015.09.21

- Changed start and stop events to "started" and "stopping_svcs" instead of "disks_mounted" and "unmounting_disks" to allow all array and non-array disks to be mounted before creating/using swap file

 

Share this post


Link to post

Plugin updated:

 

2015.09.21

- Changed start and stop events to "started" and "stopping_svcs" instead of "disks_mounted" and "unmounting_disks" to allow all array and non-array disks to be mounted before creating/using swap file

 

I'm running with this (clean install after removing swapfile.plg file and dir) and still having the same problem as MyKroFt. It starts on boot and not after the array is mounted. This is on unraid 6.1.6.

Share this post


Link to post

Kindly request ability to change vm.swappiness value from plugin GUI.  Thanks.

Share this post


Link to post

Had some issues with my cache drive yesterday and ended up reformatting it. Now when I try to start the swap I get "swapon failed: Invalid argument". I am creating the swap on /mnt/cache as recommended and I didn't have any issues with the plugin until I reformatted the cache drive.

Any ideas?

 

Tried to do it manually via SSH and encountered the same error:

 

root@VOID:~# swapon -v /mnt/cache/swapfile

swapon on /mnt/cache/swapfile

swapon: /mnt/cache/swapfile: found swap signature: version 1, page-size 4, same byte order

swapon: /mnt/cache/swapfile: pagesize=4096, swapsize=4294967296, devsize=4294967296

swapon: /mnt/cache/swapfile: swapon failed: Invalid argument

 

Share this post


Link to post

Had some issues with my cache drive yesterday and ended up reformatting it. Now when I try to start the swap I get "swapon failed: Invalid argument". I am creating the swap on /mnt/cache as recommended and I didn't have any issues with the plugin until I reformatted the cache drive.

Any ideas?

 

Tried to do it manually via SSH and encountered the same error:

 

root@VOID:~# swapon -v /mnt/cache/swapfile

swapon on /mnt/cache/swapfile

swapon: /mnt/cache/swapfile: found swap signature: version 1, page-size 4, same byte order

swapon: /mnt/cache/swapfile: pagesize=4096, swapsize=4294967296, devsize=4294967296

swapon: /mnt/cache/swapfile: swapon failed: Invalid argument

 

Try running swapoff on this swapfile and then swapon again.

 

Share this post


Link to post

Had some issues with my cache drive yesterday and ended up reformatting it. Now when I try to start the swap I get "swapon failed: Invalid argument". I am creating the swap on /mnt/cache as recommended and I didn't have any issues with the plugin until I reformatted the cache drive.

Any ideas?

 

Tried to do it manually via SSH and encountered the same error:

 

root@VOID:~# swapon -v /mnt/cache/swapfile

swapon on /mnt/cache/swapfile

swapon: /mnt/cache/swapfile: found swap signature: version 1, page-size 4, same byte order

swapon: /mnt/cache/swapfile: pagesize=4096, swapsize=4294967296, devsize=4294967296

swapon: /mnt/cache/swapfile: swapon failed: Invalid argument

 

Try running swapoff on this swapfile and then swapon again.

Same issue. It will create the swap file fine but it won't start it. Let me know what info you might need from me to troubleshoot.

 

root@VOID:~# swapoff -v /mnt/cache/swapfile

swapoff on /mnt/cache/swapfile

swapoff: /mnt/cache/swapfile: swapoff failed: Invalid argument

root@VOID:~# swapon -v /mnt/cache/swapfile

swapon on /mnt/cache/swapfile

swapon: /mnt/cache/swapfile: found swap signature: version 1, page-size 4, same byte order

swapon: /mnt/cache/swapfile: pagesize=4096, swapsize=4294967296, devsize=4294967296

swapon: /mnt/cache/swapfile: swapon failed: Invalid argument

 

 

Share this post


Link to post

Had some issues with my cache drive yesterday and ended up reformatting it. Now when I try to start the swap I get "swapon failed: Invalid argument". I am creating the swap on /mnt/cache as recommended and I didn't have any issues with the plugin until I reformatted the cache drive.

Any ideas?

 

Tried to do it manually via SSH and encountered the same error:

 

root@VOID:~# swapon -v /mnt/cache/swapfile

swapon on /mnt/cache/swapfile

swapon: /mnt/cache/swapfile: found swap signature: version 1, page-size 4, same byte order

swapon: /mnt/cache/swapfile: pagesize=4096, swapsize=4294967296, devsize=4294967296

swapon: /mnt/cache/swapfile: swapon failed: Invalid argument

 

Try running swapoff on this swapfile and then swapon again.

Same issue. It will create the swap file fine but it won't start it. Let me know what info you might need from me to troubleshoot.

 

root@VOID:~# swapoff -v /mnt/cache/swapfile

swapoff on /mnt/cache/swapfile

swapoff: /mnt/cache/swapfile: swapoff failed: Invalid argument

root@VOID:~# swapon -v /mnt/cache/swapfile

swapon on /mnt/cache/swapfile

swapon: /mnt/cache/swapfile: found swap signature: version 1, page-size 4, same byte order

swapon: /mnt/cache/swapfile: pagesize=4096, swapsize=4294967296, devsize=4294967296

swapon: /mnt/cache/swapfile: swapon failed: Invalid argument

 

Exactly the same problem. It was working before I change my cache drive (SSD on XFS to SSD on btrfs)

 

Is there any problem with btrfs format ??

Share this post


Link to post

Is there any problem with btrfs format ??

 

Swapfiles aren't supported on btrfs format disks. Look back a couple of pages in this thread.

Share this post


Link to post

Hopefully in the future

 

https://btrfs.wiki.kernel.org/index.php/FAQ#Does_btrfs_support_swap_files.3F

 

best way on a btrfs right now they say is to do it via a loop file - like the current docker/vm images are mounted

 

dont know if that method can be easily added to this plugin or not

 

Sounds like not a good idea on btrfs at all according to this:

 

Swap file

 

As an alternative to creating an entire partition, a swap file offers the ability to vary its size on-the-fly, and is more easily removed altogether. This may be especially desirable if disk space is at a premium (e.g. a modestly-sized SSD).

 

Warning: Btrfs does not support swap files. Failure to heed this warning may result in file system corruption. While a swap file may be used on Btrfs when mounted through a loop device, this will result in severely degraded swap performance.

 

Swap file creation

 

As root use fallocate to create a swap file the size of your choosing (M = Megabytes, G = Gigabytes). For example, creating a 512 MB swap file:

 

# fallocate -l 512M /swapfile

 

Note: fallocate may cause problems with some file systems such as F2FS or XFS.[1] As an alternative, using dd is more reliable, but slower:

 

# dd if=/dev/zero of=/swapfile bs=1M count=512

 

Set the right permissions (a world-readable swap file is a huge local vulnerability)

 

# chmod 600 /swapfile

 

After creating the correctly sized file, format it to swap:

 

# mkswap /swapfile

 

Activate the swap file:

 

# swapon /swapfile

 

Myk

 

Share this post


Link to post

Just as a confirmation to anyone needing it, i'm running the latest beta 21 and have just set up a 32GB swap file on my NVMe drive with no issues, htop reports the 32GB correctly so all seems to be working as expected

Share this post


Link to post

I am also having the same problem with this plugin (invalid argument).

 

For now I just upgraded my ram to take care of hitting the old cap occasionally.

Share this post


Link to post

Just installed this because my unraid server keeps crashing and I feel like its to do with running out of memory, it has created a 4gb swapfile on the btrfs cache drive, a few posts up suggests that this shouldn't work, is that still the case today?

 

Top shows the following:

Tasks: 433 total,   1 running, 432 sleeping,   0 stopped,   0 zombie
%Cpu(s):  1.1 us,  0.6 sy,  0.0 ni, 97.1 id,  1.1 wa,  0.0 hi,  0.0 si,  0.0 st
KiB Mem : 20568732 total,   305412 free, 15428820 used,  4834500 buff/cache
KiB Swap:        0 total,        0 free,        0 used.  4048564 avail Mem

 

Just changed it to /mnt/disk4/cache and now it shows:

 

Tasks: 454 total,   2 running, 452 sleeping,   0 stopped,   0 zombie
%Cpu(s):  2.3 us,  3.1 sy,  0.0 ni, 90.1 id,  4.4 wa,  0.0 hi,  0.2 si,  0.0 st
KiB Mem : 20568732 total,   943764 free, 15212644 used,  4412324 buff/cache
KiB Swap:  4194300 total,  3877760 free,   316540 used.  4246276 avail Mem

 

So I guess that means its working, could you put the swapfile on a flash drive formatted as vfat?

Edited by Spies

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now