Thursday, September 21, 2023
 Popular · Latest · Hot · Upcoming
rated 0 times [  103] [ 0]  / answers: 1 / hits: 78129  / 8 Months ago, tue, february 7, 2023, 5:17:58

My system was getting slower, especially when I use browsers like Firefox / Chromium and Virtual Machines. I noticed that I've got at least 3.2 GB of free RAM (using Gnome system monitor) and there was no swapping.

What I did now is swapoff -a and system system performance is up by 30%. So my question is: Is it safe to use swapoff? Will it be safe for my PC to restart with swapoff?

enter image description here

More From » swap


The Linux kernel provides a tweakable setting that controls how often the swap file is used, called swappiness

A swappiness setting of zero means that the disk will be avoided unless absolutely necessary (you run out of memory), while a swappiness setting of 100 means that programs will be swapped to disk almost instantly.

Ubuntu system comes with a default of 60, meaning that the swap file will be used fairly often if the memory usage is around half of my RAM. You can check your own system's swappiness value by running:

one@onezero:~$ cat /proc/sys/vm/swappiness

As I have 4 GB of RAM, so I'd like to turn that down to 10 or 15. The swap file will then only be used when my RAM usage is around 80 or 90 percent. To change the system swappiness value, open /etc/sysctl.conf as root. Then, change or add this line to the file:

vm.swappiness = 10

Reboot for the change to take effect

You can also change the value while your system is still running

sysctl vm.swappiness=10

you can also clear your swap by running swapoff -a and then swapon -a as root instead of rebooting to achieve the same effect.

To calculate your swap Formula

free -m (total) / 100 = A

A * 10

root@onezero:/home/one# free -m
total used free shared buffers cached
Mem: 3950 2262 1687 0 407 952
-/+ buffers/cache: 903 3047
Swap: 1953 0 1953

so total is 3950 / 100 = 39.5 * 10 = 395

so what it mean is that when 10 % 395 MB of ram left then it start using swapiness

[#40449] Thursday, February 9, 2023, 8 Months  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.

Total Points: 272
Total Questions: 113
Total Answers: 99

Location: Northern Mariana Islands
Member since Sun, Jul 19, 2020
3 Years ago