i dont bother with swap as ive ALMOST never needed it. if you find yourself in a situation where you do need swap just spin up a swapfile.
create a file with the size of swap space you want. Let’s say that I want to add 32 GB of swap space to my system. Use the fallocate command to create a file of size 32 GB.
fallocate -l 32G /swapfile
It is recommended to allow only root to read and write to the swap file.
chmod 600 /swapfile
You need to tell Linux that this file will be used as swap space. You can do that with mkswap
mkswap /swapfile
You should see an output like this:
Setting up swapspace version 1, size = 32 GiB (34359734272 bytes)
no label, UUID=7e1faacb-ea93-4c49-a53d-fb40f3ce016a
Now your system knows that the file swapfile can be used as swap space. You need to enable the swap file so that your system can start using this file as swap.
swapon /swapfile
when youre done just do
swapoff /swapfile
if you want to reclaim your disk space just rm it
rm -rf /swapfile