Edukasi

How to Change the Swappiness Value in Linux

Swap space is a part of the hard disk that is used when the RAM memory is full. The swap space can be a dedicated swap partition or a swap file .

When a Linux system runs out of physical memory, inactive pages are moved from the RAM to the swap space.

Swappiness is a Linux kernel property that sets the balance between swapping out pages from the physical memory to the swap space and removing pages from the page cache. It basically defines how often the system will use the swap space.

This article explains how to change the swappiness value on Linux systems.

Checking the Swappiness Value

To check the current swappiness value on your system, use the following cat command:

cat /proc/sys/vm/swappiness

The default swappiness value on most Linux distributions is 60:

60

While the swappiness value of 60 is appropriate for most users, in some cases, you may need to set a lower value.

Another command that you can use to determine the swappiness value is sysctl:

sysctl vm.swappiness
vm.swappiness = 60

Changing the Swappiness Value

Swappiness can have a value between 0 and 100. A value of 0 instructs the kernel to aggressively avoid swapping out for as long as possible. A value of 100 will aggressively be swapping processes out of physical memory.

A lower value will make the kernel to try to avoid swapping whenever possible while a higher value means the kernel will try to use the swap space more aggressively.

Accessing swap memory is much slower than accessing physical memory directly. A lower value for the swappiness parameter will most likely improve overall system performance. For regular desktop installation, a value of 10 is recommended. A swappiness value of 0 or 1 is recommended for most database servers.

The optimal swappiness value depends on your system workload and the size of the RAM memory . You should adjust this parameter in small increments to find an optimal value.

For example, to set the swappiness value to 10 at runtime, type the following command as root or sudo user:

sudo sysctl vm.swappiness=1

To make the swappiness parameter persistent across reboots open the /etc/sysctl.conf file with your text editor :

sudo nano /etc/sysctl.conf

Locate the vm.swappiness parameter and change its value. If this parameter does not exist, append the following line to the file:

/etc/sysctl.conf
vm.swappiness=1

Conclusion

We have shown you how to change the value of the swappiness parameter.

NOTE: Accessing swap space is considered much slower compared to accessing physical memory. Therefore, setting your swappiness value to 100 will not guarantee an increase in speed.

ryan

Recent Posts

Cara Tambahkan Stiker Add Yours di WhatsApp Status

WhatsApp Status kembali mendapatkan fitur baru. Setelah cukup lama diuji coba, WhatsApp akhirnya merilis fitur 'Add…

1 jam ago

Mark Zuckerberg Ingin AI Jadi Teman untuk Orang yang Kesepian

Chatbot AI saat ini sudah umum dipakai menjadi asisten digital. Tapi menurut Mark Zuckerberg, AI juga bisa…

12 jam ago

Polytron Itu Mobil Listrik Nasional atau Bukan?

Polytron jadi merek Indonesia yang terjun dalam industri mobil listrik. Polytron disebut-sebut bakal menjadi mobil…

15 jam ago

Pesaing China Muncul, Bikin AI Pakai GPU Murah Meriah

Fastino, startup kecerdasan buatan asal Amerika Serikat, memamerkan model AI barunya yang ditujukan untuk bisnis. Menariknya, model AI…

15 jam ago

Jangan Terima Kasih dan Minta Tolong ke ChatGPT, Bikin Boncos

Sopan terhadap AI seperti ChatGPT mungkin dilakukan beberapa orang karena memang mirip bicara pada manusia. Namun siapa…

15 jam ago

Rockstar Klaim Cuplikan Keren Trailer Kedua GTA 6 dari In-Game PS5

Trailer kedua GTA 6 sudah rilis. Menariknya, kualitas yang disuguhkan sungguh memesona dan memanjakan mata. Namun…

15 jam ago