What it does
The NFS server reads /etc/exports and /etc/exports.d/*.exports when it starts. After editing, run exportfs -ra to apply the changes without a restart. exportfs -v shows what is exported now, with all options.
How to write it
exportfs [-avfrsu] [-o OPTIONS] [CLIENT:/PATH]
exportfs -ra | -ua | -v | -sOptions 9
Most used
Nothing matches this filter.
Examples 10
$ run as a normal user# run as root (or with sudo)
1Apply changes of /etc/exports
exportfs -raNo restart of nfs-server needed.
2Show active exports
exportfs -v /exports/data 192.168.122.0/24(sync,wdelay,hide,no_subtree_check,sec=sys,rw,secure,root_squash,no_all_squash)All options, also the defaults.
3Example exports file
cat /etc/exports /exports/data 192.168.122.0/24(rw,sync) /exports/home 192.168.122.0/24(rw,sync)Folder, then client(options) — no space before the bracket!
4Export for a moment (not saved)
exportfs -o ro,sync 192.168.122.20:/srv/isoGone after a restart.
5Stop exporting one folder
exportfs -u 192.168.122.0/24:/exports/dataClients lose access.
6Stop all exports
exportfs -uaFor maintenance.
7Files in exports.d
echo "/srv/iso *(ro)" > /etc/exports.d/iso.exports; exportfs -raOne file per share is easy to manage.
8The space mistake
cat /etc/exports /exports/data 192.168.122.0/24 (rw)With a space, (rw) applies to everyone and the network gets read-only: a security hole.
9Read-only for all, write for one host
echo "/exports/pub *(ro) 192.168.122.20(rw)" >> /etc/exports; exportfs -raDifferent options per client.
10Check the server service
systemctl status nfs-serverexportfs works only with the server running.
Nothing matches this filter.
Files
/etc/exports, /etc/exports.d/*.exports- Export definitions.
/var/lib/nfs/etab- The active export table.
Exit codes
0 | Done. |
1 | Error. |