Skip to content

Increase Raspberry Pi Swap Space

ReefSpy edited this page Mar 29, 2024 · 2 revisions

If working on Raspberry Pi 3B you might want to increase the amount of swap space since RPi 3B only has 1GB of memory and 100MB of swap space by default. Raspberry Pi 4 and later should have enough RAM to run everything smoothly so this step is unnecessary. I found this useful while in development since I had multiple ssh sessions, Remote Desktop, Visual Studio Code, etc. open at the same time. The small amount of memory on Raspberry Pi 3B could quickly fill up.

Increasing Swap Space (for Raspberry Pi 3B) (refer to https://pimylifeup.com/raspberry-pi-swap-file/)

sudo dphys-swapfile swapoff 
sudo nano /etc/dphys-swapfile 

Find:

CONF_SWAPSIZE=100 

Change value to this and save:

CONF_SWAPSIZE=1024 

Activate the new swap space by executing following commands:

sudo dphys-swapfile setup 
sudo dphys-swapfile swapon 

Reboot system for changes to take effect:

sudo reboot 

Verify with:

free -m