Skip to content
Calcrivo

Swap Size Calculator

Get a recommended Linux swap partition size based on installed RAM and whether hibernation support is needed.

Inputs

GB

Hibernation requires swap large enough to hold the entire RAM image

Recommended Swap Size

8.00GB

Standard Recommendation (no hibernate)

8.00GB

Hibernation-Safe Recommendation

10.83GB

Rule Applied

2GB < RAM ≤ 8GB → equal to RAM

Step by step

  1. Values used

    Installed RAM = 8 GB; Support Hibernation (suspend-to-disk) = No

  2. Swap for RAM ≤ 2GB

    swap = 2 × RAM

  3. Swap for 2GB < RAM ≤ 8GB

    swap = RAM

  4. Swap for RAM > 8GB

    swap = max(4, √RAM)

  5. Hibernation-safe swap

    swap = RAM + √RAM

  6. Recommended Swap Size

    = 8.00 GB

  7. Standard Recommendation (no hibernate)

    = 8.00 GB

  8. Hibernation-Safe Recommendation

    = 10.83 GB

  9. Rule Applied

    = 2GB < RAM ≤ 8GB → equal to RAM

How it works

Swap sizing guidance varies with installed RAM. Small-memory systems (≤2GB) benefit from swap double their RAM because the OS itself needs breathing room. Mid-size systems (2-8GB) do well with swap equal to RAM. Large-memory systems (>8GB) rarely need swap proportional to RAM, so the recommendation flattens to the larger of 4GB or the square root of RAM. If hibernation (suspend-to-disk) is required, swap must be at least RAM plus a safety margin (approximated here as RAM + √RAM) since the entire RAM image is written to swap on suspend.

Formulas

Swap for RAM ≤ 2GB

swap = 2 × RAM

R
installed RAM in GB

Swap for 2GB < RAM ≤ 8GB

swap = RAM

R
installed RAM in GB

Swap for RAM > 8GB

swap = max(4, √RAM)

R
installed RAM in GB

Hibernation-safe swap

swap = RAM + √RAM

R
installed RAM in GB

Frequently Asked Questions

Do I need swap if I have a lot of RAM?

Some swap is still useful even with abundant RAM — it lets the kernel move rarely-used pages out of RAM and provides a safety margin against out-of-memory situations, but it no longer needs to scale linearly with RAM.

Why does hibernation need more swap?

Hibernation writes the entire contents of RAM to swap before powering off, so the swap space must be at least as large as RAM, with a small margin for kernel bookkeeping — approximated here as RAM plus its square root.

Is swap on an SSD bad for the drive's lifespan?

Modern SSDs tolerate swap well under normal desktop/server workloads; the practical concern is more about performance (swapping is much slower than RAM) than SSD wear for typical usage patterns.

You might also need