Swap is a great thing for people who fancy more ram but less storage. We will be using Zram — this means u will get faster and lighter swap files.
Install Zram by running this on your shell:
sudo apt install -y zram-toolsNow run this to edit the swap configuration:
sudo nano /etc/default/zramswapYou should see PERCENT & ALGO
PERCENT is how u set the swap. For example if you have a 2GB ram vps and set the percent to 50% then the swap file will be 1GB, or for example on a 4GB RAM VPS it will be 1GB if u set it to 25%
ALGO is like how the swap file is made and ran, lz4 is by far the fastest one for our servers.
After configuration save the script and u should have a swap file enabled!