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.
4 people found this article useful
4 people found this article useful