LinuxCommandLibrary

exportfs

Make directories available for NFS sharing

SYNOPSIS

exportfs [-aiorsv] [-o optlist] [host:]path ...
exportfs -r [-av] [-o optlist] [host:]path ...
exportfs -u [-av] [host:]path ...
exportfs -f

PARAMETERS

-a
    Export or unexport all directories listed in /etc/exports

-i
    Interactive mode for re-exporting (prompt before changes)

-o optlist
    Set export options (e.g., rw,sync,no_root_squash)

-r
    Re-export all directories, syncing /etc/exports with kernel

-u
    Unexport directories matching specified paths or hosts

-s
    Export without updating /var/lib/nfs/xtab (store only)

-v
    Verbose output, showing actions taken

-f
    Commit current exports to kernel export table

DESCRIPTION

The exportfs command is a key utility for administering NFS (Network File System) exports on Linux systems. It allows administrators to dynamically export or unexport directories to remote clients without restarting the NFS server daemon. Primarily, it reads the /etc/exports file, which defines the file systems to be shared, along with client permissions and options like sync/async, rw/ro, and security flavors.

Common use cases include applying all exports with exportfs -a, re-exporting after editing /etc/exports using exportfs -ra, or unexporting specific paths with exportfs -u. It updates kernel export tables via the NFS pseudo-filesystem and maintains state in /var/lib/nfs/etab and /var/lib/nfs/rmtab. This enables seamless sharing of directories over the network, supporting scalability in clustered environments.

While powerful, it requires root privileges and careful configuration to avoid security risks like unauthorized access. It's integral to NFSv3 and NFSv4 setups, working alongside daemons like nfsd and rpc.mountd.

CAVEATS

Requires root privileges. Changes are temporary unless /etc/exports is updated; not persistent across reboots. Mismatches between etab and kernel can occur if interrupted. Use cautiously to prevent exposing sensitive data.

KEY FILES

/etc/exports: Export definitions.
/var/lib/nfs/etab: Local exports table.
/var/lib/nfs/rmtab: Remote mounts table.
/proc/fs/nfs/exports: Kernel runtime view.

EXAMPLES

exportfs -a -v: Apply all exports verbosely.
exportfs -o rw,sync 192.168.1.0/24:/home: Export /home read-write.
exportfs -u client:/shared: Unexport from specific client.

HISTORY

Developed as part of Linux NFSv2/v3 support in the early 1990s, integrated into nfs-utils package around 1996. Evolved with NFSv4 features like idmapping; maintained in modern distributions like RHEL and Ubuntu.

SEE ALSO

showmount(8), nfsd(8), rpc.mountd(8), mount.nfs(8), nfsstat(8)

Copied to clipboard