increase swap memory of raspberry pi & Debian-based distros
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
| free -h # check the amount of swap memory
sudo nano /etc/dphys-swapfile # edit this file
CONF_SWAPSIZE=200 # find this line
CONF_SWAPSIZE=1024 # change from 200 into 1024
CTRL + X, then Y and Enter # to Save and exit
sudo dphys-swapfile swapoff # Disable current swap
sudo dphys-swapfile setup # Apply new swap size
sudo dphys-swapfile swapon # Enable new swap
free -h # check if the swap size has increased
|
step by step
- check the amount of swap memory
- edit this file
1
| sudo nano /etc/dphys-swapfile
|
- find this line
- change from 200 into 1024
- Save and exit with
- (CTRL + X, then Y and Enter)
- Disable current swap
1
| sudo dphys-swapfile swapoff
|
- Apply new swap size
1
| sudo dphys-swapfile setup
|
- Enable new swap
1
| sudo dphys-swapfile swapon
|
- check if the swap size has increased
Increase Swappiness (Use Swap More Frequently)
- Swappiness controls how aggressively Linux swaps memory to disk. A higher value makes the system use swap more often, which can help when RAM is limited
*Check Current Swappiness (Default is usually 60.)
1
| cat /proc/sys/vm/swappiness
|
1
| sudo nano /etc/sysctl.conf
|
- Add this line at the bottom
- Save and exit, apply changes
1
| CTRL + X, then Y and Enter
|
This should help your Raspberry Pi run smoother with more available virtual memory