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

Jadwal Imsak dan Buka Puasa Ramadhan 2025 Kota Serang Selama Sebulan

Berikut jadwal imsak dan buka puasa Ramadhan 2025 di Kota Serang dari tanggal 1 Ramadhan -…

1 minggu ago

Jadwal Resmi Awal Puasa Ramadan 2025 Pemerintah, NU, Muhammadiyah

Jakarta - Pemerintah telah menetapkan awal Ramadan 2025 berdasarkan hasil sidang isbat oleh Kemenag. Begitu pula dengan organisasi masyarakat…

1 minggu ago

Meta AI Ditanya Luas Kebakaran Los Angeles, Hasilnya Mengejutkan Sama dengan Luas Gaza

Siapa sangka, salah satu warganet justru mendapat informasi tak terduga yang berasal dari Meta AI.…

2 bulan ago

Tebak-tebakan pelesetan kata ini lucu abis, awas ketawa ngakak

Ketika menjalani rutinitas sehari-hari tentu saja kamu pernah merasa suntuk atau jenuh. Supaya kamu bisa…

2 bulan ago

Kapal China Diduga Biang Kerok Internet Mati Total di Berbagai Negara

Sebuah kapal kargo komersial China diduga sengaja menyeret jangkarnya untuk memotong kabel bawah laut yang…

3 bulan ago

Ini Sumber Kekayaan Nabi Sulaiman, Sungguh di Luar Dugaan

Nabi Sulaiman dikenal sebagai raja yang kaya raya. Para ilmuwan arkeologi kini mengungkap apa sumber kekayaannya,…

3 bulan ago