Installing Linux on a Raspberry PI for example is great! however… if you’ve decided to install the OS to an SD card, it’ll eventually wear it out. Since this happened to me after a year of operating or so I decided to dive into the OS writes a little bit and found that most writes were to:

  • /tmp
  • /var/cache/apt
  • /var/spool/mqueue
  • /var/tmp

To mitigate the problem (extending the SD card’s lifespan) I decided on the settings in my /etc/fstab file as follows:

/swapfile none swap sw 0 0
tmpfs /tmp tmpfs defaults,noatime,nosuid,size=200m 0 0
tmpfs /var/cache/apt tmpfs defaults,noatime,nosuid,size=1000m 0 0 
tmpfs /var/log tmpfs defaults,noatime,nosuid,size=200m 0 0
tmpfs /var/spool/mqueue tmpfs defaults,noatime,nosuid,size=30m 0 0
tmpfs /var/tmp tmpfs defaults,noatime,nosuid,size=400m 0 0

Of course different settings could work better for your unit, don’t forget that upon rebooting you’ll lose all data in these folders. Reason for the size limits is to not fully fill up the memory of the Pi.

Spec wise I’m currently running this on a

  • Raspberry PI 4 model B
  • 8 GB Ram
  • 16 GB SD Card

Hope this helps you out as well 😉

Categories:

Tags:

Comments are closed