Swap File Plugin for unRAID v5 and v6


theone

Recommended Posts

  • 2 weeks later...

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

Link to comment

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

 

 

Link to comment

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

 

Link to comment

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.

 

Link to comment
  • 2 months later...

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.

Link to comment
  • 1 month later...

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

 

Link to comment

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.

 

Link to comment

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

 

 

Link to comment
  • 3 weeks later...

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 ??

Link to comment
  • 2 weeks later...

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

 

Link to comment
  • 2 months later...
  • 5 months later...
  • 4 months later...

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
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.