Categories
gnu/linux

setup and use nfs server on rhel 8

default nfs version in rhel 8 is version 4

install nfs-server

dnf -y install nfs-server nfs-utils

most probably the nfs-utils package is there on your server already.

ensure nfs server starts up automatically

systemctl enable --now nfs-server

firewall stuff

firewall-cmd --add-service=nfs --add-service=rpc-bind --add-servicemountd --permanent
firewall-cmd --reload

add directories to share on the nfs server

file controlling the exports is /etc/exports

check out the man page for exports for more details

man exports

example content for /etc/exports file (pasted from the exports man page)

EXAMPLE
# sample /etc/exports file
/               master(rw) trusty(rw,no_root_squash)
/projects       proj*.local.domain(rw)
/usr            *.local.domain(ro) @trusted(rw)
/home/joe       pc001(rw,all_squash,anonuid=150,anongid=100)
/pub            *(ro,insecure,all_squash)
/srv/www        -sync,rw server @trusted @external(ro)
/foo            2001:db8:9:e54::/64(rw) 192.0.2.0/24(rw)
/build          buildhost[0-9].local.domain(rw)
 

The first line exports the entire filesystem to machines master and trusty.  In addition to write access, all uid squashing is turned off for host trusty. The second and third entry show examples for wildcard hostnames and netgroups (this is the entry `@trusted'). The fourth line shows  the  entry  for the PC/NFS client discussed above. Line 5 exports the public FTP directory to every host in the world, executing all requests under the nobody account. The insecure option in this entry also allows clients with NFS implementations that don't use a reserved port for NFS.  The sixth line exports a directory read-write to the machine 'server' as well as the `@trusted' netgroup, and read-only to netgroup `@external', all three mounts with the `sync' option enabled. The seventh line exports a directory to both an IPv6 and an IPv4 subnet. The eighth line demonstrates a character class wildcard match.

mount nfs shared directories on your machine

you’ve got 2 options – root mount, and directory mount.

root mount – if you mount the / of the nfs server, then all the shared directories with you will appear in this mount.

otherwise you may check what directories are shared with you using:

showmount --exports <server_address>

now mount them individually using the mount command

notes for adding an entry in the fstab

version may be specified using the nfsvers= argument

important – remember to add the _netdev to the options to mount the nfs share after the networking has started on the machine, else…

example /etc/fstab entry for a nfs share

nfshost:/   /nfs-share   nfs   defaults,_netdev   0 0

resolving permissions issue while using nfs

try chown‘ing the nfs shared directories to nobody

monitoring nfs server

nfsstat and nfsiostat

Leave a Reply

Your email address will not be published. Required fields are marked *