ZFS Shares not exported until sharenfs property re-set on Ubuntu 16.04
I am setting up ZFS and NFS on Ubuntu Server 16.04LTS and have a weird issue that is causing me to go crazy. I have set up ZFS and NFS using ZFS shares as described in https://pthree.org/2012/12/31/zfs-administration-part-xv-iscsi-nfs-and-samba/. As you can see in my log below, although I have set zfs-share to run zfs share -a
during boot, the shares are still not exported. Even weirder, is that zfs share -a
still doesn't when I manually run it. I can only get zfs shares to work if I reset the sharenfs
property of one of the shares and then re-run zfs share -a
. See below
$ showmount -e
Export list for apu:
/mnt localhost
$ sudo zfs share -a
$ showmount -e
Export list for apu:
/mnt localhost
$ sudo zfs share pool1
cannot share 'pool1': filesystem already shared
$ sudo zfs get sharenfs pool1
NAME PROPERTY VALUE SOURCE
pool1 sharenfs on local
$ sudo zfs set sharenfs=on pool1
$ showmount -e
Export list for apu:
/s/apu/a/homes *
/s/apu/a *
/s/apu/a/sys *
/mnt localhost
$ sudo zfs share -a
$ showmount -e
Export list for apu:
/s/apu/b *
/s/apu/a/homes *
/s/apu/a *
/s/apu/a/sys *
/s/apu/b/cwc *
/mnt localhost
Solution 1:
My Ubuntu 16.04.05 LTS has a similar problem.
First question: are you using systemd or the older-style init system? 16.04 uses systemd by default and the ZFS components are not really well debugged.
Next time you reboot and your shares are not there, try:
# systemctl restart zfs-share.service
and then see if the shares are there with showmount. BTW on my system I have a problem with the RPC registration service coming up so you might have to do:
# systemctl start rpcbind.service
if rpcbind isn't running first.
If this mitigates your problem you might consider adding those commands to your system rc file but I just do it manually each time I reboot.
Solution 2:
I also faced this problem under Ubuntu 16.04, but that probably applies to newer versions as well.
There is a bug that systemd unit zfs-share.service
does not perform sharenfs -a
on startup https://github.com/zfsonlinux/zfs/issues/1375
As a workaround, you can add that to /etc/rc.local
sudo zfs unshare -a
sudo zfs share -a
See this discussion for details: https://github.com/zfsonlinux/zfs/issues/2107#issuecomment-47182970