oio11: (Default)
[personal profile] oio11

How do I configure swappiness?


19 down vote accepted
.......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 60 
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

Help . Ubuntu . Swap


What is swappiness

The swappiness parameter controls the tendency of the kernel to move processes out of physical memory and onto the swap disk. Because disks are much slower than RAM, this can lead to slower response times for system and applications if processes are too aggressively moved out of memory.
. swappiness can have a value of between 0 and 100
. swappiness=0 tells the kernel to avoid swapping processes out of physical memory for as long as possible
. swappiness=100 tells the kernel to aggressively swap processes out of physical memory and move them to swap cache
The default setting in Ubuntu is swappiness=60. Reducing the default value of swappiness will probably improve overall performance for a typical Ubuntu desktop installation. A value of swappiness=10 is recommended, but feel free to experiment.

Started Using swap at 91%
enter image description here As i have configured my system & vm to make use of ram at 90 % . At 90 % there was no swapping
after that i opened some application like Firefox & Shutter , its start swapping because of ram usage is above 90 %
shareimprove this answer

http://askubuntu.com/questions/103915/how-do-i-configure-swappiness


Swap в Ubuntu:оптимизация

Ubuntu при использовании больше 60% оперативной памяти начинает активно использовать swap.

Это полезно когда стоит сервер с большой нагрузкой и мало оперативной памяти, если это настольная система и достаточно оперативной памяти(у меня 2гб ) то лучше использовать оперативную память больше(работает быстрее) на 90%.
Для того чтоб проверить при какой нагрузке на оперативку начинает использоваться swap открываем терминал и вводим;
sudo cat /proc/sys/vm/swappiness
если стоит 10 то оставляем все как есть , 60 продолжаем.
Для того чтоб временно переключить открываем терминал и вводим:
sudo sysctl -w vm.swappiness=10
действует до перезагрузки.
Чтоб постоянно поменять в терминале вводим ;
sudo gedit /etc/sysctl.conf
и в открывшемся файле в самом конце добавляем строчку
vm.swappiness=10

сохраняем и перегружаемся.
http://ubuntual.com/swap-в-ubuntuоптимизация/



https://help.ubuntu.com/community/SwapFaq

October 2025

S M T W T F S
   1234
567891011
12131415161718
19202122 232425
262728293031 

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Feb. 4th, 2026 08:26 am
Powered by Dreamwidth Studios