When learning NixOS, I found references to the concept of “darling erasure” and the value of resetting the root file system between reboots to keep the system clean and having control over the configuration. I think this makes a lot of sense but I have not seen so many references to this with respect to data that is maintained by services. For example, data below /var/lib and /var/cache is often where a service stores the data it maintains. It is certainly possible to redirect this data on a service-by-service case, but I wonder if it makes more sense to exclude these directories from “darling erasure” entirely.
To give an example, the navidrome and jellyfin media services both maintain their databases there, and both seem to take advantage of systemd’s conventions in this regard. From Dynamic Users with systemd :
" With systemd 235 this limitation is removed: there are now three new settings: StateDirectory=
, LogsDirectory=
and CacheDirectory=
. In many ways they operate like RuntimeDirectory=
, but create sub-directories below /var/lib
, /var/log
and /var/cache
, respectively. There’s one major difference beyond that however: directories created that way are persistent , they will survive the run-time cycle of a service, and thus may be used to store data that is supposed to stay around between invocations of the service."
I am considering creating separate subvolumes in my btrfs setup to exclude them from root, because of this. Do you think this makes sense, or do I miss the point of darling erasure with that approach?