How can the performance of multiple swap partitions be tuned?
If a system is configured with several swap partitions, the default behaviour is to make use of one partition at a time. Once one swap partition has been exhausted the next will be used.
This is not always the best method for performance, since when a new process needs to be swapped to disk it may be forced to wait until another process is swapped out.
The swap usage can be tuned in /etc/fstab to allow for all swap partitions to be used randomly based on their current activity.
For instance, if there are two swap partitions specified in /etc/fstab it will look something like this:
/dev/sdb2 swap swap defaults 0 0
/dev/sda2 swap swap defaults 0 0
Change the mount options section from ''defaults'' to ''pri=0'' :
/dev/sdb2 swap swap pri=0 0 0
/dev/sda2 swap swap pri=0 0 0
Once this has been done the system will be able to access any of the designated swap partitions independently of the others. This can increase the swap performance of a machine which is regularly swapping memory to disk. However it is important to bear in mind that in most situations a machine should not make heavy use of swap partitions. If this behaviour is occurring, it is recommended to increase the amount of physical memory in the machine.