Creating the swapfile
1
| sudo dd if=/dev/zero of=/swapfile bs=1M count=4096 status=progress
|
This creates a swapfile and allocates 4GB for it
Set the required permissions
1
| sudo chmod 600 /swapfile
|
Enable the swapfile
1
2
| sudo mkswap /swapfile
sudo swapon /swapfile
|
Ensure swap is enabled at boot
1
| sudo bash -c "echo /swapfile none swap defaults 0 0 >> /etc/fstab"
|
Increasing the size of the swapfile
Turn off all swap processes
Resize swap
Normaly you want your swap to be RAM(GB) + 2GB
So if you have 8GB of ram your swap should be 10GB
1
| sudo dd if=/dev/zero of=/swapfile bs=1G count=10
|
Make the file usable as swap
Activate the swapfile
This should be it!