Create A Swap File
How to create a swap file.
A 2GB swap file.
<pre lang="bash">
dd if=/dev/zero of=/swapfile bs=1k count=2048k
Activate.
<pre lang="bash">
mkswap /swapfile
chmod 0600 /swapfile
systemctl daemon-reload
swapon /swapfile
To make swap permanent, add to /etc/fstab.
<pre lang="bash">
/swapfile swap swap defaults 0 0
Check if swap is working.
<pre lang="bash">
cat /proc/swaps
free -h