To increase the size of the swap file on a Raspberry Pi, edit the dphys-swapfile file with the following command:
sudo nano /etc/dphys-swapfile
and change the line CONF_SWAPFILE=100 to CONF_SWAPFILE=2048 (if you want 2048 MB; this depends on your Raspberry Pi’s RAM).
Now restart the Raspberry Pi with the command:
sudo reboot now.
By default, the Raspberry Pi is set up with 100 MB (you can check this size by running the command:
swapon
Enjoy!
