How can I speed up performance of my RH using multiple swap partitions?

If your system (especially a server) has multiple drives set up as a RAID 0 array (data
striping), it would automatically spread the data across all the drives in parallel, greatly
increasing the speed of disk writes versus a non-RAID setup, where the swap partition is on
only one drive. Of course, not everyone can afford a RAID setup; fortunately, there is an
alternative that offers many of the same performance benefits in a multidisk environment, at
least as far as swap space performance is concerned.
As it happens, there is a way to “parallelize” swap file read/writes through the use of the
priority setting in the /etc/fstab file. (Note: This works best with multiple SCSI drives and/or
controllers. Two IDE drives on the same controller will see little or no performance boost from
this technique, but multiple IDE drives on multiple controllers may benefit somewhat.)
Use an appropriate tool (such as kfstab [available from kfstab.purespace.de/kfstab], which
knows the exact layout of the file that fstab requires) to open the file /etc/fstab. This file lists
the partitions used by Linux, including swap space. (Note: It is possible to use a simple text
editor such as vi, but if you do not get the columns lined up just right, or if you use tabs instead
of spaces or vice versa, you can corrupt your system; so if you elect to go this route, rather
than using a tool specifically designed for editing fstab, such as kfstab, be sure to make a
backup copy of fstab first, so that you can recover if your system crashes.) 

When you open fstab, if you have multiple SCSI drives with a swap partition on each, you might see something 
like this (without the headings):  point> type> options> dump>  /dev/sda2 none swap sw 0 0 /dev/sdb2 none swap
 sw 0 0 /dev/sdc2 none swap sw 0 0 /dev/sdd2 none swap sw 0 0 

Under normal circumstances, Linux would use the swap partition /dev/sda2 first, then
/dev/sdb2, and so on, one at a time, until it had enough space to meet its current swapping
needs.
On the other hand, if you change the settings to:
/dev/sda2 none swap sw,pri=3 0 0
/dev/sdb2 none swap sw,pri=3 0 0
/dev/sdc2 none swap sw,pri=3 0 0
/dev/sdd2 none swap sw,pri=1 0 0
you will be assigning the first three partitions the same priority level—a higher one than the
fourth partition. (Swap partitions are used in order from highest priority to lowest—where a
priority level of 32767 is the highest and 0 is the lowest.) This has the effect of forcing Linux to
write to the first three partitions in parallel, greatly increasing the read/write throughput of the
swap space. The fourth partition would be used only if the first three fill up.
In addition to parallelizing the swapping, this technique also allows you to prioritize access to
the fastest drives first. Therefore, you can set up an emergency swap partition on an old, slow
drive, using low priority, so that it will be used only when all high-speed swap space is
exhausted.

Ron Jagannathan has written 54 articles

Ronan is a Caffeine dependent life-form from Planet Earth who wants to be a Jedi Knight of cloud computing. A man of mystery and power, whose power is exceeded only by his mystery. Quantum Physicist, TransHumanist, Systems Architect, Unix Administrator, Artificial Intelligence, Machine Learning and DIY Gadget enthusiast. Believes that the Universe has a high probability of being a simulation.
But he's real and hopefully some of his readers are too.
email: Ron.Jagannathan@gmail.com ph: 202 355 5205
https://www.linkedin.com/in/ronjagan/
My Famous Quotes:
“In a Unix Universe, God is known by a four letter word called root. To err is human...to really foul requires you to be root.. err.. god.” ― Ron Jagannathan

Github: github.com/ronjag
Linkedin: linkedin.com/in/ronjagan/

“Quotes found on the Internet are not always accurate.” ― Abraham Lincoln

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>