Swap File Plugin for unRAID v5 and v6


Recommended Posts

It's a swapfile made by this plugin... 


I've tried deleting and using the GUI to recreate numerous times (about to try manually).


but as best as I can tell, the plugin is using the correct commands (as per a google search and what's in the plugin/rc.swapfile code):


# Create swap file
logger -trc.swapfile -plocal7.info -is "Creating swap file ${SWAP_LOCATION}/${SWAP_FILENAME} please wait ..."
dd if=/dev/zero of=${SWAP_LOCATION_NEW}/${SWAP_FILENAME_NEW} bs=1M count=${SWAP_SIZE_MB_NEW}
# Assign SWAP_NAME to the swap file
# Change swap file permissions as required
# Turn on swap file usage
logger -trc.swapfile -plocal7.info -is "Swap file ${SWAP_LOCATION_NEW}/${SWAP_FILENAME_NEW} created and started"

Link to comment

There's a user-controllable flag in the plugin UI to control whether the swap lasts past array stop.  I have tried both deleting the swapfile on stop & keeping it.


The swap file is being created in /mnt/user/apps (which is a cache-only share).


The file's complete path is:




It's on a brand-new, precleared drive (5400rpm laptop - don't think that matters) that was added when my old cache drive died (and when the plugin worked for me - i kept the swap file between array stop/starts)

Link to comment

OK that makes sense now.

Try creating on the disk mount point instead of the user share.


/mnt/cache/.swapfile or something like that.


What I've just read, is that it could be that the file system does not support swap.


usershare being a filesystem in user space.


I just created a swapfile manually on my /mnt/disk1/.swapfile and I was successful

Link to comment

well that did it :).  man, i wish i had my hours back...


I forgot to mention that OCD forced me to consolidate my plugins to always reference the same base path for app data:




Prior to my drive crash, it was /mnt/cache/apps.  now that same ocd is wondering if I should switch them all to /mnt/cache...


Thanks so much!!!

Link to comment

I just tested this by hand, here are my results.


root@unRAID2:/# dd if=/dev/zero of=/mnt/user/swapfile bs=1M count=256

256+0 records in

256+0 records out

268435456 bytes (268 MB) copied, 3.08609 s, 87.0 MB/s


root@unRAID2:/# mkswap -L SWAP /mnt/user/swapfile

mkswap: /mnt/user/swapfile: warning: don't erase bootbits sectors

        on whole disk. Use -f to force.

Setting up swapspace version 1, size = 262140 KiB

LABEL=SWAP, UUID=77b9d51f-163b-43a8-8977-71b3e709470e


root@unRAID2:/# swapon -v /mnt/user/swapfile

swapon on /mnt/user/swapfile

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

swapon: /mnt/user/swapfile: pagesize=4096, swapsize=268435456, devsize=268435456

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


root@unRAID2:/# swapon -v /mnt/disk1/swapfile

swapon on /mnt/disk1/swapfile

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

swapon: /mnt/disk1/swapfile: pagesize=4096, swapsize=268435456, devsize=268435456


root@unRAID2:/# top -b | head

top - 20:16:42 up 2 days,  1:24,  3 users,  load average: 0.22, 0.12, 0.08

Tasks:  72 total,  1 running,  71 sleeping,  0 stopped,  0 zombie

Cpu(s):  0.0%us,  0.1%sy,  0.0%ni, 99.7%id,  0.1%wa,  0.0%hi,  0.0%si,  0.0%st

Mem:  4146032k total,  616828k used,  3529204k free,    7608k buffers

Swap:  262140k total,        0k used,  262140k free,  498764k cached


Link to comment
  • 2 weeks later...
  • 5 months later...
  • 1 year later...
  • 3 months later...

Trying to get this to work.... will it work if the swapfile is in a hard drive that is ReiserFS (array drive) or BTRFS (my cache drive). My array drives are old and I rather not reformat.... I do have a new cache drive which is btrfs.


I created a new unRAID system for my sister, and it works perfectly if I store it to XFS formatted drive (array).


But I need this to work on my old system.


Please help.





Link to comment
  • 3 weeks later...

Mine is reiserfs and works perfectly. I actually never tried it on anything else.


The plug-in is essentially broken under unRAID 6 because it defaults to creating the swap file on the cache drive without checking the filesystem format on that drive. The cache drive in turn now defaults to being btrfs formatted, which according to the swapon manpage does not support swap files. It gives the "swap file has holes" error. It would be nice if the plug-in checked first before creating the swap file and, on detecting an incompatible filesystem, warned the user and exited gracefully.

Link to comment

I've been searching this board for a reliable way to implement a swap space but I'm struggling because it contains a lot of outdated information. I don't want to use reiserfs at all and will stick with the default use of XFS on my data disks and btrfs on my cache disk so after a little thought I came up with the idea of using a swap partition on my cache disk. So I did a bit of searching to see if unRAID supports the idea.


This thread suggests that multiple partitions are supported as long as the cache is on partition 1. However this message, while confirming that it is theoretically possible, says that a bug was introduced back in 2011 that prevented it from working. Does anyone know the position with version 6.0.1 in 2015, please?


Link to comment
  • 2 weeks 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.

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.