Sizing a Swap Partition

It is still one of the first questions when installing a unixoid OS: do you still need a swap partition and how big should you make it. In the old days™ this was an important question because disk space was expensive and the OS memory management had several constraints.

Today both memory and disks are cheap enough to make this question insignificant in many cases. One can usually buy enough memory to prevent swapping, and with terrabyte disks it makes no real difference whether the swap partition is 1 Gb or 4 Gb in size.

I still use the old rule of thumb and allocate twice the size of RAM for a swap partition. But the intention is not so much to swap memory pages but rather to always have enough space for kernel core dumps. My basic reasoning is:

  1. In case of kernel errors I want to get a core dump.
  2. A later RAM upgrade is relatively cheap and easy, thus probable over a system’s lifetime.
  3. A later disk re-partitioning is more difficult, thus to avoid.
  4. Disk space is cheap, allocating ≤ 5% for a mostly unused swap partition has no significant cost.

 

Comments are closed.