How to add Swap File
- Create a file that will be used for swap: sudo fallocate -l 1G /swapfile. ...
- Only the root user should be able to write and read the swap file. ...
- Use the mkswap utility to set up the file as Linux swap area: sudo mkswap /swapfile.
- Enable the swap with the following command: sudo swapon /swapfile.