ESDS Knowledge Base

07
Aug

How to optimize and increase Swap partition file with eNlight?

How to optimize and increase Swap partition with eNlight?

Introduction

Swap file partition is the conception that glues only with Linux servers; it is not used with Windows server. Windows operating system comes altogether with complete single partition, whereas, Linux operating system has separate swap file partition. Swap space also known as virtual memory on Linux server plays very important role in system performance. When the server runs out of memory, the kernel can move inactive processes to swap to make space for active processes in the working memory. 

Swap file partition need and optimization

The question is do I really need swap partition and will it really affect my system performance. Yes! Swap file partition can add up to your system performance if optimized and used in a proper way. Swap literally provides a way to run new application, if the memory has gone full. Below are advantages of Swap file partition:

  • Facilitates runoff space memory (RAM) fills up entirely
  • Rarely-used applications can be moved to Swap, for giving room for mostly used.
  • Enables Hibernation

The use of swap space can be controlled by altering the system’s swappiness value, it is recommended to be ‘1’ for Linux VMs running on eNlight Cloud Platform.

open /etc/sysctl.conf file and put the following entry : vm.swappiness = 1

Then apply the changes using the following command : sysctl –p

Increase in Swap file partition

Before increasing the Swap space on the server, it is necessary to check for enough free space available on the partition atleast larger than that of Swap size. Follow these simple steps for successful increase in swap space.

Step 1:- #dd if=/dev/zero of=/swapfile bs=1024 count=1572864 : This command creates the free space for file /swapfile to 1.5 GB

Step 2:- #mkswap /swapfile

Step 3:- #chown root:root /swapfile

Step 4:- #chmod 0600 /swapfile1

Step 5:- #swapon /swapfile1

Step 6:- #vi /etc/fstab : enter this at the end of file “/swapfile1 swap swap defaults 0 0”

Step 7:- # mount -a or free -m (check swap file size for your confirmation)

 

There you go! Your increased Swap file partition is ready.

For further queries contact our Exuberant Customer support team.

Leave a Reply