Main Content

Linux - where to put swap space

Archive - Originally posted on "The Horse's Mouth" - 2004-12-16 06:02:00 - Graham Ellis

Swap Space is used on Unix and Linux systems to provide additional pseudomemory resources. In other words, if you try to run so many processes that they won't all fit into memory at the same time, the operating system will swap them in and out of the swap space.

Swap space can be either disc partition(s) (a.k.a. slice(s)) dedicated to the task, and/or file(s) held within the file system. Although the operating system will attempt to swap as efficiently as possible, it does turn into a heavy resource burden sometimes and it's worth tuning your file system layout to take note of this:
a) Use Swap partitions rather than files (but files are great for a temporary expansion if you need it)
b) If you have multiple disc drives of the same speed, spread the swap area between them
c) If you have multiple disc drives of different speeds, put you swap space on the fastest
d) Keep the swap space in the middle of the disc / close to often used files to mimimise head movements
e) If you are using network drives, do NOT put any swap space onto a remote drive!