Tuesday, September 27, 2016

Increase Swap Size in Linux

The free -m command shows that the swap memory in your current server.

We can increase 4GB of swap size now.

Create Swap file using below command

touch /swapfile

Use the following command to create 4GB of swap file.

# dd if=/dev/zero of=/swapfile bs=1M count=4096
# mkswap /swapfile

Now the swap file is created.

activate /swapfile file swap space now.
# swapon /swapfile

Add entry on /etc/fstab file to activate after Linux system reboot.

# vi /etc/fstab
/swapfile swap    swap    defaults        0 0

save and close the file.

Now check your swap space now.

# free -m

In order to delete swap.

Run “swapoff /swapfile” command
Remove the entry from /etc/fstab file
Remove /swapfile  file (using rm command)