While it would be ideal if every server had plenty of RAM in the real world that does not happen. If for some reason you have a server with too little SWAP or you are hitting the max of the swap here is a quick hack which will create a 2Gb container file then use it for additional swap space on the server. To check the swap space used you can use "free -m".
dd if=/dev/zero of=/usr/swap-file bs=1024 count=2048000
mkswap /usr/swap-file
swapon /usr/swap-file
swapon -s
Now add the following to the /etc/fstab and you are done.
/usr/swap-file swap swap defaults 0 0
round-robin swap
One useful thing in adding more swap on different disks is that you can have the kernel use the different locations in round-robin as RAID0 partition.
You can do that by editing the lines for the swap in /etc/fstab. You have to change the defaults option to pri=0 on all lines defining swap.
The trick aroung pri=0 is this:
Pri comes from priority, and thus defining the priority of the swap partition/file which will be used. Every swap partition has its own unique priority which tells the kernel when it will start using this swap partition/file. Using the defaults option causes every line defined in fstab to be with a lesser priority then the one before. This means that if you have three lines for swap in fstab the first line will be with greatest priority and the last line will be with lowest priority. The kernel starts writing to the swap partitions from the greatest(0) to the lowest priority and it switches to the next priority partitions/files only if the first one is already filled.
But if you have two or more lines defined with the same priority you will tell the kernel to use all of the partitions/files in a round-robin for reads/writes, this makes the swap faster.
-----------------------------------------
One Planet, One Internet!
We Are All Connected!
Great one
Great one