If you’re on a first generation Raspberry Pi you don’t have much RAM, so it makes sense to increase the swapfile size to be able to do more with your Pi. I’ll show you how!

First, edit the file /etc/dphys-swapfile

sudo nano /etc/dphys-swapfile

Change the line:

CONF_SWAPSIZE=100

To something like:

CONF_SWAPSIZE=512

This will increase the swapfile setting from 100M to 512M. Note that if the line is commented out with # you should remove the hash. If the option does not exist, add it.

Now let’s apply the setting with:

sudo dphys-swapfile swapoff
sudo dphys-swapfile setup
sudo dphys-swapfile swapon

Now to verify it worked, run:

free -h

Which should show something like:

Swap:         511Mi

And that’s all there is to it! Enjoy your added swap!