Create swap file on Raspberry Pi Zero W

First check if you have swap configured:

swapon --show

IF empty you can create for example 256MB swap file with following commands:

fallocate -l 256M /var/swap
chmod 600 /var/swap
mkswap /var/swap
swapon /var/swap

You can again check if swap is properly configured:

#swapon --show
NAME      TYPE SIZE USED PRIO
/var/swap file 256M   0B   -2

#free -m
              total        used        free      shared  buff/cache   available
Mem:            480         109         140           9         229         312
Swap:           255           0         255

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.