If you find your machine running low on physical RAM, you can add swap ram.
Swap allows inactive pages to be moved from RAM to the swap space. Swap is space allocated from your hard disk quota and reserved for swap RAM usage.
You can either create a swap partition to used as swap RAM whereby the entire partition would be dedicated to swap.
Alternatively, you can also create a file which can be used to create swap RAM with. We will use a file today!
Follow these steps to add 1GB of swap to your server. If you want to add 5GB instead of 1 GB, replace
Create a file which will be used for swap.
yum -y install fallocate
fallocate -l 1G /swap
chmod 600 /swap
Create swap space.
swapon /swapNow, we need to make the changes permanent.
To do so, we need to edit the contents of
/etc/fstaband add a new line:
/swap swap swap defaults 0 0
Swap has now been added and we can check this.
You can also remove the swap
swapoff -v /swap
Remove the entry
/swap swap swap defaults 0 0from the