$ exportfs: Failed to stat [MY ZPOOL]: No such file or directory

I recently exported a Zpool without first removing the corresponding sharenfs option. On the next reboot, exportfs attempted to share this directory from a pool which is no longer mounted (as it doesn’t exist anymore).

Removing a failing NFS export from dead/exported zfs sharenfs option can be done by first trying:

exportfs -r

from man exportfs:

-r Reexport all directories, synchronizing /var/lib/nfs/etab with /etc/exports and files under /etc/exports.d. This option removes entries in /var/lib/nfs/etab which have been deleted from /etc/exports or files under /etc/exports.d, and removes any entries from the kernel export table which are no longer valid.

Now I tried this, but running exportfs still shows the exported NFS share and subsequently, a restart of nfs-server.service still shows

$ exportfs: Failed to stat [ZPOOL]: No such file or directory

I then manually edited out the failing entry from /etc/exports.d/zfs.exports.

This is of course despite the warning up top…

!!! DO NOT EDIT THIS FILE MANUALLY !!!

After doing another exportfs -r, exportfs now shows the old dataset removed, and systemctl restart nfs-server now succeeds!