I understand swap is like an extention to RAM and is mostly used when the amount of free memory is below a certain threshold - which can be set with vm.swappiness in /proc/sys/. Swap can also be used for hibernation, like virtual memory on Windows.

I've come across this answer which tells a bit more about swap and how it can be used to reduce memory usage, or like disk cache:

Swap is useful because applications that aren't being used can be stored on disk until they are used. Then they can be "paged in" and run normally again. While it is not in memory, though, the OS can use that memory for something else, like disk cache.

But apart from these, what is swap used for? If I never (theoretically) run out of available memory, and don't use hibernation, would there be any downsides to having no swap? Would there be any performance improvements? Longer disk lifespan?

  • This doesn't really answer your question so I'm putting it as a comment here: other than for hibernation, you never need a swap partition. You can apt-get install dynamic swap by installing the swapspace package. This package automatically ads more swap when you need it and cleans up swap files when you don't need it. Sep 30, 2020 at 14:35

3 Answers 3


If you have enough RAM and never use hibernation, swap is completely useless.

In theory if some RAM pages are sent to swap, there is more RAM available for cache and the most active applications, that can slightly improve performance.

But the process of swapping itself is slow.

If you have enough RAM, or even just enough, it is more useful to install zram-config to improve performace a bit. It will create a compressed swap in RAM.


When battery in your laptop goes below a threshold, it is hibernated and shutdown. In the process of hibernation, the contents of RAM is dumped into the SWAP partition.




Edit: Post Ubuntu-18.04, Ubuntu automatically creates a swap file in root file system if a separate swap partition is not made.

Ref: https://askubuntu.com/a/1234843/1107236


It is always useful to have some swap just in case you need some extra free memory when memory pressure gets high. Also the kernel will swap out pages that have not been used for a while and this frees up more physical memory for caching file data and this should lead to better I/O performance. Finally, the underlying virtual memory subsystem behaves differently when swap is enabled and this can affect the way the kernel selects processes that need OOM'ing when memory is really tight.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .