2

I've got a more common question. I come from bare metal microcontroller development - there we usually avoid flash write access for several reasons. one is to avoid damage of the flash memory because of too many erase/write cycles.

the raspberry is running from a sd card, which is also flash memory.

So i ask myself whats with the linux system running on a embedded system and the "everything is a file" philosophy.

Is the system writing every time physically to the flash (e.g. for logging) or is there a driver layer which collects requests and writes bigger blocks delayed to the physical semiconductor?

When i write scripts for the embedded system, should I avoid redirection like foo > tmp.file temporary file writes when the script is running every minute and data could be also held in RAM?

i am curious whats your expert opinion about it...

1 Answer 1

1

Your understanding of the problem seems to underestimate the write life of the given flash memory.

"everything is a file" philosophy.

This is true, but only kind of. The "everything is a file" philosophy doesn't mean it's a legitimate (as in physical) file. /proc/cpuinfo, for example, is a "file", but it doesn't reside anywhere on the disk. It's a virtual file. Anything you write to or read from that "file" is coming straight from memory.

Is the system writing every time physically to the flash (e.g. for logging) or is there a driver layer which collects requests and writes bigger blocks delayed to the physical semiconductor?

All modern operating systems have a buffer that tries to make writing more efficient. So, in some sense, it will try to block the data a little, but the RPi will log just like any other desktop/server OS.

When I write scripts for the embedded system, should I avoid redirection like foo > tmp.file temporary file writes when the script is running every minute and data could be also held in RAM?

It's not really necessary to avoid the temporary writes. I would just log directly to the file. I find your design choice a little odd, but it's not wrong or ill advised per say.

9
  • thank you. what did you mean with "log directly to the file" , just to do not use temporary (files)
    – twooBeers
    Commented Apr 11, 2016 at 19:16
  • @user3336433: correct. I don't see a point in using a temporary file when you could just write to whatever the normal file is.
    – Jacobm001
    Commented Apr 12, 2016 at 19:25
  • right. but if i am on shell and may need a step in between (may for debugging) its difficult to have an alternative. let say to put a file into a temp. buffer located in RAM. /tmp is also located inside non volatile memory, or ?
    – twooBeers
    Commented Apr 14, 2016 at 16:40
  • @user3336433: If you have a legitimate need for a temporary file, then go for it as you're already doing. I thought you were trying to use a temp file to somehow reduce device writing.
    – Jacobm001
    Commented Apr 14, 2016 at 16:48
  • And yes, /tmp is usually stored on the sdcard, but that may change slightly based on the distro.
    – Jacobm001
    Commented Apr 14, 2016 at 16:49

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.