NFS share as Avahi service

Network

You can make NFS shares available with the Avahi Service. All you have to do is create an Avahi service. If the service is set up correctly, file browsers with Zeroconf support can find the shares automatically.

Setup NFS share in “/etc/exports”

First we create the share in the “/etc/exports” file:

/export/photos                192.168.3.0/24(rw,nohide,insecure,no_subtree_check,no_root_squash)

Adjusts the IP address range in the example above to your network. The “insecure” option is important, without which the release via Avahi will not work. Then restart the NFS server for the changes to take effect.

Setup Avahi Service

Create a new file in the “/etc/avahi/services” directory. In my case I use “nfs_photos.service”. Then open it in an editor of your choice and fill it with the following content:

<?xml version="1.0" standalone='no'?>
<!DOCTYPE service-group SYSTEM "avahi-service.dtd">
<service-group>
  <name replace-wildcards="yes">NFS Photos on %h</name>
  <service>
    <type>_nfs._tcp</type>
    <port>2049</port>
    <txt-record>path=/export/photos</txt-record>
  </service>
</service-group>

If necessary, adjust the file permissions so that the Avahi Daemon has access to them.

Then restart the daemon for the change to take effect.

Check function

You can check if the share is visible with the following command:

avahi-browse -a

Your rshareshould appear somewhere in the output. In my case it is in the 4th line.

+    br0 IPv4 distcc@server            _distcc._tcp         local
+    br0 IPv4 server                   _sftp-ssh._tcp       local
+    br0 IPv4 server                   _ssh._tcp            local
+    br0 IPv4 NFS Photos on server     _nfs._tcp            local     

This concludes this tutorial. I hope it was helpful for you!