Recommended swap size for Linux systems

Two importance of swapping memory is as, first like when the system requires more memory than is statically available, the kernel swaps out less used pages and provides memory to the application and second the number of pages used application in the startup phase may only be used for initialization and not used again. The system swaps out pages and frees the memory for other resources.

So many people use the old method that the swap partition should be twice the size of the system. In a current era that is a lot of swaps, most of the systems never swap. People don’t want their system to ever run out of memory ( RAM + SWAP) , but they usually would rather have enough RAM in the system so it doesn’t need to swap.

If we add a large amount of RAM to a system, we don’t need to extend a large amount of swap space.

Why do we need to swap the partition file system?

When physical memory ( RAM) is full, then the system needs more resources of memory. The swap will be used when the amount of physical memory is full then inactive pages in memory are moved to the swap filesystem.

The amount of swap memory recommended for Linux depends on some factors including the amount of memory in the system and the workload on the memory.

SWAP Memory Recommendation

2GB of RAM requires 2 times the amount of RAM
2GB-8GB RAM requires Equal to the amount of RAM
8GB to 64GB of RAM requires 0.5 times the amount of RAM
64GB of RAM requires 4 GB of swap space

Recommended swap space if allowing for hibernation

2GB of RAM requires 3 times the amount of RAM
2GB-8GB RAM requires 2 times the amount of RAM
8GB to 64GB of RAM requires 1.5 times the amount of RAM
64GB of RAM requires No extra space needed

By Sachin G

I am a professional freelance contributor and founder of tech transit. Love to write and lover of education, culture, and community. I have been using it, setting, supporting, and maintaining it since 2009.Linux rocks! Sachin G Follow me on LinkedIn and x formerly twitter