Setting the vm.swappiness Linux Kernel Parameter

The Linux kernel parameter, vm.swappiness, is a tuning parameter for the virtual memory subsystem, it has a value from 0-100 that controls the swapping of application data (as anonymous pages) from physical memory to virtual memory on disk. The higher the value, the more aggressively inactive processes are swapped out from physical memory. The lower the value, the less they are swapped, forcing filesystem buffers to be emptied. The value can be found (and changed) directly by the file /proc/sys/vm/swappiness and in sysctl it is available as “vm.swappiness” configuration parameter. Just to make sure that the parameter is not set under a wrong name (vi.swappiness should have no effect to the system, if it is written as this to /etc/sysctl.conf). The OS default is usually 60, you can see what value your system is set to by running the following command:
# cat /proc/sys/vm/swappiness

It is responsible for the mechanism, how the  linux kernel tries to get “free” memory (See the “top” command or “cat /proc/meminfo”). The kernel always tries to have some spare memory around, if processes require some new memory. At a specific point, there is no “real” free memory available, because all physical memory is claimed by the kernel, the block cache or the applications on the machine. This is the time, when the vm.swappiness value jumps in.

Systems with memory constraints that run batch jobs (processes that sleeps for long time) might benefit from an aggressive swapping behavior.

To change swapping behavior, use either echo or sysctl
# sysctl -w vm.swappiness=90
# echo 90 > /proc/sys/vm/swappiness

Tuning the Linux memory subsystem is a tough task that requires constant monitoring to ensure that changes do not negatively affect other components in the server. If you do choose to modify the virtual memory parameters (in /proc/sys/vm), change only one parameter at a time and monitor how the server performs.

There are some calculation you should consider when changing your settings. The parameter value set to “60” means that your kernel will swap when RAM reaches 40% capacity. Setting it to “100” means that your kernel will try to swap everything. Setting it to 10 means that swap will be used when RAM is 90% full, so if you have enough RAM memory, this could be a safe option that would easily improve the performance of your system. If you set swapping to “1” or even “0”. “1” is the minimum possible “active swapping” setting while “0” means disable swapping completely and only revert to when RAM is completely filled. While these settings can still theoretically work, testing it in low-spec systems of 2GB RAM or less may cause freezes and make the OS completely unresponsive.

How to increase rpool in Solaris

In ZFS, it is not possible to add one more disk on the root pool for the reason that it is the root disk, for a senior system engineer, this logic is pretty straight forward.
Imagine if the root pool has multiple disks, if one disk was removed for some reason, the system will become unbootable.

What if you get a request to extend the rpool, because for some reason, the project manager has put /var, /usr or /home in the same rpool, these directories usually fills up fast and highly suggested to be a separate filesystem from root filesystem.

There is only one way to extend the rpool space. For an instance the rpool size is 20GB and they want you to extend to 50GB.
You can do the below steps:

  1. Add a bigger size root hard disk, in this case 50GB
  2. Mirror the rpool using the new 50GB hard disk
  3. Installboot block on the new disk
  4. Detach the old disk from rpool

Continue Reading…