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...

goldilocks
  • 60,325
  • 17
  • 117
  • 234
twooBeers
  • 123
  • 3

1 Answers1

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.

Jacobm001
  • 11,904
  • 7
  • 47
  • 58