Multiple prioritized swap devices

If you need multiple swap partition to handle a huge use of memory, you can set-up two different HDDrives (partitions on the same drive are useless) with your swap space and also give a single swap partition its priority. Priority simply works this way: when the swap space in the disk with greater priority is full, the system fall back to the other (lowered priority) swap partition; priority is a value between 0 and 32767. Higher numbers indicate higher priority (see man swapon).

Q: How and where can we setup it ?

A: /etc/fstab using 'pri' option

Generally a swap partition is set as follow:

/dev/partition  none  swap  sw  0  0
# Or better, for new systems
UUID=here_goes_the_partition_ID  none  swap  sw 0  0

What we do is add an option for the swap (pri=#)

# Disk with high priority
UUID=here_goes_the_partition_ID  none  swap  sw,pri=10 0  0
# Second disk with lower priority
UUID=here_goes_the_partition_ID  none  swap  sw,pri=0 0  0

Then you can just mount all of your swap partitions

swapon -a