NFS.SYSTEMD(7)

πŸ’– NFS.SYSTEMD(7) πŸ’–

okay bestie, pull up a chair, this is nfs.systemd from the Miscellaneous Information Manual (section 7, the good one) and it's literally all about managing NFS services through systemd. no cap.


✨ NAME ✨

nfs.systemd β€” managing NFS services through systemd. πŸŽ€


🌸 SYNOPSIS 🌸

nfs-utils.service
nfs-server.service
nfs-client.target
etc

πŸ¦‹ DESCRIPTION πŸ¦‹

so the nfs-utils package ships a whole suite of systemd unit files and generators, and they're what let all the various services get started and managed. these unit files and generators are the reason everything kicks off in the correct order β€” they make sure the prerequisites are actually active before any dependant services start. 🫢

but here's the thing: there are quite a few unit files and generators, so it's genuinely not immediately obvious how best to achieve certain results. the following subsections attempt to cover the issues that are most likely to come up. iykyk. πŸ’…

βš™οΈ Configuration

standard systemd unit files do not give you any easy way to pass command line arguments to daemons so you can configure their behavior. in many cases you can still do that config by making changes to /etc/nfs.conf or other configuration files (see nfs.conf(5)). πŸ’–

when that's not convenient, a distribution might hand you systemd "drop-in" files which replace the ExecStart= setting, so the program starts with different arguments. for example, a drop-in file systemd/system/nfs-mountd.service.d/local.conf containing:

[Service]
EnvironmentFile=/etc/sysconfig/nfs
ExecStart=
ExecStart= /usr/sbin/rpc.mountd $RPCMOUNTDOPTS

would cause the nfs-mountd.service unit to run the rpc.mountd program using, for arguments, the value given for RPCMOUNTDOPTS in /etc/sysconfig/nfs. this allows for seamless integration with existing configuration tools. slay. ✨

πŸ‘‘ Enabling unit files

there are three unit files which are designed to be manually enabled. all the others are automatically run as required. the three are:

  • nfs-client.target β€” this should be enabled on any host which ever serves as an NFS client. there is little cost in transparently enabling it whenever NFS client software is installed.
  • nfs-server.service β€” this must be enabled to provide NFS service to clients. it starts and configures the required daemons in the required order.
  • nfs-blkmap.service β€” the blkmapd daemon is only required on NFS clients which are using pNFS (parallel NFS), and particularly using the blocklayout layout protocol. if you might use this particular extension to NFS, the nfs-blkmap.service unit should be enabled.

several other units which might be considered to be optional, such as rpc-gssd.service, are careful to only start if the required configuration file exists. rpc-gssd.service will not start if the krb5.keytab file does not exist (typically in /etc). πŸ™ˆ

πŸ”„ Restarting NFS services

most NFS daemons can be restarted at any time. they will reload any state that they need, and continue servicing requests. this is rarely necessary though. πŸ“

when configuration changes are made, it can be hard to know exactly which services need to be restarted to ensure that the configuration takes effect. the simplest approach, which is often the best, is to restart everything. to help with this, the nfs-utils.service unit is provided. it declares appropriate dependencies with other unit files so that

systemctl restart nfs-utils

will restart all NFS daemons that are running. this will cause all configuration changes to take effect except for changes to mount options lists in /etc/fstab or /etc/nfsmount.conf. mount options can only be changed by unmounting and remounting filesystem. this can be a disruptive operation so it should only be done when the value justifies the cost. 😭 the command

umount -a -t nfs; mount -a -t nfs

should unmount and remount all NFS filesystems.

πŸ’€ Masking unwanted services

rarely there may be a desire to prohibit some services from running even though they are normally part of a working NFS system. this may be needed to reduce system load to an absolute minimum, or to reduce attack surface by not running daemons that are not absolutely required.

three particular services which this can apply to are rpcbind, idmapd, and rpc-gssd. rpcbind is not part of the nfs-utils package, but it is used by several NFS services. however it is not needed when only NFSv4 is in use. if a site will never use NFSv3 (or NFSv2) and does not want rpcbind to be running, the correct approach is to run

systemctl mask rpcbind

this will disable rpcbind, and the various NFS services which depend on it (and are only needed for NFSv3) will refuse to start, without interfering with the operation of NFSv4 services. in particular, rpc.statd will not run when rpcbind is masked. πŸ‘‘

idmapd is only needed for NFSv4, and even then is not needed when the client and server agree to use user-ids rather than user-names to identify the owners of files. if idmapd is not needed and not wanted, it can be masked with

systemctl mask idmapd

rpc-gssd is assumed to be needed if the krb5.keytab file is present. if a site needs this file present but does not want rpc-gssd running, it can be masked with

systemctl mask rpc-gssd

🧚 Generators

systemd unit generators are small executables placed in /usr/lib/systemd/system-generators/ to dynamically extend the unit file hierarchy. the nfs-utils package provides three:

  • nfsroot-generator β€” it creates the sysroot.mount unit to mount /sysroot via NFSv4 in the initrd, if it detects one the following options in the kernel command line:
    • root=/dev/nfs nfsroot=[<server>:]<path>[,<options>]

defined in <kernel_source>/Documentation/admin-guide/nfs/nfsroot.rst

  • root=nfs[4]:[<server>:]<path>[:<options>]

defined in dracut.cmdline(7).

NOTE: although "nfs" can be used as type indicator for the mountpoint, the mount unit will use always "nfs4".
  • nfs-server-generator β€” it creates ordering dependencies between nfs-server.service and various filesystem mounts: it should start before any "nfs" mountpoints are mounted, in case they are loop-back mounts, and after all exported filesystems are mounted, so there is no risk of exporting the underlying directory.
  • rpc-pipefs-generator β€” it creates ordering dependencies between NFS services and the rpc_pipefs mountpoint.

πŸŽ€ FILES πŸŽ€

  • /etc/nfs.conf
  • /etc/nfsmount.conf
  • /etc/idmapd.conf

also similar files in /usr/etc and in related conf.d drop-in directories. πŸ’–


🌈 SEE ALSO 🌈

bootup(7), systemd.generator(7), systemd.unit(5), nfs.conf(5), nfsmount.conf(5).


and that's the whole vibe, bestie β€” you just read NFS.SYSTEMD(7) from the Miscellaneous Information Manual, and it's giving certified unix baddie energy. go forth and systemctl responsibly. mwah. πŸ’…βœ¨πŸ¦‹πŸ’–

πŸ“¦ where this page comes from