admin/ July 25, 2016/ Linux/ 0 comments

Swap Space

Swap space in Linux is used when the amount of physical memory (RAM) is full. If the system needs more memory resources and the RAM is full, inactive pages in memory are moved to the swap space. While swap space can help machines with a small amount of RAM, it should not be considered a replacement for more RAM. Swap space is located on hard drives, which have a slower access time than physical memory.

How to check swap space.

If you don’t have any swap space you will get blank output.
Check Ram and Swap space using below command.

According to my this post I am going to make swap space of 1GB.

Step 1-: Create a swap file.

The above command make a swap file with 1GB space on your system disk.
To verify it, use the df -hl command like below.


Step-2: Change the permission for root only.

Step-3: Mark the as swap space.

Step 4-: Enable the swapfile allowing to use the swap file.

Now check the swap space would be like.
Use free -m command.


or Use the sudo swapon –show to check the swap space.


Additional Step-: To make the swap file permanent.
First of all we must create backup of existing fstab file.

Add the swap file into /etc/fstab file using the below command.

You will get output like below-:

Gotechnies Linux Blog

Rating: 4.9
Votes: 480
Reviews: 560

Leave a Reply

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