BACKGROUND INFORMATION :
I have an init script that allows me to
mount a folder to
tmpfs, while bind-mounting the folder on drive to another location, so I can sync the contents (on startup, shutdown, and when needed) between the
tmpfs and the original folder on system drive.
It's used mostly to move to ram the folders and stuff that is written often to avoid excessive writes in the system drive (which is a USB flash or SD card).
I have a different init script for each mountpoint I need (each is actually generated by a setup script which is not relevant here).
Each of these init scripts does (as soon as possible during boot):
- bind mount of folder X to another folder called X-bindmount located somewhere else in main drive. (the folder X-bindmount is also created if needed)
- mount folder X as
- move content from X-bindmount to X (which is now a
- on shutdown or when asked to it syncs from X to X-bindmount.
How can I do this more or less natively with
I can cobble together a
systemd service that calls a script, what I'm asking is if there is a better, native way.