Learn how to change swappiness in Linux to optimize system performance. Follow our step-by-step guide to adjust this kernel parameter and enhance your system’s memory management. #centlinux #linux #ubuntu
A swap partition is a designated area on a hard drive or SSD that is used as virtual memory by the Linux operating system. When the physical RAM (Random Access Memory) is fully utilized, the system can move inactive or less frequently used memory pages from RAM to the swap partition. This helps free up physical memory for more urgent tasks and processes.
Key points about swap partitions:
In summary, a swap partition is a useful feature in Linux that helps manage memory more effectively, especially on systems with limited RAM. It acts as a safety net to ensure the system remains functional under heavy memory loads.
The Linux kernel’s swappiness setting defines how aggressively it will swap memory pages versus dropping pages from the page cache.
A higher value increases swap aggressiveness, while a lower value tells the Linux kernel to swap as little as possible to disk and favor RAM.
The swappiness range is from 0 to 100, and most Linux distributions have swappiness set to 60 by default.
Some database servers managed cache to use RAM, and is capable of managing what should be in RAM and what shouldn’t be. Allowing the Linux operating system to have too much control over what memory pages are in RAM is likely to lower your database performance. Therefore, it is recommended that swappiness should be set to 0.
If you are new to Linux and facing difficulty in working at Linux Bash prompt. We recommend that, you should read The Linux Command Line, 2nd Edition: A Complete Introduction by William Shotts.
or you may also attend online training: Learn Bash Shell in Linux for Beginners
Check current setting of swappiness.
# cat /proc/sys/vm/swappiness 60
Set the swappiness setting to 0 for the running system.
# sysctl -w vm.swappiness=0 vm.swappiness = 0
Verify the current setting of swappiness again.
# cat /proc/sys/vm/swappiness 0
To make swappiness setting persistent, you have to add it in Kernel parameter file.
# echo 'vm.swappiness=0' >> /etc/sysctl.d/99-swappiness.conf
You have successfully change the swappiness for your Linux distribution.
Understanding and adjusting the swappiness value in Linux can significantly improve your system’s performance based on your specific needs and workloads. By fine-tuning this parameter, you can optimize memory management and ensure that your system runs efficiently. If you need personalized assistance or further guidance on adjusting swappiness or other Linux performance tweaks, I offer professional services on Fiverr. Check out my Fiverr gig for expert help in optimizing your Linux system.
Puppy Linux is a fast, lightweight OS designed for speed and simplicity, perfect for old…
Learn how to change Apache document root in Linux by following this step-by-step guide. Adjust…
Discover how to change Apache port in Linux easily. Follow our simple guide to modify…
Learn how to create a virtual host in Apache Server with this comprehensive guide. Set…
Discover 10 practical tasks for the RHCSA exam with step-by-step solutions. Boost your Linux skills…
Discover the ultimate Fail2ban configuration guide. Learn how to set up, customize, and optimize Fail2ban…
This website uses cookies.