What Is A Swap Partition And Do You Need it?: Linux

When you install windows, you install it directly and entirely on one single partition .But when it came to Linux , most of Linux distributions installation recommend that the user should include a Swap partition. So what is a Swap partition and do you really need it?.

1- Swap Partition:

Swap partition is used when the amount of physical memory (RAM) is full. So when  the system needs more memory resources and the RAM is full,  all the inactive pages in memory are moved to the Swap partition. Which means that  swap partition can help your machine when you have a small amount of RAM  , you can say that the Swap partition is nothing but a  replacement for more RAM but always keep in mind that Swap partition is a real partition on your hard drive so it will have a slower access time than physical memory. 

2- Do You Need A Swap Partition:
2-1 Replacement of physical memory (RAM):
A 2GB of RAM is considered as a small amount of RAM on the recent Linux distribution (Ubuntu 14.04 and above for example). In this case you will need a Swap partition because  when your  RAM is full, your additional applications will use the SWAP partition rather than memory to run (keep in mind this process can make your pc slower). 
The formula is Swap partition should equal 2*physical memory if you have a 2gb or less  of RAM and 2+Physical memory if you have more than 2 Gb of RAM:
– For example, if you have 2 Gb of RAM then the Swap Partition should be 2*2 = 4Gb and if you have 3 Gb of RAM then The Swap Partition should be 3+2 = 5GB.
Well actually you can install Linux without a Swap Partition if you have 3Gb or more of physical memory (RAM). 

2-2 Enable Hibernation :
A SWAP partition is used as the destination of your memory’s contents whenever you tell your system to hibernate. This means that without a SWAP partition, hibernation on Linux is impossible.

2-3 When your Swap Partition Doesn’t help:
Swap partition doesn’t help when you have like 1 Gb or less of physical memory or a slow hard disk  (5400rpm) or both of them. In this case even if you have a swap partition it won’t help you,  your PC or laptop will be extremely slow and you will be unable to work with it until you close some apps in order to free up some memory.
3- My opinion :

I am going to share with you my own opinion about this matter. Actually I think that swap partition is needed  even if you have a large amount of RAM because Linux is an Operating system which is not perfect like any other operation systems . Sometime the kernel will pick one or more processes which it thinks are good candidates and kill them and  a good amount of physical memory will never saves you sometimes from that so your work will be lost if you didn’t have that swap partition.I feel uncomfortable loosing parts or all of my work because the kernel thinks my applications are worth killing. And with the current size of an average disk being in the TB range, reserving a few percent for swap is usually not an issue.
 finally , I hope this article was helpful for you and let me know your opinion about this in the comment section. 

Otaku,Cats lover and of course the founder of www.pr0t3ch.com "When life gets hard.. just Watercool and OVERCLOCK !"