Running histor/recorder from ram drive


Having lost my second SD card, looking at the possibility the SD is simply getting worn out with too many writes, looking at disk writes generated by HA moving recording to a RAM drive seems like a sensible idea.

Running HA on raspbian, path to ram drive is: /mnt/ram_disk and using the standard HA database which I understand is SQLAlchemy.
Hence my recorder section of configuration has the following line added to redirect to the RAM drive:

   db_url: sqlite:////mnt/ram_disk

But the recorder fails to load with the following error logged:

ERROR (Recorder) [homeassistant.components.recorder] Error during connection setup: (sqlite3.OperationalError) unable to open database file (Background on this error at: (retrying in 3 seconds)

Thanks in advance!


1 Like

So RAM drive… will be lost if you restart? Why not just exclude entities from history?
What kind of SD-Cards are you using? (Also could be power supply)

I used this for awhile with tmp on tmpfs. This was before I moved off the rPI and onto a NUC but had too many devices that the DB writes were bringing my system down.

I think you have one too many /'s

db_url: sqlite:///tmp/home-assistant_v2.db


Worked it out…needed to include the filename! :thinking:
db_url: sqlite:////mnt/ram_disk/filename

No great loss if I do lose history on the odd reboot and really don’t need to look back anything past the last 24hrs so committing a small amount of ram to storage should work out well.
Now thinking…might use a USB flash drive instead of the ram drive, if it wears out a flash drive no big deal
Been using brand names such as sandisk and purchasing these from element14, so original and should be good.
Running a custom powersupply solution from a battery and been well engineered, 3.3V is rock solid so that’s not the culprit.

Bottom line is via iotop seeing constant writes to the SD card, which simply can’t be healthy longterm.