Virtualmin System Swap File Issue

Hi guys,
I am about to increase my swap file size…its in the red at 90% and i have plenty of spare system RAM (4GB system using about 50%)

Anyway, i thought i would unmount the swafile using virtualmin. Webmin>System>Disk and Network File Systems>Virtual Memory>Mount Now= Unmount

Imagine my surprise when i see the following…

Screen Shot 2020-06-07 at 9.07.16 am

How is the possible? I note my system also was doing this kind of thing with Dovecot (ie saying it wasnt running when it clearly was)
I dont see this as being a Virtualmin problem, seems to be a debian thing?


  1. I also cannot delete the file in File manager so i can create a new one with a larger size.
  2. When we create a new swapfile in virtualmin file manager, how do we set the size using virtualmin (for example 1GB)?

Before adding more swap space consider an adjustment to your swappiness setting and figure out why swap is filling up out of balance with RAM. A full swap space happens sometimes but if it’s too often and too fast something is off and for all you know the extra 50 percent will be gobbled up. Before swap gets to 99 percent you can use swapoff and swapon commands to clear it out if rebooting isn’t an option.

Sorry i had to edit the above post so the first image would show up.
Notice how in virtualmin it says that the swapfile isnt mounted, however, memory -m shows swap space. and its showing up in virtualmin dashboard as virtual memory.

How is that possible?

Also, i did as you suggested yesterday or the day before (ie swapoff swapon and reset it), however, its already at 99% again after not even 48 hours. The system has plenty of spare RAM so i dont understand why all of a sudden, after running for more than a year, the system is now doing this (it didnt seem to be an issue before).

Finally, I cant seem to edit the swapfile in virtualmin filemanager, so i cant change the swapiness level in webmin>system>disk and network …it wont let me even though webmin says the swapfile isnt mounted. Why is that?

You can’t edit a binary paging file unless you’re using a hex editor. Not recommended.

Your swap is a paging file, as opposed to a partition on disk, so those mount settings in Webmin are probably fine. Are you getting different info from Webin than what these commands tell you?

cat /proc/swaps
swapon -s
fdisk -l

Try a few things in a terminal. Since your swap is full, might as well clear it before going further.

swapoff -a

Wait a few seconds before running

swapon -a

View your swappiness setting. It’s probably 30 or higher on a 4gb VPS.

cat /proc/sys/vm/swappiness

Try setting it to 10 or below.

sysctl vm.swappiness=10

The setting is active at this point but resets after the next reboot. For persistant swappiness use an editor to add the value to sysctl.conf.

nano /etc/sysctl.conf

While you’re in there add this setting too if it’s not there already.


Save the file and run

sysctl -p

After the next reboot the new setting should still be there.

cat /proc/sys/vm/swappiness

Webmin’s graphs are useful but these monitoring commands will give you detailed numbers in a more timely fashion.

free -g
free -k
free -m
vmstat 1 5

I still think your problem isn’t solved by increasing swap size, but maybe I’m wrong.

Last time my swap partition filled up the problem turned out to be Fail2Ban. There’s no simple way to flush Fail2Ban for a fresh start but there’s a way to zap its database.

ClamAV uses a ridiculous amount of RAM because of gigantic signature databases that need to be active all the time (in swap). If SpamAssassin loads big RBLs on a busy mail server it needs a place stash them (swap). Low-volume mail systems don’t need all that, but if you’re hosting email for customers you don’t have the luxury of turning off these inefficient services. Just keep an eye on mail server defenses because sometimes they’re offensive.


@ramin this is such a great comment!

And, you’re absolutely right, it’s probably fail2ban. Could also be clamd, but fail2ban is more likely as it uses that memory mapped disk data structure that is always swappable.

1 Like

Thank you, @Joe. And a dandy job you and your team have done with CentOS 8. Debian 10 looked good too. Deciding was a tough call.

So i have done the following in putty…

nano /etc/sysctl.conf (and added the following lines to it)
nano /etc/sysctl.conf

I have then done the following:

swapoff /swapfile
fallocate -l 1G /swapfile (to increase the swapfile from 500MB to 1G)
mkswap /swapfile

I then got a warning saying

insecure permissions 0644, 0600 suggested.
Setting up swapspace version 1, size = 1024 MiB (1073737728 bytes)
no label, UUID=0cba8223-55bf-4ce2-a388-0b968dcb5f47

so next:
chmod 600 /swapfile

ls -l /swapfile returns

-rw------- 1 root root 1073741824 Jun 10 13:45 /swapfile

swapon -s returns

Filename     Type     Size    Used    Priority
/swapfile    file   1048572    0         -1

that seem good enough to you guys?

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.