Related to the answer by @basic6, I had to figure out where the environments file is held on our CentOS 7 system.
TL;DR
We changed the RPCNFSDARGS variable in /etc/sysconfig/nfs
.
Where is the config file?
Here is the systemd service:
sudo systemctl status nfs-server.service
● nfs-server.service - NFS server and services
Loaded: loaded (/usr/lib/systemd/system/nfs-server.service; enabled; vendor preset: disabled)
Drop-In: /run/systemd/generator/nfs-server.service.d
└─order-with-mounts.conf
Active: active (exited) since Tue 2019-06-25 13:12:19 CEST; 7min ago
Main PID: 44563 (code=exited, status=0/SUCCESS)
Tasks: 0
Memory: 0B
CGroup: /system.slice/nfs-server.service
In /usr/lib/systemd/system/nfs-server.service
we notice the ExecStart but also EnvironmentFile and the Wants/After service:
[Unit]
...
Wants=nfs-config.service
After=nfs-config.service
[Service]
EnvironmentFile=-/run/sysconfig/nfs-utils
...
ExecStart=/usr/sbin/rpc.nfsd $RPCNFSDARGS
So we may want to change the RPCNFSDARGS variable to include "--no-nfs-version 4". The EnvironmentFile is recreated by the nfs-config service. Let's look into /usr/lib/systemd/system/nfs-config.service
:
[Service]
...
ExecStart=/usr/lib/systemd/scripts/nfs-utils_env.sh
That script creates the EnvironmentFile and gets it initial variables from /etc/sysconfig/nfs
at the top of its script:
#!/bin/sh
#
# Extract configuration from /etc/sysconfig/nfs and write
# environment variables to /run/sysconfig/nfs-utils to be
# used by the systemd nfs-config service
#
nfs_config=/etc/sysconfig/nfs
if test -r $nfs_config; then
. $nfs_config
fi
@basic6 referred to /etc/default/nfs-kernel-server
, in our case it is /etc/sysconfig/nfs
.
Adding the --no-nfs-version
option
Next to that, we choose to change the RPCNFSDARGS variable in /etc/sysconfig/nfs
instead of RPCNFSDCOUNT as it seems more neat:
diff --git a/etc/sysconfig/nfs b/var/tmp/nfs.XXS8L74E
index 74104d3..82bc1b4 100644
--- a/etc/sysconfig/nfs
+++ b/var/tmp/nfs.XXS8L74E
@@ -11,7 +11,7 @@
#LOCKD_UDPPORT=32769
#
# Optional arguments passed to rpc.nfsd. See rpc.nfsd(8)
-RPCNFSDARGS=
+RPCNFSDARGS="--no-nfs-version 4"
# Number of nfs server processes to be started.
# The default is 8.
RPCNFSDCOUNT=32