Skip to content
View in the app

A better way to browse. Learn more.

Unraid

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

[Plugin] Swapfile for 6.9.1

Featured Replies

  • Author
6 hours ago, Zeench said:

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?

Other than taking up disk space none that I am aware of. The plugin has been known to struggle to format large swapfiles, basically the gui hangs or the operation fails waiting for swapfile creation to complete. I dont think thats your case though as the swapon command seems to show a functioning swapfile.

 

Also did you say what version of unRAID you are running?

Edited by primeval_god

  • Replies 134
  • Views 40.2k
  • Created
  • Last Reply

Top Posters In This Topic

Most Popular Posts

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

  • If you want to get in as early as possible during startup and as late as possible during shutdown then the best place for this would be the config/go and config/stop script files (the latter does not

  • 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 bui

Posted Images

  • Author
6 hours ago, Zeench said:

image.png.20c20915a518c83328c35f5752a31d79.png

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

Actually, something i just noticed, your swapfile size is set to 10 MB not GB. Couple of things for you to try if you would. Could you verify that the fields for location, filename, and swap name contain no extra whitespace at the end? Additionally please re-specify your swapfile size using only digits (no . or , etc).

 

On 7/26/2023 at 11:30 AM, Zeench said:

image.thumb.png.b1a7a5411708f0f1d4de714c1c22c3e2.png

Edited by primeval_god

23 hours ago, primeval_god said:

Actually, something i just noticed, your swapfile size is set to 10 MB not GB. Couple of things for you to try if you would. Could you verify that the fields for location, filename, and swap name contain no extra whitespace at the end? Additionally please re-specify your swapfile size using only digits (no . or , etc).

 

Ty very much for that good support here. 

Its working now, wasnt a blank, it was the "slash" in the location...

Now its working just fine.

image.thumb.png.c7c0b2d02c42678447cf3434fc1c97ad.png

Edited by Zeench

Is there a reason the swap file would fill up if I still had heaps of ram free? Today I had about 30 gigs RAM free and the swap file was sitting at around 7 gig (91%)

  • Author
4 hours ago, DrSpaldo said:

Is there a reason the swap file would fill up if I still had heaps of ram free? Today I had about 30 gigs RAM free and the swap file was sitting at around 7 gig (91%)

What setting do you have for swappiness? Lower values will swap data out less aggressively.

8 hours ago, primeval_god said:

What setting do you have for swappiness? Lower values will swap data out less aggressively.

 

Hi, I just left it at the default (60)

  • 1 month later...

I just installed and am having some issue trying to get this to work. I am hoping you may be able to help. I click start and it creates the appropriately sized swap file, but it doesn't actually start the swap. I read through some other posts, here is some information that hopefully is helpful.

 

Unraid Version: 6.12.4

Assigned swap file to an NVME cache drive.

Output of "swapon -s" is blank.

 

System Log:

Oct  1 11:02:25 Computer kernel: swapon: swapfile has holes
Oct  1 11:02:25 Computer rc.swapfile[11716]:  Swap file /mnt/user/NVME/swap/swapfile re-used and started
Oct  1 11:02:25 Computer rc.swapfile[11717]: Setting swappiness to 1

 

Screenshot of my settings.

 

Thank you very much!

Screenshot 2023-10-01 at 11-08-00 Korriban_swapfile.png

  • Author
2 minutes ago, Bovive said:

I just installed and am having some issue trying to get this to work. I am hoping you may be able to help. I click start and it creates the appropriately sized swap file, but it doesn't actually start the swap. I read through some other posts, here is some information that hopefully is helpful.

 

Unraid Version: 6.12.4

Assigned swap file to an NVME cache drive.

Output of "swapon -s" is blank.

 

System Log:

Oct  1 11:02:25 Computer kernel: swapon: swapfile has holes
Oct  1 11:02:25 Computer rc.swapfile[11716]:  Swap file /mnt/user/NVME/swap/swapfile re-used and started
Oct  1 11:02:25 Computer rc.swapfile[11717]: Setting swappiness to 1

 

Screenshot of my settings.

 

Thank you very much!

Screenshot 2023-10-01 at 11-08-00 Korriban_swapfile.pngwhat file system is your cache drive 

 

3 hours ago, primeval_god said:

 

 

It is xfs.

  • Author

Looks like you are using a user share path instead of a disk share path. Make sure the path to your swap file is directly via the nvme disk share. Also delete both the swap file and the folder it is in before re-specifying the path. I think the help text may have a note about that.

On 10/1/2023 at 9:34 PM, primeval_god said:

Looks like you are using a user share path instead of a disk share path. Make sure the path to your swap file is directly via the nvme disk share. Also delete both the swap file and the folder it is in before re-specifying the path. I think the help text may have a note about that.

 

Thank you, that absolutely was the case and fixed it right up. Much apprecaited!

  • 3 months later...

Edit : fixed the issue myself. I had to do several things :

- backup cache files

- stop array

- delete cache pool

- remove 1 cache drive (don't think i need 2 anyway)

- reformat the remaining cache drive to XFS (was BTRFS)

- restart array

- recreate cache shares because everything was missing (had backup for that)

- reconfigure swapfile plugin to cache drive as shown :

image.thumb.png.cf0953d9fad625ce4c5aa3759c498dbf.png

 

It works !

 

Quote

 Hi I just installed swapfile but don't think it's working.

I'm on 6.12.6

 

Jan 23 18:04:56 SRVBRUH root: plugin: running: anonymous
Jan 23 18:04:56 SRVBRUH root: plugin: creating: /boot/config/plugins/swapfile/swapfile-package-2023.04.23b.txz - downloading from URL https://github.com/dcflachs/swapfile_plugin/releases/download/2023.04.23b/swapfile-package-2023.04.23b.txz
Jan 23 18:04:57 SRVBRUH root: plugin: checking: /boot/config/plugins/swapfile/swapfile-package-2023.04.23b.txz - MD5
Jan 23 18:04:57 SRVBRUH root: plugin: running: upgradepkg --install-new /boot/config/plugins/swapfile/swapfile-package-2023.04.23b.txz
Jan 23 18:04:57 SRVBRUH root: plugin: running: anonymous
Jan 23 18:04:58 SRVBRUH root: plugin: running: anonymous
Jan 23 18:04:58 SRVBRUH root: plugin: swapfile.plg installed
Jan 23 18:07:20 SRVBRUH emhttpd: cmd: /usr/local/emhttp/plugins/swapfile/scripts/rc.swapfile updatecfg true false /mnt/disk4 swapfile UNRAID-SWAP 10240 60
Jan 23 18:07:21 SRVBRUH rc.swapfile[23205]: Plugin configuration written
Jan 23 18:07:27 SRVBRUH emhttpd: cmd: /usr/local/emhttp/plugins/swapfile/scripts/rc.swapfile start
Jan 23 18:07:27 SRVBRUH rc.swapfile[23475]: Creating swap file /mnt/disk4/swapfile please wait ...

 

image.thumb.png.265c94526fa81338ce3876e3c8f6b7e7.png

 

I chose /mnt/disk4 as a location (xfs) because i have 2 cache drives and read it would not work.

image.png.965763cccceb195a8544bf941a4401cf.png

image.png.2bd0ef4c9940a2d725c1e5477d3521fc.png

 

Also, Is there a reason why text is overlapping?

 

Thanks

 

Edited by theosusan

  • Author
On 1/23/2024 at 12:15 PM, theosusan said:

Edit : fixed the issue myself. I had to do several things :

- backup cache files

- stop array

- delete cache pool

- remove 1 cache drive (don't think i need 2 anyway)

- reformat the remaining cache drive to XFS (was BTRFS)

- restart array

- recreate cache shares because everything was missing (had backup for that)

- reconfigure swapfile plugin to cache drive as shown :

...

It works !

 

 

I am glad you got it working. I dont think you needed to go through all that just to get swap working, but having swap on an array disk is not ideal so it may be better that you did. My guess us that the issue was your 10GB swap file size. This plugin struggles creating large swap files as the webui portion can time out before the underlying file operations complete. You could likely have created the file from the terminal then started it from the plugin just fine. 
p.s. as to why putting the swapfile on the array is not a recommended configuration, it will tend to keep the disk it is on spun up at all times (and thus also parity).

Hi

I uninstalled this plugin, but I still see kswapd0 and kcompactd0 using CPU.

I have asked on unraid discord and it seems it's not usually running at all for other unraid users.

 

Anyway to remove kswap entirely?

  • 4 weeks later...

When typing "10G" or swap amounts above 10000, I noticed the pluggin stops working :

Cache is missing when typing "free -m".

  • Author
On 1/24/2024 at 8:43 PM, primeval_god said:

... This plugin struggles creating large swap files as the webui portion can time out before the underlying file operations complete. You could likely have created the file from the terminal then started it from the plugin just fine. 

 

22 hours ago, primeval_god said:

 

So it really was out of luck that 10000 worked and 10001 failed !

 

 

I searched and found on this topic some indications to use the terminal :

 

 

dd if=/dev/zero of=/mnt/ssd/swap/swapfile bs=1M count=32768
btrfs property set /mnt/ssd/swap/swapfile compression none
mkswap -L swapfile /mnt/ssd/swap/swapfile
chmod 600 /mnt/ssd/swap/swapfile
swapon -v /mnt/ssd/swap/swapfile

 

Would you mind validating that this matches the settings bellow ? :)

765377615_Screenshot2024-02-21at09_10_10.thumb.jpg.3c8541d4ff75b0b90973d117add7132f.jpg

 

I tried, but first row created the right file, but second row gets me :

ERROR: failed to set compression for /mnt/ssd/swap/swapfile: Invalid argument

 

And while the filehas been created after a few seconds, the options doesn't update to the right size on the pluggin.

 

And regarding swapiness, should I run this ?

 

sysctl /mnt/ssd/swap/swapfile.swappiness=10

 

Thanks !

 

Note that I'm doing this for GitLab CE repository that wants to eat all my ram.

I probably could find the answers by googling, but I'm hopping some user may find this post useful.

Edited by dboris

  • Author
7 hours ago, dboris said:

So it really was out of luck that 10000 worked and 10001 failed !

 

 

I searched and found on this topic some indications to use the terminal :

 

 

dd if=/dev/zero of=/mnt/ssd/swap/swapfile bs=1M count=32768
btrfs property set /mnt/ssd/swap/swapfile compression none
mkswap -L swapfile /mnt/cache/ssd/swapfile
chmod 600 /mnt/ssd/swap/swapfile
swapon -v /mnt/ssd/swap/swapfile

 

Would you mind validating that this matches the settings bellow ? :)

765377615_Screenshot2024-02-21at09_10_10.thumb.jpg.3c8541d4ff75b0b90973d117add7132f.jpg

 

I tried, but first row created the right file, but second row gets me :

ERROR: failed to set compression for /mnt/ssd/swap/swapfile: Invalid argument

 

And while the filehas been created after a few seconds, the options doesn't update to the right size on the pluggin.

 

And regarding swapiness, should I run this ?

 

sysctl /mnt/ssd/swap/swapfile.swappiness=10

 

Thanks !

 

Note that I'm doing this for GitLab CE repository that wants to eat all my ram.

I probably could find the answers by googling, but I'm hopping some user may find this post useful.

Did you create the folder called "swap"? If so delete it and and recreate it with the command "btrfs sub create /mnt/ssd/swap". Swapfiles need to be in a subvolume on btrfs. The plugin should create it automatically if it is allowed to create the folder as well as the swapfile.

  • 1 month later...

Since the last 2 minor unraid updates it seems that mkswap can't grab the created swapfile anymore (on xfs), resulting in a massive CPU load (50 to over 100 load on a 16 thread CPU) ending in the system being unresponsive.

Edited by BIGFAT

  • Author
2 hours ago, BIGFAT said:

Since the last 2 minor unraid updates it seems that mkswap can't grab the created swapfile anymore (on xfs), resulting in a massive CPU load (50 to over 100 load on a 16 thread CPU) ending in the system being unresponsive.

Logs (specifically anything that mentions swapfile) and the specifics of your settings would be helpful. Also the actual unRAID Version as i am not certain what the last 2 minor releases were. 
 

On 3/29/2024 at 7:44 PM, primeval_god said:

Logs (specifically anything that mentions swapfile) and the specifics of your settings would be helpful. Also the actual unRAID Version as i am not certain what the last 2 minor releases were. 
 

Will try again once parity is fully sync again in about 24 hours since i couldn't really check for logs and didn't save them otherwise before crashing. Had to hard reset the system yesterday after it got unresponsive and didn't do the regular shutdown over the case shutdown button. What i stated was only what i could perceive in the "surviving" unresponsive ssh htop shell. After uninstalling the plugin system is stable again. But since some workload i use likes a lot of ram i still need this plugin on the long run :).

 

PS: Nothing special in the logs, for now it seems to work again without any issues.

Edited by BIGFAT

  • 5 months later...

I've encountered a issue.

 

The swap file location was configured to: `/mnt/disks/ssd1`, but automount for the disk was not enabled, so the filesystem was not mounted.

 

The script will try to create the swap file in `/mnt/`filesystem, where is not enough disk space. The script `/usr/local/emhttp/plugins/swapfile/scripts/rc.swapfile` has no error check for `dd` command creating the swap file and thus did not detect any error:

    # Create swap file
    logit "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}

 

Maybe we should check if target filesystem has enough free space before creating the swap file to avoid this issue?

 

At least the script should check if `dd` command was successfull and or should check if swap file does have the desired size?

Edited by pixeldoc81
Reformatting

  • Author
13 hours ago, pixeldoc81 said:

The swap file location was configured to: `/mnt/disks/ssd1`, but automount for the disk was not enabled, so the filesystem was not mounted.

I am guessing that ssd1 is a disk mounted with unassigned devices? The plugin wasnt really designed with those in mind. A permanent single disk pool is really more suited to hosting a swapfile.

On 9/26/2024 at 2:32 AM, primeval_god said:

I am guessing that ssd1 is a disk mounted with unassigned devices? The plugin wasnt really designed with those in mind. A permanent single disk pool is really more suited to hosting a swapfile.

You are right, this is a single disk mounted with unassigned devices plugin.

 

Using a single disk pool did not cross my mind. I will give it a try.

 

IMHO better error handling would be great. Is the swapfile plugin source on github to maybe contribute a pr?

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

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.