Here's a simple guide how to add memory swap in your vps server to cover the memory needed when you have a low ram vps
To add a memory swap on your VPS, you can follow these steps:
1. Check if your VPS has a swap partition: First, you need to check if your VPS already has a swap partition. Run the following command to view the current swap configuration:

sudo swapon --show
This command will display any active swap partitions. If it doesn't show any output, it means you don't have a swap partition set up yet.
2. Create a swap file: If your VPS doesn't have a swap partition, you can create a swap file instead. Use the following command to create a swap file with a desired size (e.g., 5GB):

sudo fallocate -l 5G /swapfile
This will create a 5GB swap file named
3. Set the correct permissions for the swap file: Change the permissions of the swap file to restrict access:

sudo chmod 600 /swapfile
4. Enable the swap file: Enable the swap file using the following command:

sudo mkswap /swapfile
sudo swapon /swapfile
This will format the swap file and enable it as a swap area.
5. Verify the swap setup: To verify if the swap file is active, use the command:

sudo swapon --show
It should now display the swap file as active.
6. Make the swap file permanent: To make the swap file persistent across reboots, you need to add an entry in the

sudo nano /etc/fstab
Add the following line at the end of the file:

/swapfile swap swap defaults 0 0
Save the file and exit the text editor.
That's it! You have successfully created a memory swap file on your VPS. The swap file will provide additional virtual memory in case your server's RAM usage exceeds capacity.
Note: To avoid further questions, This tutorial is for advanced members only with simple/basic knowledge in vps servers
To add a memory swap on your VPS, you can follow these steps:
1. Check if your VPS has a swap partition: First, you need to check if your VPS already has a swap partition. Run the following command to view the current swap configuration:

sudo swapon --show
This command will display any active swap partitions. If it doesn't show any output, it means you don't have a swap partition set up yet.
2. Create a swap file: If your VPS doesn't have a swap partition, you can create a swap file instead. Use the following command to create a swap file with a desired size (e.g., 5GB):

sudo fallocate -l 5G /swapfile
This will create a 5GB swap file named
/swapfile. You can adjust the size as per your requirements.3. Set the correct permissions for the swap file: Change the permissions of the swap file to restrict access:

sudo chmod 600 /swapfile
4. Enable the swap file: Enable the swap file using the following command:

sudo mkswap /swapfile
sudo swapon /swapfile
This will format the swap file and enable it as a swap area.
5. Verify the swap setup: To verify if the swap file is active, use the command:

sudo swapon --show
It should now display the swap file as active.
6. Make the swap file permanent: To make the swap file persistent across reboots, you need to add an entry in the
/etc/fstab file. Open the /etc/fstab file using a text editor:
sudo nano /etc/fstab
Add the following line at the end of the file:

/swapfile swap swap defaults 0 0
Save the file and exit the text editor.
That's it! You have successfully created a memory swap file on your VPS. The swap file will provide additional virtual memory in case your server's RAM usage exceeds capacity.
Note: To avoid further questions, This tutorial is for advanced members only with simple/basic knowledge in vps servers
