• We value your experience with Plesk during 2024
    Plesk strives to perform even better in 2025. To help us improve further, please answer a few questions about your experience with Plesk Obsidian 2024.
    Please take this short survey:

    https://pt-research.typeform.com/to/AmZvSXkx
  • The Horde webmail has been deprecated. Its complete removal is scheduled for April 2025. For details and recommended actions, see the Feature and Deprecation Plan.

Question increase swap partition on ubuntu 16

Alaa Mansour

Basic Pleskian
Hello everybody,

I have a server with 8GB of RAM, and I keep getting the message:
Advanced monitoring

The swap usage threshold has been exceeded​

now when running this command:
Code:
sudo swapon --show

I get:
Code:
NAME      TYPE      SIZE USED PRIO
/dev/dm-1 partition 1.9G 1.6G   -1

I'm using the VPS of Ionos.com they use SSD disks want to increase the swap space, should I just increase the swap partition? and how to do it?
or should I disable the swap partition and create a swap file? and how to do it?
thank you all very much
 
they told me that they don't do any kind of intervention on the server, as I have complete control over it.
so I would have to do it by myself
 
I wouldn't recommend trying to resize mounted filesystems remotely unless you absolutely know what you're doing, so I guess you're stuck with using a swap file.
See the man pages for mkswap and swapon for how to create and configure such a file. I recommend specifying a lower priority for swapon in fstab because swap file is slower than swap partition.
 
Would not upgrading to more RAM be the correct solution? If you run into swap usage, it is an indication that your RAM is too small. The moment when swap comes into play, the system performance is considerably degraded. Your server can slow down to a point where it feels like it is almost not responding at all. So instead of upgrading the swap space, it may be better to upgrade the RAM.
 
OP didn't write anything about monitoring complaining about RAM usage threshold, so I assume that is not a problem (yet).

Depending on swappiness, linux kernel will swap not recently used application data out in favor of keeping more cache available. This is often faster than keeping code/data in RAM that e.g. is only used at startup/shutdown of that app. So though you have sufficient RAM available or even free (not used for cache/buffers) there may still be swap usage.
 
yeah, as I thought, the "real" RAM usage does not exceed half of physical RAM, the kernel is just swapping out pages it doesn't use much in favor of having more cache during the backup. You can see those pages aren't really needed as they stay swapped out even after cache goes back down after 2:00. If they were accessed, they would be swapped back in.
So, nothing to worry about, just the kernel optimizing use of the available ressources.
 
you can issue following commands as root to add 4GB to swap in a file, so without the need to resize partitions etc.
Code:
# fallocate --length 4G /swapfile
# chmod 600 /swapfile
# mkswap /swapfile
# swapon /swapfile
 
Back
Top