On Thu, 15 Nov 2018, Don NetBSD wrote: > I've a box with a DoM. I'd like to mount / as ro and create a > tmpfs for /var (and /tmp). I don't think anything else NEEDS to > be rw (the infrequent changes to /etc can be made by unlocking / > to make those changes). > > I imagine I can just make a tarball of a skeletal /var and > unpack this over /var, once mounted? > > Is there a preexisting mechanism for this sort of thing? > Or, do I roll my own?
Have a look at the /etc/mtree/ specifications. Many /var/ entries in there. You could use it to create your own spec file for your required files and directories with correct ownership and permissions and then run mtree to generate them. Or (looking at my notes from 2002), I used a /var.copy directory pre-populated as needed and after the /var was mounted and "cp -R -p /var.copy/* /var" into it.
