I tried looking for a similar question but had no luck.

The goal is to extend the sdcard's lifetime by saving data to RAM instead of the card.

The program in question is running every 30mins to n-hours (not sure yet) and will fetch data from a webpage the internet (web crawling) and save it locally to compare with the next fetch cycle if the data changed.

So my goal is to "save" in Memory instead of the sdcard.

An idea I have from to top of my head is to save with WriteMemoryProcess or some other C, x86 Assembler register etc.. trickery.

Actually, is this even worth it? I installed Log2RAM but I don't know if something like this would make any difference.

2 Answers 2


There is a 'wearout mechanism' in all SD cards. It follows that the less you write to any given SD card, the longer it will last. I think it's reasonable to be concerned about failures regardless of whether or not you've experienced them. @Milliways' makes a sound point in his answer regarding longevity and costs, but these are judgments which will vary depending upon use-case and individual preference.

Wrt your headline question, the answer is "Yes, it is possible to write/save data/variables to memory instead of the SD card." Perhaps the simplest way is to write your saved webpage data in /tmp; e.g. /tmp/webpagedata/somefilename.

/tmp uses the tmpfs file system, and in most modern Linux systems (including RPi OS), /tmp is automatically mounted as a tmpfs by systemd. Which means that you needn't bother with creating an entry for it in /etc/fstab - you simply boot, and use it. Write to it in exactly the same way you would write to a file on your SD card.

But, depending on your use-case, there may be a catch(see #13): Everything you write to /tmp will be lost in a reboot. Consequently, depending on your requirements, you may or may not need to take measures to avoid data loss. And therein lies the rub - if you can't afford to lose any data, you must backup /tmp to non-volatile media.

  • 1
    "* if you can't afford to lose any data, you must backup /tmp to non-volatile media*". If you can't afford to lose data, don't save it to /tmp...
    – David Arno
    Commented Nov 5, 2021 at 9:06

Similar questions are asked often, usually by people who have no actual experience of failure.

There are means of minimising writes, but in 9 years with multiple Pi several running 24/7 I have only 2 failures. SD Cards are so cheap they should be considered expendable and reliable brands last years.

My original Pi Model B is still running, although it is only pulled out occasionally. My Pi Model B+ running Stretch has been logging data continuously since January 2019.

On the other hand I have a dozen HDD which have failed.

  • So what you are saying is that the n interval writes to the sdcard (in a file) are acceptable/not worth thinking about memory & sdcard lifespan etc...?
    – anon
    Commented Nov 5, 2021 at 1:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.