jails Jail's fstab Inside Encrypted ZFS Dataset. Jail Fails to Launch

Each jail's specific data lives inside its own dataset: zusr/$name. This includes the fstab, which (if the dataset is encrypted/unmounted), won't be available until zfs mount -l zusr/$name.

Naturally, I thought that I could put some logic in exec.prepare, which performs this command before the jail attempts to mount anything. However, launch is failing with
Code:
root@quBSD:~ # jail -vc $name
jail: $name: mount.fstab: /zusr/$name/rw/etc/fstab: No such file or directory

/etc/jail.conf has the line: mount.fstab="/zusr/$name/rw/etc/fstab";

So it seems that jail wants to see the fstab file in existence, even before it actually attempts to run the mount command. While I can work around this by removing this line in jail.conf, and just doing it manually in the exec script, somehow I feel like this failure shouldn't happen until after exec.prepare finishes, seeing as how that's specifically reserved for actions to take before mounting. Actions such as unlocking/mounting the encrypted dataset, which might contain critical data for the jail.

Perhaps I'm missing an option or something? Rarely if ever have I felt like a certain logic/flow in FreeBSD should be different, but I think this one might make sense.
 
Looking into this on my own system taught me a few things, so first, thank you for posting this.

Second, what version of FreeBSD is running on the jail host, and what version in the jail? It looks like exec.prepare and exec.release were added in to stable/12 on May 21, 2020, so I'm assuming 12.2 or above?

If you don't have a typo in your /etc/jail.conf, maybe file a problem report?
I'm running 14.0-p4 on both host and jails. My jail.conf has been working fine for a long time for me, and I only encountered an error when incorprating zfs encrypted datasets.

It's been a few months, but I remember playing around with making edits to a jail's fstab inside of exec.prepare, but that the edits did nothing. It gave me the distinct impression that the fstab was being cached somehow, at the outset of `jail -c` before the completion of exec.prepare.

I think I'll file a problem report.
 
Back
Top