[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [ezjail] zfs datasets won't automount inside jail

Hi Patrick,

El 22/04/2015 a las 10:47, patpro AT patpro DOT net escribió:
Hi Vedad,

On 22 avr. 2015, at 10:31, Vedad KAJTAZ <vedad AT kajtaz DOT net> wrote:

You're being lucky if the above works. It will randomly fail.

The issue is that zfs datasets are being linked to the jail from the host system (ezjail issues the "zfs jail <id> <dataset>" command) after the jail startup (since the above command requires the jail id), that is, after the jail_MYJAIL_exec_start is fired from within the jail.

The only rock solid working solution is to write a jail startup script (jail_MYJAIL_exec_start) that will wait for the zfs datasets to appear (eg. by checking the "zfs list" output in a while/sleep loop) before issuing the zfs mount command (unless you have zfs_enable="YES" set in rc.conf, then it will implicitly mount), and before running the /etc/rc script.

In fact, I've tried zfs_enable="YES" in my jail's /etc/rc.conf, but it would not work at all (100% failure across reboots).
I guess I'm going to write a script to handle all this mess :)
I'll have to create a total of 11 jails, I don't want something randomly failing in the event of a reboot.

Indeed, there is no alternative to making the jail startup script.
Moreover, make sure it will run *before* /etc/rc, otherwise your daemons that might require data on a zfs dataset will fail to start.

Feel free to use the following scripts:

- One of the ezjail scripts:

Note that ZFS_DATASETS may contain several, space separated, zfs datasets.

- rc.boot.zfs that launches rc.mount.zfs and returns success (so that ezjail-admin start returns immediately):


- rc.mount.zfs that waits for dataset(s) to appear in the jail, then launches /etc/rc:


- rc.shutdown.zfs that unmounts datasets on shutdown (otherwise they actually do remain mounted... this is only because I don't set zfs_enable="YES" in jails)


Note also that rc.boot.zfs explicitly attempts to unmount datasets before mounting them - otherwise the mount (if not properly unmounted during the previous shutdown) fails upon jail restart.

Kind regards,



Attachment: smime.p7s
Description: Firma criptográfica S/MIME