Skip to content

How to set up ramdisk for the rrd database on a Rasperry Pi

Anders Nylund edited this page Jan 31, 2018 · 5 revisions

Guide written by Steen Andreassen.

A SD-card have a limit number of writecycles, so if a RRD-database is put on the SD-card, it will wear out very fast. This guide will help you create a ramdisk on the Raspberry Pi.

First, create a mountpoint for our new ramdisk:

sudo mkdir /mnt/ramdisk

Now we need to be sure, that our ramdisk is mounted during boot-time:

sudo nano /etc/fstab

Add this line:

tempfs /mnt/ramdisk tmpfs defaults,noatime,size=20M,mode=1777 0 0

This will create a ramdisk of 20M. The pellmon DB is ~8M, so less than 20M will also be ok. Now mount the new filesystem:

sudo mount /mnt/ramdisk

Or

sudo mount –a

You can check that the new ramdisk is mounted by:

sudo mount

Or

df -h

Last step is to configure pellmon to use the rrd-database on the ramdisk:

nano /etc/pellmon/conf.d/database.conf

Change the database property:

database = /var/lib/pellmon/rrd.db

To:

database = /mnt/ramdisk/rrd.db

Finally tell PellMon where to persist the rrd-database when stopping PellMon by removing the hash in front of:

persistent_db = /var/lib/pellmon/nvrrd.db

Now restart PellMon

sudo service pellmonsrv restart