exportfs
Make directories available for NFS sharing
SYNOPSIS
exportfs [-avi] [-o options] [-f] [-s] [-r] [-u directory] [host:/path]
Common usages:
exportfs -a
exportfs -r
exportfs -u directory
PARAMETERS
-a
Export or unexport all directories listed in /etc/exports. Typically used to load all exports into the kernel or remove them all.
-r
Reexport all directories. This causes exportfs to re-read /etc/exports and update the kernel's export table with any changes, effectively refreshing all exports.
-u directory
Unexport the specified directory. This removes the given directory from the kernel's export table, making it unavailable to NFS clients.
-v
Verbose output. Shows what exportfs is doing.
-o options
Specify export options directly on the command line, similar to those found in /etc/exports (e.g., ro, rw, sync). These apply to the specified host:/path or all exports if -a is used.
-i
Ignore /etc/exports. When this option is used, command-line arguments are the definitive source, and /etc/exports is not read.
-f
Force exportfs to flush and reload the kernel's export table. Useful for situations where the kernel state might be out of sync.
-s
Suppress output. Disables the default behavior of showing which exports are added or removed.
DESCRIPTION
exportfs is a utility used to maintain the kernel's table of currently exported NFS filesystems. It works in conjunction with the /etc/exports file, which defines the list of directories that NFS servers should make available to NFS clients. While /etc/exports defines the desired state of exports, exportfs is the command that applies these definitions to the running kernel. It can be used to export all directories listed in /etc/exports, unexport specific directories, or re-export them to apply changes without needing to restart the entire NFS server (nfsd service). This dynamic capability is crucial for managing NFS shares on a live server without service interruptions, allowing administrators to add, remove, or modify export options on the fly. However, it's important to remember that changes made solely with exportfs are not permanent and will be lost upon reboot unless saved to /etc/exports and re-applied at system startup.
CAVEATS
Persistence: Changes made with exportfs are not persistent across reboots unless the /etc/exports file is updated accordingly and the NFS server service is configured to apply these changes at startup.
Security: Ensure that the options specified via exportfs -o are carefully chosen to prevent unintended access or security vulnerabilities.
Client Cache: NFS clients might cache information; changes might not be immediately reflected on all clients. Clients may need to remount.
Firewall: exportfs only manages the kernel export table; it does not configure firewall rules. Ensure NFS-related ports (2049, 111, etc.) are open if required.
APPLYING CHANGES PERMANENTLY
To make changes to NFS exports permanent, first modify the /etc/exports file. Then, use exportfs -r (to re-export all, applying changes) or exportfs -a (to export all if not already exported) to update the kernel's export table. Finally, ensure your system's NFS server service is configured to re-read and apply /etc/exports at boot (e.g., by enabling nfs-server.service with systemctl).
VERIFYING EXPORTS
After running exportfs, you can verify the currently exported directories using showmount -e localhost or by checking the contents of /proc/fs/nfsd/exports (though this file might vary or be less human-readable).
HISTORY
exportfs has been a fundamental part of the NFS server utilities since its early implementations on Linux. It provides a crucial mechanism for dynamically controlling NFS exports without requiring full server restarts, which is particularly important for high-availability systems and production environments. Its development has focused on reliability and integration with the kernel's NFS module to ensure consistent and efficient export management.
SEE ALSO
exports(5), nfsd(8), mountd(8), showmount(8), rpcinfo(8)