I hope this is an appropriate place for this question as it involves the use of the kernel.

I have an embedded system with a battery backup for the RAM chip. The battery also allows for the MCU to gracefully shutdown.

The data I am writing to RAM goes in the /tmp folder. When Linux shuts down and then eventually boots up again, I lose access to the RAM.

In the graceful shutdown process, is it possible to save the mounting location (memory location) of /tmp to a file in non-volatile memory so that when Linux boots up again it can line up the memory and allow me to access the preserved RAM accurately?

If so, how can this be done?



closed as too broad by Eugene Sh., RoyC, laptop2d, Elliot Alderson, Finbarr Oct 18 '18 at 9:36

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • \$\begingroup\$ You should use a different folder than /tmp, /var/cache for example. Anyway, this is a linux question, there are other sites for this. unix.stackexchange.com \$\endgroup\$ – Jeroen3 Oct 15 '18 at 11:36

Keeping power is not enough to preserve regular SDRAM contents. At the very least, you will have to provide clock and periodically send the "refresh command" if you need to preserve the contents for more than a few milliseconds or tens of milliseconds. If your system allows to keep the DRAM controller working while the rest of the system is off, try doing that when you power off.

If you can source PSDRAM (pseudo-static DRAM) or self-refreshing SDRAM (example), you won't have to worry about refresh, as the SDRAM controller will be embedded in the RAM itself. This is what some mobile phones and other portable gadgets use to reduce current consumption in sleep mode. You'll still have to provide clock for it to work.

Note that tmpfs is not designed with any kind of persistence in mind: the filesystem simply gets recreated from scratch every time you mount it. Also, /tmp is the wrong place to keep persistent files anyway. Even if you get to preserve RAM contents and write a persistence-aware filesystem driver, Linux is free to wipe the /tmp folder when it reboots.


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