본문 바로가기
Linux/RaspberryPi Server

[RaspberryPi] SWAP Size 지정

by 暻煥 2024. 2. 4.

라즈베리 파이를 사용하다 보면,

memory부족으로 인한 OOM(Out of Memory)을 자주 만나게 된다.

 

OOM을 피하기 위해서 swap 크기를 늘려서 memory 증가와 같은 효과를 만들 수 있다.

 


먼저, 아래 명령어를 통해서 swap-off 한다.

$ sudo dphys-swapfile swapoff

 

/etc/dphys-swapfile 파일을 편집해서 swap 크기를 지정한다.

CONF_SWAPSIZE 값을 원하는 값으로 조정한다. 단위는 [MB]이다.

 

 

다시 swap-on 하고,

$ sudo dphys-swapfile swapon

 

free 명령어로 확인하면, 입력한 대로 swap disk 크기가 변한 것을 알 수 있다.

$ free -h
               total        used        free      shared  buff/cache   available
Mem:           1.8Gi       166Mi       308Mi       848Mi       1.3Gi       766Mi
Swap:          499Mi       3.0Mi       496Mi

 


※ 출처

https://linuxhint.com/increase-memory-raspberry-pi/

 

How to Increase Memory on Raspberry Pi

The low memory issue is one of the significant problems for Raspberry Pi users who use the Raspberry Pi model with 2GB or 4GB RAM. The low memory issue directly slows down the performance of the applications running on the Raspberry Pi system. The ideal wa

linuxhint.com

.