The goal is to minimize writes to /var on SSD.
Mounting /var read-only won't solve it, obviously - it changes too frequently, not only when we decide to update something. So the solution is to mount /var as tmpfs, and sync it with the SSD copy on init (as early as possible, to eliminate the chance of something useful being overwritten by something useless) and SSD copy with tmpfs on shutdown (as late as possible, to make less useless writes).
First task is fairly simple - we just place
The second task is harder: we have to compare the last modification timestamp of each file and directory contents. A custom script which would parse several
Are there some other solutions?
Mounting /var read-only won't solve it, obviously - it changes too frequently, not only when we decide to update something. So the solution is to mount /var as tmpfs, and sync it with the SSD copy on init (as early as possible, to eliminate the chance of something useful being overwritten by something useless) and SSD copy with tmpfs on shutdown (as late as possible, to make less useless writes).
First task is fairly simple - we just place
cp -R /somedir/var.bak/ /var
somewhere in rc.d.The second task is harder: we have to compare the last modification timestamp of each file and directory contents. A custom script which would parse several
ls -c
outputs and then recursively check directoriess and then copy new files doesn't seem to be right way, also I'm not yet familiar enough with sh
syntax.Are there some other solutions?