Minimize wear of the microSD
The main storage drive of a Raspberry Pi is typically a microSD card. These are generally durable in terms of severe weather conditions and extensive wear, but when put in constant write and read, they will degrade very quickly.
I once used a Raspberry Pi as a home server, which was on 24/7. So I had to minimize reads and writes to the microSD card in order to maximize the lifespan of the card by reducing its wear.
Migrate to tmpfs
An important step is migrate as much as possible to tmpfs (RAM). We want the following to be stored in RAM, not on the microSD card:
/tmp
/var/spool/rsyslog/
- Any application-specific temporary files
Edit /etc/fstab
and add the following lines:
tmpfs /tmp tmpfs defaults,noatime,nosuid,nodev 0 0
tmpfs /var/spool/rsyslog tmpfs defaults,noatime,nosuid,nodev,noexec,size=50M 0 0
Logs into RAM
I’ve installed Log2Ram
in order to log into RAM and only occasionally write to the disk.
For installing onto Debian 12, I’ve done the following: (check the Github repository)
echo "deb [signed-by=/usr/share/keyrings/azlux-archive-keyring.gpg] http://packages.azlux.fr/debian/ bookworm main" | sudo tee /etc/apt/sources.list.d/azlux.list
sudo wget -O /usr/share/keyrings/azlux-archive-keyring.gpg https://azlux.fr/repo.gpg
sudo apt update
sudo apt install log2ram