How to export and mount ZFS as READ-ONLY in jail?

What is the easiest way to export a ZFS filesystem (created using "zfs create ..." command) and mount it as READ-ONLY in a jail?

The ZFS filesystem can be either create in the global (non-jail) environment, or within another jail.
 
# zfs create -o mountpoint=/usr/ports tank/FreeBSD/ports
# mount -t nullfs -o ro /usr/ports /jail/myjail/usr/ports

You can add that line to, for example /etc/fstab.myjail:
Code:
/usr/ports                      /jail/myjail/usr/ports                nullfs  ro      0       0

And in /etc/rc.conf:
Code:
jail_myjail_mount_enable="YES"
Then it'll be automatically mounted/unmounted when the jail starts/stops.
 
Hi,

Pardon the necrobump, but is storing a /etc/fstab.jailname on the host system still the proper way of doing mounting to it, or has that functionality been moved to /etc/jail.conf?

Thanks!
 
ManBitesDog said:
is storing a /etc/fstab.jailname on the host system still the proper way of doing mounting to it, or has that functionality been moved to /etc/jail.conf?
When I set
Code:
jail_test_allow_mount="YES"
for a test jail, it looks for a /etc/fstab.test file, but if I understand the jail(8) manual correctly, it's also possible to manage the mounting through /etc/jail.conf. Moreover, I'm not entirely sure but I seem to remember that configuring jails in /etc/rc.conf is deprecated and /etc/jail.conf should be used instead.

Please note that the above applies to FreeBSD 9, things may be different in FreeBSD 10. So if you're using the latter, I suggest you just try it out.
 
Back
Top