Swap file. Good for VM that has no Swap assigned.
wget -q https://kps.makz.net/run/mkfswap.sh -O - | bash
#!/bin/bash
_SIZE='2' # Gigabyte
set -e
if [ -f "/swapfile" ]
then
echo 'Swap file /swapfile already exists.'
swapon --show
else
dd if=/dev/zero of=/swapfile bs=1024 count=${_SIZE}M status=progress
chmod 600 /swapfile
mkswap /swapfile
swapon /swapfile
swapon --show
echo "Add to your /etc/fstab: /swapfile swap swap defaults 0 0"
fi