Swap
Turn off
sudo dphys-swapfile swapoff
Change Size
First of all, tell the OS to not use the swap file anymore (see above).
Now open the following file to change the size of the swap file:
sudo nano /etc/dphys-swapfile
Find the following line and change the number (in MB):
CONF_SWAPSIZE=100
Save the file.
Re-create the new swap file:
sudo dphys-swapfile setup
Let the OS know to use the swap file again and reboot the system (see below).
Turn on
sudo dphys-swapfile swapon
sudo reboot
Log2RAM
To expand the lifespan of the SD card used by the Raspberry Pi, you can use Log2RAM to offload the Log files to a RAM disk, which will reduce the number of active writes to the SD card.
Install
sudo apt install rsync
wget https://github.com/azlux/log2ram/archive/master.tar.gz -O log2ram.tar.gz
tar xf log2ram.tar.gz
cd /home/pi/log2ram-master
sudo ./install.sh
Config
To make sure, that the RAM disk is large enough to contain all files in “/var/log”, you should check and configure the max. size of the RAM disk:
sudo nano /etc/log2ram.conf
Find the following line:
SIZE=40M
Change this number to e.g.:
SIZE=128M
Save the file.
Reboot the system:
sudo reboot