1

From this, I gather that RAM-directory /run/user/1000 is accessible by me, and by processes running under my account (I'm uid 1000).

I'm working on an application that needs to write a small packet of data every 10 seconds. In order to minimize wear on the SD-card, I want to write it to a tmpfs, and then copy accumulated packets to the SD-card every hour or so.

I have this, after startup.

me@Rpi:~ $ df
Filesystem     1K-blocks    Used Available Use% Mounted on
tmpfs              22904       0     22904   0% /run/user/1000

I could use it for my application, or create a new, dedicated one. The latter option, I assume will never conflict with other user processes, but I guess it will occupy RAM, and there's only 256 MB of it.

So is there any best practice here?

RolfBly
  • 609
  • 1
  • 9
  • 24

1 Answers1

2

As per man tmpfs:

The filesystem consumes only as much physical memory and swap space as is required to store the current contents of the filesystem.

Depending on the system this may be sort of obvious when you compare the output of df and free; the former can show various potentially large chunks of RAM allocated to tmpfs mounts while the latter shows much less than that actually consumed by the system (eg. you could have 2 GB in tmpfs but only 250 MB RAM used; in fact, there is no enforced limit to the size of the partition and the "on paper" value shown by df can be much larger than the total RAM and swap space).

So there's no issue here with that space being wasted; the allocation is really the maximum that can be occupied by the mounted filesystem. This being the case, if you are worried your app may starve others and vice versa, provide it with a dedicated mount.

There is other interesting stuff in the man page, BTW, worth a look especially if you are creating a mount.

goldilocks
  • 60,325
  • 17
  • 117
  • 234