What is a linux swap partition, and what does it do?

Most Linux installations recommend that you include an exchange partition. This may seem strange to Windows users, who are accustomed to having their entire operating system on a single partition.

What does an exchange, you may even need one, and how big should it be? All of these are important questions that, with the right answers, can greatly improve the performance of your system.

Memory overflow


In it’s simplest sense, the swap partition acts as a memory overflow (RAM). If the memory is completely full, any additional application will be performed outside the swap partition instead of memory.

This sounds like an easy way to increase the amount of usable memory without getting more RAM, but that’s not the case. RAM is the ideal hardware for memory because it is extremely fast, unlike hard drives that are, in relative terms, very slow. In addition, they do not want to cause additional wear and tear on their solid-state drive. The advent of solid-state drives have made performance in a minor problem with their much improved speeds – but even they can not match RAM.

The closest analogy of the swap partition can be Windows paging file, although there are many technical differences between the two.


A swap partition can also help some memory elements on the hard drive in order to leave more memory space for the more important elements. This implies that the items being touched would almost never get transferred to the swap partition.

The threshold of what is considered “rare” depends on the “swappiness” (yes, that is the current term used), which can be configured. A higher swappiness means that items are more likely to be moved to the SWAP partition – meaning less swappiness that is less likely to be transferred to the swap partition.

Allow hibernation

Finally, a swap partition is used as the destination of the contents of your memory every time you tell your system to hibernate. This means that without an exchange partition, hibernation in Linux is impossible.

Of course, in fact it is quite rare for users to use the hibernate feature, so this may not matter to you.

Do you need an exchange partition?

So does this mean that an exchange partition is needed? Absolutely not! A Linux system can perform perfectly well without an exchange partition. However, there are some advantages and disadvantages of having one.


  • Provides overflow space when memory is full
  • You can move the necessary items seldom away from your high-speed memory
  • Allows you to hibernate


  • Take up space on the hard disk as swap partitions do not resize dynamically
  • May increase hard disk wear
  • Performance does not necessarily improve (see below)

When swap partitions do not help

What? Swap partitions do not always help improve performance? I’ll explain a scenario where you have an exchange partition was actually worse than having none.

I had Linux installed on a netbook that only had 1 GB of memory and a hard drive of 5400 rpm. With just 1 GB of memory, you can imagine that it can fill up pretty quickly with a couple of open tabs on your browser. The SWAP partition allowed me to keep all of them open as the memory overflow simply went to it.

But then a bottleneck appeared, due to the 5400 rpm speed of the hard drive. Because the hard drive was so slow, and the system constantly wanted to access the swap partition, the netbook was made very, very slow to the point where it became virtually unusable unless it shut down everything to free up some memory.

The swappiness set does not guarantee that, even though there was now space in memory, everything on the swap partition would be backed up. Instead, a lot of it would stay in the swap partition, causing the netbook to continue to be slow. This was only fixed by a restart, which took a while anyway because the system had to remove everything from the partition before shutting down.


So, this is what I recommend:

  • If you would like to be able to hibernate the computer, then you should have a swap partition. The size of this partition should be the size of the installed memory, plus an additional 10-25% leaving space for items that have already moved more towards the swap partition.
  • If you want a small increase in performance (and you have at least a 7200 rpm hard drive), then you can add a SWAP partition if you want, but it is not necessary unless you have less than 4 GB of Memory installed. The size of this may be what you want, but it would not do anything bigger than it would if you were creating a SWAP partition to enable hibernation.
  • If you have a 5400 rpm hard drive then you should not create a swap partition simply because the bottleneck will make the computer worse. SWAP, then you can still create a partition using the same size guidelines described above – but change the swappiness value to something much lower.

Swappiness change

To change the swappiness, you need to run the command gksu gedit /etc/sysctl.conf that will launch a text editor with the name Gedit, a fantastic all around text editor, for the configuration file we need to change. Then find “vm.swappiness” and change it to a different value (preferably 10). If you do not see this parameter, add this line to the end of the file: vm.swappiness = 10

The value you enter indicates when you want Linux to actively start moving processes from the swap partition’s memory. So, for example, a value of 10 indicates that processes will move when memory usage.

There are a lot of other details involved in this, but it would only make things more confusing.


Swap partitions can make a big difference in the performance of your system – sometimes good and sometimes bad. Now that you are well educated, you should be able to make the right decisions.

Are you looking for other ways to speed up the Linux system? Check out these four other quick and easy tips .

What have you heard about the swap partitions? Do you think it’s worth using? Let us know in the comments!

About the author


Is An Online Platform

For Latest Gist On News, Entertainment, Business Tips & Updates, Dating Tips, My School News And More To Explore From Us.


  • These days is a partition really necessary?
    Personally I would argue in favour of a swap file instead.
    Main benefit being that it is so much simpler to resize as needed

    • Hello Dave.
      Thanks for your contribution.. Actually partition is necessary and I can say it’s better to use partition rather than swap file.. Though I understand that Ubuntu want to make life easier for users.. That’s why they introduced swap file.. But their are some facts I want you to look into.

      In short, a Swap partition will never have fragmentation.

      A swap file may have fragmentation. If the swap file is generated when you install the system or with a disk with space there is no problem, but if you generate it when your hard disk is full then you will have a swap file with fragmentation.

      All this that I have discussed is only valid for mechanical hard disks because SSDs have no fragmentation.

      Also note that Creating a Swap file loses space if or if, and the more distros you use on a computer, the more you lose.

      In the case of VPS server is a solution for the server does not crash, but what you must do in the short term is to increase your RAM.

      No doubt SSD disk helps your experience with the use of swap space is positive. On a mechanical disk it is not.
      I will create a thread about the swap partition and file swap in the forum… Kindly stay tuned


  • If you are ever curious about how your system would run without swap, you can disable it temporarily with “sudo swapoff -a”.

  • Swap was in its heyday when servers had multiple disks. Put a swap partition on each disk and they will be accessed in parallel. Swap kills performance in single-disk systems. With today’s RAM prices, swap is obsolete.

    • You are right… But I will share a post in the forum today.. I will like you to see some points that I will figure out there..
      Stay tuned for the post.. Or you can kindly subscribe to get alert once posted..
      If you don’t mind.. I will like you to share your experience so far about file swap.. So others will benefit from it..
      Take a look at our new forum Here


Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.