Sun Jan 20 2019

What is SWAP partition in Linux?

SWAP partition in Linux

Traditionally, Linux was developed for a server system. Server systems are built to process several processes simultaneously. Sometime some process may use more than expected memory. Any service may use more memory at its peak time. Linux uses swap space to deal with the shortage of physical memory. The swap is the space of hard disk that can be used as the memory. There has always been a lot of confusion around swap size.

So, here we explore what swap partition is and how swap space is used in Linux.

Let's get started -

What Is Swap partition?

Swap is a replacement or better say less used alternative for RAM( Random Access Memory). The swap partition is used by the Linux kernel in order to implement the memory-swap mechanism. When there is not enough physical memory available in RAM, the kernel searches the least used pages and copy their contents in the swap partition.

You can create a swap partition which will be used by Linux to store idle processes when the physical RAM is getting low. The swap partition is basically disk space set aside on your hard drive. It's obviously much quicker accessing RAM than files stored on your hard drive. If you find that you are constantly running out of memory and your hard drive is whirring it is likely that you are excessively using swap space.

For instance, 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, this can make that app or even whole system slower. Although you can put a check on it by decreasing swap, though that doesn’t work all the time.

So, you may think that Swap is the waste; but No! It actually becomes helpful when you are out of RAM.

Here are the best use of Swap -

  • If you have a computer with less RAM than 2GB, recommend that you use swap figuring out how much Swap space you require. Most of the time OS actually makes a good choice themselves.

  • If, you want to keep much memory a.k.a RAM all the time, then use Swap.

  • If your system uses resource heavy applications like video editors, it would be a good idea to use some swap space as your RAM may be exhausted here.

  • If you use hibernation, then you must add swap because the content of the RAM will be written to the swap partition. This also means that the swap size should be at least the size of RAM.


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.

If you are using Swap, it's recommended that you should decrease it to 10-20%. So that system access it some less frequently and you PC runs smooth. On the other side, too much swap can cause extreme lag. So don’t create a heavy swap partition.

To decrease swap space, visit the community site and search the methods. Mostly all distro have a method to decrease swap partition easily or hardly.

We use cookies to improve your experience on our site and to show you personalised advertising. Please read our cookie policy and privacy policy.