Home » Ubuntu » How to Add Swap Memory to your Ubuntu Server

How to Add Swap Memory to your Ubuntu Server

Don’t worry even if your server has only 512 MB RAM, you can actually increase your server memory with help of swap files.In any case they are somewhat deficient regarding RAM. 615mb of RAM is sufficient to test utilizing the support and doing essential things. Anyway in the event that you need to begin doing element website pages or even begin doing database driven stuff you may begin to use up memory rapidly.


Considering this present its justified even despite making a swap “record” to facilitate the torment if you use up virtual RAM.

1gb of swap ought to be sufficient. So make your swap record in the base of your filesystem:

Follow these commands in your SSH terminal (PUTTY or any SFTP client)

The swap memory can be created as follows

[root ~]# dd if=/dev/zero of=/swapfile bs=1M count=1024
This command creates a swap file of size 1GB named swapfile in your server root.
[root ~]# mkswap /swapfile
This command creates the swap filesystem.
[root ~]# swapon /swapfile
This command mounts the swapfile.
In your server /etc/fstab file, adding the following line to fstab file
/swapfile  swap      swap    defaults         0 0
Once done check whether swap is functioning or not
[root ~]# swapon -s
Your 1GB swap memory is ready!!

2 thoughts on “How to Add Swap Memory to your Ubuntu Server

  1. perfect… thank you

  2. Wahyudi says:

    nice article I like to read your article and I hope you often post

Comments are closed.