I use Raspberry Pi 4 to run Home Assistant, AdGuard Home and other software. My Raspberry Pi has SSD and flash card. Flash cards usually live shorter, and it makes sense to reduce the amount of write operations there.

Disable Swap File

Using swap file results in numerous read/write operations, which can slow down the system. It's wiser to avoid using it, especially if you have 8GB RAM in your Raspberry Pi, but it all depends on how you use it.

$ sudo vim /etc/dphys-swapfile
CONF_SWAPSIZE=0

Change location of Docker directory

Disclaimer: This will work only if you have an external drive connected to your Raspberry Pi.

Docker needs to keep somewhere all images, volumes, temporary files, etc. It requires a lot of read and write operations, so we can place them to our external drive instead of SD card.

# Stop Docker process
sudo service docker stop

# Move the directory to your SSD
sudo mv /var/lib/docker <path_to_your_external_drive>

# Link Docker directory to your SSD
sudo ln -s <path_to_your_external_drive>/docker /var/lib/docker

# Start Docker process
sudo service docker start

Write logs to RAM

Writing system logs to RAM can seriously decrease the amount of write operations to our SD card. Don’t use it if you don’t have enough free RAM. I use ‣ with the following configuration:

sudo journalctl --vacuum-size=10M
sudo journalctl --vacuum-time=1d

# Set SystemMaxUse=10M and RuntimeMaxUse=10M
sudo vim /etc/systemd/journald.conf

# Set SIZE=150M
sudo vim /etc/log2ram.conf