I am working on a solution for mass jails deployment based on ZFS datasets and unionfs.
A jail template is created by extracting base archive into the dataset. Then the dataset is mounted read-only in all the jails' roots and each jail has its own lean dataset, where only the deltas are stored.
The goal is, when an update is applied, only the template is modified and the jails automatically get the updates without duplicating the files for each jail.
My problem is, when I start a jail with initially empty top unionfs layer (R/W), many standard files in /bin, /lib, /sbin etc. get rewritten with the current timestamp but the sizes are identical. This bloats the jail's dataset and will probably break the update, when I update the template, the older files from the jails will hide what is the latest version in the lower unionfs layer.
Why do the binary files get rewritten? This happens only for a handful of them, for example /bin/sh, /bin/cat, /bin/mkdir etc. In total, it's about 7 MB and ~300 files.
Here is a little visual help about the situation:
level 0 ------ jail*/root, R/W -------------- : should contain only the changed files in each jail (but the rewritten files in /bin land here and hide the respective files in level 1).
level 1 ------ template/root, R/O -------------- : contains the system base, completely generic, to be updated regularly
I know about the possibility to mount read-only directories via nullfs, but this option looks quite complicated compared to the simple layering with unionfs, which should work in principle.
A jail template is created by extracting base archive into the dataset. Then the dataset is mounted read-only in all the jails' roots and each jail has its own lean dataset, where only the deltas are stored.
The goal is, when an update is applied, only the template is modified and the jails automatically get the updates without duplicating the files for each jail.
My problem is, when I start a jail with initially empty top unionfs layer (R/W), many standard files in /bin, /lib, /sbin etc. get rewritten with the current timestamp but the sizes are identical. This bloats the jail's dataset and will probably break the update, when I update the template, the older files from the jails will hide what is the latest version in the lower unionfs layer.
Why do the binary files get rewritten? This happens only for a handful of them, for example /bin/sh, /bin/cat, /bin/mkdir etc. In total, it's about 7 MB and ~300 files.
Here is a little visual help about the situation:
level 0 ------ jail*/root, R/W -------------- : should contain only the changed files in each jail (but the rewritten files in /bin land here and hide the respective files in level 1).
level 1 ------ template/root, R/O -------------- : contains the system base, completely generic, to be updated regularly
I know about the possibility to mount read-only directories via nullfs, but this option looks quite complicated compared to the simple layering with unionfs, which should work in principle.