Swap configuration guide for Raspberry Pi
Check the available swap:
free -h
Turn off the swap:
sudo dphys-swapfile swapoff
Check that no swap is available:
free -h
Edit configuration:
sudo nano /etc/dphys-swapfile
In the configuration, change the value of CONF_SWAPSIZE
as desired (in MiB):
# CONF_SWAPSIZE=200
CONF_SWAPSIZE=1024
Save and exit, then set up the swap file:
sudo dphys-swapfile setup
Expected output:
want /var/swap=1024MByte, checking existing: deleting wrong size file (104857600), generating swapfile ... of 1024MBytes
Enable swapping:
sudo dphys-swapfile swapon
Verify that the available swap is as desired:
free -h
Known issue
The default swap size in /etc/dphys-swapfile
is 200
. However, the actual swap available was 100 MiB (104857600).
Maybe a restart is needed to verify that this configuration guide works as intended.
References
https://forums.raspberrypi.com/viewtopic.php?t=46472#p1687676