swap what is it good for…
steps to add swap
Create empty file
Traditional:
dd if=/dev/zero of=/mnt/swap16G bs=1G count=16
Fast:
fallocate -l 16G /mnt/swap16G
Make Swapfile and enable
mkswap /mnt/swap16G
chmod 600 /mnt/swap16G
swapon /mnt/swap16G
Enable on boot
Add to the /etc/fstab
if you want to keep the settings
/mnt/swap16G none swap sw 0 0
Note
If using things like AWS instance-store-volume adding the file to the /etc/fstab
is not appropriate.
You could create the swapfile on the fly or you could create one swapfile, compress it, and decompress on each boot.
In Ubuntu and other probably others using the /etc/rc.local
file can be a decent choice (there are others).
gunzip -c /swap16G.gz > /mnt/swap16G
chmod 600 /mnt/swap16G
swapon /mnt/swap16G