How to Increase Swap Memory In Ubuntu 18.04 – [Solved]

What is Swap Memory

Swap Memory is a part of your computer storage (HDD/SSD) that temporarily works as a RAM. Whenever you overload your RAM, your machine starts lagging and sometimes even hangs completely. So here, we have a SWAP Memory to solve that problem(Kind of).

Whenever you start overloading your computer with multiple applications and most of your available RAM gets consumed it starts using swap memory. Files and applications with the least priority are compressed and stored into your swap file and, RAM holds files with high priority. Whenever you start using that application back it gets loaded back to the RAM.

It’s obvious that here, the processor has to do more work for compressing and decompressing files, but in my experience, I have seen that most of the time huge part of my processor remains unused. so I don’t think that can be the problem considering the advantage swap memory provides

Let’s get started!

To see current swap memory:

sudo swapon –show

If you have any swap file available then it will appear. Here you will be able to see the size of the swap file as well. Here below you can see that I have 8 GB swapfile size. Initially, it was 2 GB But I Increased it to 8GB.

If you already have any swapfile then before changing its size you need to turn it off first.

To turn off swapfile for swapping

sudo swapoff /swapfile

To increase or change the size of the swapfile

sudo fallocate -l 8G /swapfile

Here 8G is the size of swapfile.

To tell the system for using this file for swapping

sudo mkswap /swapfile

To turn on the swapping

sudo swapon /swapfile

Now you can again use the first command swapon –show to see the swapfile size in your system.

courtesy: Youtube Video

About Geek Kishan

Tech enthusiast | Geek | Programmer | Web developer | Introvert. Love to read and write about technology. I want to share my little knowledge with the world hoping that it will help someone.

View all posts by Geek Kishan →

Leave a Reply

Your e-mail address will not be published. Required fields are marked *