# Assume I need another 2GB
# Allocate 2GB in another file. Let's call it swapfile2g.
sudo fallocate -l 2G /swapfile2g
# Make it secure
sudo chmod 600 /swapfile2g
# Activate it
sudo mkswap /swapfile2g
sudo swapon /swapfile2g
# Confirm again there's indeed more memory now
free -m
sudo swapon -s
# Configure fstab to use swap when instance restart
sudo nano /etc/fstab
# Add this line to /etc/fstab, save and exit
/swapfile2g none swap sw 0 0