2022年12月26日 星期一

[pi, memory, swap] How to increase your swap file size for your Raspberry Pi

 How to increase your swap file size for your Raspberry Pi?

井民全, Jing, mqjing@gmail.com


1. Quick

top # check the original swap file size


# turn off the swap system

sudo dphys-swapfile swapoff  

sudo vi /etc/dphys-swapfile # setup new swap size


File: /etc/dphys-swapfile

...

CONF_SWAPSIZE=1024


# recreate the swap file

sudo dphys-swapfile setup


# turn on the swap file system

sudo dphys-swapfile swapon


# Check

top


2. Procedure

Check current swap size

top

E.g.


2.1. Step 1: Turn off the swap file function

sudo dphys-swapfile swapoff

E.g.

Check 

top


2.2. Step 2: Setup the configuration file

vi sudo vi /etc/dphys-swapfile


File: /etc/dphys-swapfile

...

CONF_SWAPSIZE=1024


E.g.


2.3. Step 3: Re-initialize the system

Force system to re-create a new swap file.

sudo dphys-swapfile setup

E.g.


2.4. Step 4: Turn the swap system back on

sudo dphys-swapfile swapon

E.g.


3. Reference

  1. https://pimylifeup.com/raspberry-pi-swap-file/