An NFS export is active only after the saved export definition has been loaded into the server export table. A directory can exist on disk and still be unavailable to clients when its export line is missing, ignored because of the drop-in filename, or reloaded with different client selectors than intended.

Linux NFS servers read export definitions from /etc/exports and from files ending in .exports under /etc/exports.d. A drop-in such as /etc/exports.d/projects.exports keeps one shared path separate from other exports, while /etc/exports remains acceptable for simple hosts with only a few rules.

Each export line starts with a local path, followed by one or more client selectors and optional parenthesized options. The example uses the documentation subnet 192.0.2.0/24 as a placeholder, grants write access with rw, applies writes synchronously with sync, avoids subtree checks for a dedicated export path, and keeps root_squash so client-side root maps to anonymous IDs instead of server-side root.

Steps to create an NFS export:

  1. Open a shell on the NFS server with an account that can use sudo.
  2. Create a group for accounts that should write to the export.
    $ sudo groupadd --system nfs-projects

    Skip this command when an application group already controls the directory. Use a group whose numeric ID policy makes sense on the clients that will write files.

  3. Create the directory with shared group ownership and setgid permissions.
    $ sudo install -d -o root -g nfs-projects -m 2775 /srv/nfs/projects

    The setgid bit keeps new files under /srv/nfs/projects in the directory group. Filesystem ownership and mode still control writes even when the export uses rw.

    With root_squash enabled, client UID/GID 0 maps to anonymous IDs. Do not depend on remote root access for writes; use matching user or group ownership for accounts that should create files.

  4. Create the export drop-in directory.
    $ sudo install -d -o root -g root -m 0755 /etc/exports.d

    Some systems create /etc/exports.d only after a package or administrator adds it. exportfs reads files in this directory only when their names end in .exports.

  5. Open the drop-in export file.
    $ sudo vi /etc/exports.d/projects.exports

    Use /etc/exports instead on small servers where keeping all export rules in one file is clearer.

  6. Add the export definition.
    /srv/nfs/projects 192.0.2.0/24(rw,sync,no_subtree_check,root_squash)

    Keep no whitespace between the client selector and its option list. 192.0.2.0/24(rw,sync) applies those options to that subnet, while 192.0.2.0/24 (rw,sync) changes how exports(5) parses the rule.

  7. Review the client selector before loading the export.

    Avoid broad writeable exports such as *(rw,sync,no_subtree_check) unless the NFS server is intentionally isolated and every client on the reachable network is trusted.

  8. Reload the active export table.
    $ sudo exportfs -rv
    exporting 192.0.2.0/24:/srv/nfs/projects

    exportfs -r synchronizes the active table with /etc/exports and /etc/exports.d, including removal of saved entries that no longer exist.

  9. Verify that the export is loaded with the intended selector and options.
    $ sudo exportfs -v
    /srv/nfs/projects
    		192.0.2.0/24(sync,wdelay,hide,no_subtree_check,sec=sys,rw,root_squash,no_all_squash)

    exportfs may show defaults such as wdelay, hide, sec=sys, and no_all_squash in addition to the options saved in the file.

  10. Check the NFS server unit before client testing.
    $ sudo systemctl is-active nfs-server
    active

    Clients also need network access to the server's NFS ports. Check the server firewall when exportfs -v is correct but remote mounts time out.

  11. Mount the export from a host allowed by the client selector.
    $ sudo mount -t nfs4 files.example.net:/srv/nfs/projects /mnt/projects

    Replace files.example.net with the NFS server name and use an empty local mount point. The client host must match 192.0.2.0/24 or the selector used in the saved export line.

  12. Confirm that the client sees the mounted export.
    $ findmnt -o TARGET,SOURCE,FSTYPE,OPTIONS /mnt/projects
    TARGET        SOURCE                               FSTYPE OPTIONS
    /mnt/projects files.example.net:/srv/nfs/projects nfs4   rw,relatime,vers=4.2,proto=tcp