All You Need To Know About Swap Partition In Linux

So somewhere while installing your favorite Linux distro you came across the word “Swap” and now you are here to know what is Swap. Well, I will tell you it in the simplest sense.  

What Is Swap Space?

Swap is a replacement or better say less-used alternative for RAM( Random Access Memory). Let’s say that when you have 512mb RAM and you are running a game and RAM suddenly gets full. Then what? There comes the role of Swap. The OS moves the less used background running applications to Swap partition and frees up RAM so that you can run your favorite game easily.

The Swap partition is created on your hard drive. So 100% they are not as fast as RAM as the speed of RAM is so great that hard disk can match. So the apps running in Swap partition are simply slower (or worse) than the apps running in RAM. So you will think Swap as useless. The answer is No! But it is not also the best. Let me show you in detail.

Actually, when your OS creates a Swap partition on your SSD, the system much of the time wants to keep the memory free. So mostly it continues to move the less frequent apps to Swap and keep up the memory free. So you can see that this can make that app or even the whole system slower like a hell. Although you can put a check on it by decreasing swappiness, that doesn’t work all the time. So you might be thinking that Swap is the waste but No! It actually becomes helpful when you are out of RAM. Think about your mom’s old computer that has only 256-512mb RAM. How will she run her favorite apps? Here Swap comes as a savior and lets you run your apps without any problem.

So what you might be thinking about how to decide whether I need it or not!. Well here are some of my tips to decide and have the best use of swap.

  1. If you have an old computer with less RAM than 2GB I recommend you use swap figuring out how much Swap space you require. Most of the time OS actually makes good choices themselves.
  2. You want to keep a lot of memory a.k.a RAM all the time, then use Swap.

​There are also some situations that you won’t like to have Swap –

  1. Your Linux OS doesn’t require a swap partition as it runs in RAM itself.
  2. You want to keep access to background apps frequently.
  3. You have a high memory a.k.a RAM.

How much size should swap partition have?

If you are using Swap I recommend you should decrease it to 10-20% so that the system access it some less frequently and your PC run smooth cause too much swappiness cause extreme lag.  Also, have less Swap partition size as too much Swap is also not god. There is a famous proverb in my country that “Know your limits when expanding feets”. So don’t create a heavy swap partition. To decrease swappiness visit your community site and search method. Mostly all distro have a method to decrease swappiness easily or hardly.

Use a low requirement OS so much RAM stays free.

There aren’t too many points about Swap. All you need to know is that it is a type of Virtual RAM that you can create yourself if your SSD is way too faster like above 7000 rpm or better. I won’t advise you to use it below this limit as it will create no difference and will ultimately cause lag.

Conclusion

I actually recommend Swap if you have a low requirement system but also too much of something is never good. I use Swap in my mom’s PC as she has 512mb RAM only but not on mine as it has 4gb. It all depends on what you do with your system but keep things in control and you are good to go loose chain and have your SSD ripped off with heat to run faster.