RaspberryPi 2 Model B SD Life Extender

I am a very happy owner of a RaspberryPi Model B 2, a quad core ARMv7  computation unit for a price between 45 and 35 €.

If you plug only a network cable it can be powered by a USB port of your router (!avoid putting on it other USB stuff, because the energy drain can be too much).

RaspberryPI  is a perfect all-time-running machine, just follow this smart guide…

My 1995 PC was a 486DX with a 512MB hard disk and 8MB of RAM, powered with a Slackware-Linux operating system. The RaspberryPi is a dream box for me, with a quad-core 900Mhz ARM Cortex and 1024MB of RAM in a tiny space.

First of all, googling on Internet it seems the SD Card life is very limited (1 month) for a long running machine if you use it like a mechanical disk. So you must reduce to the minimum the stress on the SD Card, employing the same setup you would use for a Solid State Drive (SDD).
Our setup plan will use a NetworkAreaStorage Server to store backup and 3-rd part software. Synology is our choice, but you can use what you want.

Let’s start

  1. Setup your timezone time, otherwise your cron jobs will start in the wrong moments…
    sudo dpkg-reconfigure tzdata
  2. Adjust the sizes of the tmpfs mounts in /etc/default/tmpfs. I suggest to enable /tmp in RAM, to speed up things a bit.
  3. Ensure your root partition is mounted with noatime in the /etc/fstab(this is the default, and greatly extend SD life and speed up things too)
  4.  Zap the swap
    The simpler and not destructive way of doing it is…

    sudo dphys-swapfile swapoff
    sudo dphys-swapfile uninstall
    sudo update-rc.d dphys-swapfile remove
  5. Verify the swap is gone and if not remove /var/swap by hand.
  6. Increase your NASperformance. Googling, a good shot seems to  have a 32KB buffer, so add to /etc/fstab a line like
    nfshostname:/volume/rpi /rpi    nfs    nolock,nouser,rsize=32768,wsize=32768,atime,auto,rw,dev,exec,suid    0    0

    This will give you a good network performance (around 10 Mb/s at least).

  7. Last but not least, keep an eye on your CPU temp, if needed…

    /opt/vc/bin/vcgencmd measure_temp

    This nice link will help you to learn how to gather other system information, you should log from time to time.

Now your last enemy could be /var/log.

Between reboots it can increase in size of about 96Kb, mostly because of your cron jobs. Anyway logging is a very critical part of a long running box, so my suggestion is to avoid putting it on tempfs and leave raspberry colleting logs, rotating them and so on.

Last but not least, backup your SD on time to time

Try it, Play with it, and do not fear of breaking it.

 

 

Leave a Reply