In previous article, we covered how to Set priority for Swap devices in Ubuntu. Just to brief you. Virtual Memory is a combination of Physical memory (RAM) and Swap space. If we launch an application then, it takes up space in RAM. Processes/applications would fail, if they require RAM space larger than what our system can offer. To avert that, we have Swap space.
So, processes require memory space which is allocated in the form of pages. Availability of Swap space would make the Kernel move inactive pages from RAM to Swap space. This frees up the RAM. And, processes can continue to function instead of failing.
Swap space in form of files or partitions are there on a physical disk. But, if there are multiple physical disks involved then we may prefer the faster one. That is where we need to prioritize. A higher priority value would show that Swap space has got higher priority. And, when higher priority Swap space is full then, the Kernel would utilize the next Swap space in priority.
Swap priority values
A user can set priority value which is greater than equal to zero (0) but less than equal to 32767 for a Swap device. These values can be set through /etc/fstab. When we provide value greater than 32767 then, the system would on its own set the maximum value to 32767. If there are two or more Swap devices which exceeds 32767, then both of these devices would have priority value: 32767.
But, for an arbitrary negative priority value it assigns priority values -2 and lower in sequence.
Swap priority -2
So, a user is allowed to set a priority value between 0 and 32767. But, when no priority value is set by the user then, system will automatically start assigning priority values -2 and lower. Earlier it was -1 and lower. -1 is now a reserved promoted value.
For instance, if we add Swap partitions/files without priority values then, system will assign priority values as -
/dev/sda10 -2 /swap.img -3 /swap1G.img -4 /swap2G.img -5