On a specific machine I use a lot of RAM to serve websites really fast directly from RAM (which by the way is working amazingly well). For this I have mounted a ramdisk in /etc/fstab (in debian 7, via tmpfs) like so;
tmpfs /ramd tmpfs defaults,relatime,size=2G 0 0
I run a bunch of scripts in crontab to sync dirs from disk into /ramd when /ramd is empty, and from /ramd to disk when the dirs exist.
Now, obviously, I need to sync from RAMdisk to harddisk before a reboot, and back again in reverse at bootup.
I used to just run the sync from crontab every several minutes, but this is really overkill, since it has power backup and so it never shuts down unplanned, basically the only time it needs ram to sync back to disk.
I looked around and experimented for a while now, for the best ways to accomplish this without crontab. Just running sync scripts as init.d scripts seems awfully complex for the task. The only dependency for the syncjob would be that the ram is still mounted, so that would probably be
and the only dependency at startup would be that nginx has not yet started, and of course that fstab has already been processed.
Any insight on how to best accomplish this, either with or without init script, is very welcome.
The reason init.d seems a bit odd is that it would not hold up after OS changes or upgrades. There's enough custom made in the system as it is.